Beispiel #1
0
def NewNote():

    db = mongoDB("note")
    pages = {
        "cmd": {
            "link": "newNote",
            "name": "New Note"
        },
        "title": "New Note"
    }
    if request.method == "GET":
        s = render_template('newNote.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        tags = request.form["tags"]
        noteText = request.form["note"]
        db.addItem("notes", {"note": noteText, "tags": tags})
        s = render_template('noteAdded.html',
                            p=pages,
                            note=noteText,
                            tags=tags)
    elif request.method == "POST" and request.form["api"] == "true":
        noteText = request.form["note"]
        tags = request.form["tags"].split(",")
        note = {"note": noteText, "tags": tags, "timestamp": time.time()}
        db.addItem("notes", {"note": noteText, "tags": tags})
        s = json.dumps(note)
    return s
Beispiel #2
0
def newPlace():
    db = mongoDB("note")

    if request.method == "GET":
        pages = {
            "cmd": {
                "link": "newPlace",
                "name": "New Place"
            },
            "title": "New Place"
        }
        s = render_template('newPlace.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        pages = {
            "cmd": {
                "link": "newPlace",
                "name": "Place Added"
            },
            "title": "Place Added"
        }
        loc = request.form["location"]
        tags = request.form["tags"]
        noteText = request.form["note"]
        place = {"location": loc, "note": noteText, "tags": tags}
        s = render_template('placeAdded.html', p=pages, placeInfo=place)
    elif request.method == "POST" and request.form["api"] == "true":
        term = request.form["term"]
        s = json.dumps(db.searchForItem(term))
    else:
        s = "not valid"

    return s
Beispiel #3
0
def search():
    db = mongoDB("note")

    if request.method == "GET":
        pages = {"cmd": {"link": "search", "name": "Search"},
                 "title": "Search"}
        s = render_template('search.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        pages = {"cmd": {"link": "search", "name": "Search Result"},
                 "title": "Search Result"}
        term = request.form["term"]
        s = request.form['options']
        results = db.searchForItem(term, sortBy=s)
        for r in results:
            text = Markup(markdown.markdown(r['obj']['note']))
            r['obj']['note'] = text
        s = render_template('searchResult.html',
                            p=pages,
                            searchResults=results)
    elif request.method == "POST" and request.form["api"] == "true":
        term = request.form["term"]
        s = json.dumps(db.searchForItem(term))
    else:
        s = "not valid"

    return s
Beispiel #4
0
def NewTodo():
    db = mongoDB("note")

    pages = {"cmd": {"link": "newTodo", "name": "New ToDo"},
             "title": "New ToDo"}
    if request.method == "GET":
        s = render_template('newTodo.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        todoText = request.form["todoText"]
        done = str(request.form['options'])
        date = request.form['date']
        done = (done == "done")

        todoItem = {"todoText": todoText,
                    "done": done,
                    "date": time.mktime(time.strptime(date, "%m/%d/%Y"))}
        db.addItem("todos", todoItem)
        todoItem['done'] = str(todoItem['done'])
        todoItem['date'] = str(todoItem['date'])
        s = render_template('todoAdded.html', p=pages, todo=todoItem)
    elif request.method == "POST" and request.form["api"] == "true":
        todoText = request.form["todoText"]
        tags = request.form["tags"].split(",")
        todo = {"todoText": todoText, "tags": tags, "timestamp": time.time()}
        dateStr = time.mktime(time.strptime(date, "%m/%d/%Y"))
        db.addItem("todos", {"todoText": todoText,
                             "done": done,
                             "date": dateStr})
        s = json.dumps(todo)
    return s
Beispiel #5
0
def Delete():
    db = mongoDB("note")
    pages = {"cmd": {"link": "delete", "name": "Delete"}, "title": "Delete"}
    if request.method == "GET":
        s = render_template('delete.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        ID = int(request.form["ID"])
        db.deleteItem(ID)
        s = render_template('deleted.html', p=pages, itemID=ID)
    elif request.method == "POST" and request.form["api"] == "true":
        ID = int(request.form["ID"])
        result = db.deleteItem(ID)
        retVal = {"result": result, "ID": ID}
        s = json.dumps(retVal)
    else:
        s = u"not valid"

    return s
Beispiel #6
0
def Delete():
    db = mongoDB("note")
    pages = {"cmd": {"link": "delete", "name": "Delete"}, "title": "Delete"}
    if request.method == "GET":
        s = render_template('delete.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        ID = int(request.form["ID"])
        db.deleteItem(ID)
        s = render_template('deleted.html', p=pages, itemID=ID)
    elif request.method == "POST" and request.form["api"] == "true":
        ID = int(request.form["ID"])
        result = db.deleteItem(ID)
        retVal = {"result": result, "ID": ID}
        s = json.dumps(retVal)
    else:
        s = u"not valid"

    return s
Beispiel #7
0
def NewTodo():
    db = mongoDB("note")

    pages = {
        "cmd": {
            "link": "newTodo",
            "name": "New ToDo"
        },
        "title": "New ToDo"
    }
    if request.method == "GET":
        s = render_template('newTodo.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        todoText = request.form["todoText"]
        done = str(request.form['options'])
        date = request.form['date']
        done = (done == "done")

        todoItem = {
            "todoText": todoText,
            "done": done,
            "date": time.mktime(time.strptime(date, "%m/%d/%Y"))
        }
        db.addItem("todos", todoItem)
        todoItem['done'] = str(todoItem['done'])
        todoItem['date'] = str(todoItem['date'])
        s = render_template('todoAdded.html', p=pages, todo=todoItem)
    elif request.method == "POST" and request.form["api"] == "true":
        todoText = request.form["todoText"]
        tags = request.form["tags"].split(",")
        todo = {"todoText": todoText, "tags": tags, "timestamp": time.time()}
        dateStr = time.mktime(time.strptime(date, "%m/%d/%Y"))
        db.addItem("todos", {
            "todoText": todoText,
            "done": done,
            "date": dateStr
        })
        s = json.dumps(todo)
    return s
Beispiel #8
0
def NewNote():

    db = mongoDB("note")
    pages = {"cmd": {"link": "newNote", "name": "New Note"},
             "title": "New Note"}
    if request.method == "GET":
        s = render_template('newNote.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        tags = request.form["tags"]
        noteText = request.form["note"]
        db.addItem("notes", {"note": noteText, "tags": tags})
        s = render_template('noteAdded.html',
                            p=pages,
                            note=noteText,
                            tags=tags)
    elif request.method == "POST" and request.form["api"] == "true":
        noteText = request.form["note"]
        tags = request.form["tags"].split(",")
        note = {"note": noteText, "tags": tags, "timestamp": time.time()}
        db.addItem("notes", {"note": noteText, "tags": tags})
        s = json.dumps(note)
    return s
Beispiel #9
0
def newPlace():
    db = mongoDB("note")

    if request.method == "GET":
        pages = {"cmd": {"link": "newPlace", "name": "New Place"},
                 "title": "New Place"}
        s = render_template('newPlace.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        pages = {"cmd": {"link": "newPlace", "name": "Place Added"}, "title":
                 "Place Added"}
        loc = request.form["location"]
        tags = request.form["tags"]
        noteText = request.form["note"]
        place = {"location": loc, "note": noteText, "tags": tags}
        s = render_template('placeAdded.html', p=pages, placeInfo=place)
    elif request.method == "POST" and request.form["api"] == "true":
        term = request.form["term"]
        s = json.dumps(db.searchForItem(term))
    else:
        s = "not valid"

    return s
Beispiel #10
0
def search():
    db = mongoDB("note")

    if request.method == "GET":
        pages = {
            "cmd": {
                "link": "search",
                "name": "Search"
            },
            "title": "Search"
        }
        s = render_template('search.html', p=pages)
    elif request.method == "POST" and request.form["api"] == "false":
        pages = {
            "cmd": {
                "link": "search",
                "name": "Search Result"
            },
            "title": "Search Result"
        }
        term = request.form["term"]
        s = request.form['options']
        results = db.searchForItem(term, sortBy=s)
        for r in results:
            text = Markup(markdown.markdown(r['obj']['note']))
            r['obj']['note'] = text
        s = render_template('searchResult.html',
                            p=pages,
                            searchResults=results)
    elif request.method == "POST" and request.form["api"] == "true":
        term = request.form["term"]
        s = json.dumps(db.searchForItem(term))
    else:
        s = "not valid"

    return s