Beispiel #1
0
def list_on_sections(guid, responseType):

    forceRefresh = False
    if request.args.get("refresh"):
        forceRefresh = str_to_bool(request.args.get("refresh"))

    # Listing the Onenote notebooks
    if is_access_token_valid() == False:
        if responseType == safeglobals.TYPE_JSON:
            return jsonify(status=safeglobals.http_unauthorized,
                           message=safeglobals.MSG_NO_TOKENS)
        elif responseType == safeglobals.TYPE_SELECT:
            return send_response(
                [{
                    "guid": "",
                    "name": "Access token expired or doesn't exist"
                }], responseType, {"default": "select.sections.html"})
        else:
            return render_template("onenote.token.expired.html"), 401

    # Getting a list of sections
    access_token = get_access_token(safeglobals.service_onenote)
    sections = list_sections(access_token, forceRefresh, guid)

    # Returning response based on specified format
    return send_response(sections, responseType,
                         {"default": "select.sections.html"})
Beispiel #2
0
def list_onenote_notebooks(responseType):

    forceRefresh = False
    if request.args.get("refresh"):
        forceRefresh = str_to_bool(request.args.get("refresh"))

    # Checking the access token
    if is_access_token_valid() == False:
        if responseType == safeglobals.TYPE_JSON:
            return jsonify(status=safeglobals.http_unauthorized,
                           message=safeglobals.MSG_NO_TOKENS)
        elif responseType == safeglobals.TYPE_SELECT:
            return send_response(
                [{
                    "guid": "",
                    "text": "Access token expired or doesn't exist"
                }], responseType, {"default": "onenote.select.notebooks.html"})
        else:
            return render_template("onenote.token.expired.html")

    # Getting access token and getting a list of notebooks
    access_token = get_access_token(safeglobals.service_onenote)
    notebooks = list_on_notebooks(access_token, forceRefresh)

    # Returning response based on specified format
    return send_response(notebooks, responseType,
                         {"default": "onenote.select.notebooks.html"})
Beispiel #3
0
def searches(responseType):
   
    # Getting access token
    access_token = get_access_token()
    if access_token == "":
        abort(safeglobals.http_bad_request,{"message":safeglobals.ERROR_NO_TOKEN})
    
    # Getting a list of Saved Searches
    searches = list_searches(access_token,False)

    # Returing the response based on specified format
    return send_response(searches,responseType,{safeglobals.TYPE_HTML:'list.searches.html'})
Beispiel #4
0
def tags():
    
    # Default values
    forceRefresh = False
    responseType = "html"

    # Checking request parameters
    if request.args.get("refresh"):
        forceRefresh = request.args.get("refresh")
    if request.args.get("format"):
        responseType = request.args.get("format")

    # Getting access token
    access_token = get_access_token()
    if access_token == "":
        abort(safeglobals.http_bad_request,{"message":safeglobals.ERROR_NO_TOKEN})

    # Getting a list of tags
    tags = list_tags(access_token,forceRefresh)

    # Returning response based on specified format
    return send_response(tags,responseType,{safeglobals.TYPE_SELECT:"select.tags.html",safeglobals.TYPE_HTML:'list.tags.html'})
Beispiel #5
0
def notebooks(responseType):

    # Checking Access Token
    access_token = get_access_token()
    if access_token == "":
        abort(safeglobals.http_bad_request,
              {"message": safeglobals.ERROR_NO_TOKEN})

    forceRefresh = False
    if request.args.get("refresh"):
        forceRefresh = str_to_bool(request.args.get("refresh"))

    # Connecting to Evernote
    note_store = get_note_store(access_token)

    # Getting a list of notebooks
    notebooks = list_notebooks(note_store, access_token, forceRefresh)

    # Returning response based on specified format
    return send_response(
        notebooks, responseType, {
            safeglobals.TYPE_SELECT: "select.notebooks.html",
            safeglobals.TYPE_HTML: "list.notebooks.html"
        })