Exemple #1
0
def callback(request):
    try:
        client = get_evernote_client()
        token = client.get_access_token(
            request.session["oauth_token"], request.session["oauth_token_secret"], request.GET.get("oauth_verifier", "")
        )
    except KeyError:
        return redirect("/")

    user = request.user

    new = Token(user=user, string=token, service="Evernote")
    new.save()

    client = get_evernote_client(token)
    note_store = client.get_note_store()
    notebooks = note_store.listNotebooks()

    for notebook in notebooks:
        wall = Wall(user=user, title=notebook.name, not_spaced=True)
        wall.save()
        filter = NoteStore.NoteFilter(notebookGuid=notebook.guid)
        notes = note_store.findNotes(filter, 0, MAX_NOTES).notes

        for i, note in enumerate(notes):
            x = INIT_X + (i * X_SPACING)
            wp = Waypoint(wall=wall, text=note.title, x=x + WP_OFFSET_X, y=INIT_Y + WP_OFFSET_Y)
            wp.save()
            html = note_store.getNote(note.guid, True, True, True, True).content.decode("utf-8")
            marks = html2text(html).split("\n")

            for j, mark in enumerate(marks):
                mark = mark.strip()
                if mark:
                    y = INIT_Y + j * Y_SPACING
                    mark = Mark(wall=wall, text=mark, x=x, y=y)
                    mark.save()

        if len(notebooks) == 1:
            return redirect("/" + str(wall.id))

    return redirect("/")
Exemple #2
0
from django.core.management import setup_environ
from general import settings

setup_environ(settings)

from walls.models import Wall, Mark, Waypoint

hiswall = Wall.objects.filter(pk=2)[0]
hismarks = Mark.objects.filter(wall=hiswall)
hiswaypoints = Waypoint.objects.filter(wall=hiswall)
mywall = Wall.objects.filter(pk=27)[0]

for mark in hismarks:
	new = Mark(wall=mywall, text=mark.text, x=mark.x, y=mark.y)
	new.save()

for wp in hiswaypoints:
	new = Waypoint(wall=mywall, text=wp.text, x=wp.x, y=wp.y)
	new.save()