Ejemplo n.º 1
0
def get_current_todos():
    server = ShorthandServer(current_app.config['config_path'])

    status = get_request_argument(request.args, name='status',
                                  default='incomplete')
    directory_filter = get_request_argument(request.args,
                                            name='directory_filter')
    query_string = get_request_argument(request.args, name='query_string')
    sort_by = get_request_argument(request.args, name='sort_by')
    tag = get_request_argument(request.args, name='tag')
    suppress_future = get_request_argument(request.args,
                                           name='suppress_future',
                                           arg_type='bool', default=True)
    case_sensitive = get_request_argument(request.args, name='case_sensitive',
                                          arg_type='bool', default=False)

    if directory_filter == 'ALL':
        directory_filter = None
    if tag == 'ALL':
        tag = None

    todos = server.get_todos(todo_status=status,
                             directory_filter=directory_filter,
                             query_string=query_string,
                             case_sensitive=case_sensitive, sort_by=sort_by,
                             suppress_future=suppress_future, tag=tag)
    current_app.logger.info(f'Returning {len(todos)} todo results')

    wrapped_response = wrap_response_data(todos)
    wrapped_response['meta'] = analyze_todos(todos)
    return json.dumps(wrapped_response)
Ejemplo n.º 2
0
def get_gps_locations():
    server = ShorthandServer(current_app.config['config_path'])

    directory_filter = get_request_argument(request.args,
                                            name='directory_filter')

    locations = server.get_locations(directory_filter=directory_filter)
    wrapped_response = wrap_response_data(locations)
    return json.dumps(wrapped_response)
Ejemplo n.º 3
0
def fetch_record_sets():
    server = ShorthandServer(current_app.config['config_path'])

    directory_filter = get_request_argument(request.args,
                                            name='directory_filter')
    if directory_filter == 'ALL':
        directory_filter = None

    record_sets = server.get_record_sets(directory_filter=None)
    return json.dumps(wrap_response_data(record_sets))
Ejemplo n.º 4
0
def fetch_questions():
    server = ShorthandServer(current_app.config['config_path'])

    status = get_request_argument(request.args, name='status', default='all')
    directory_filter = get_request_argument(request.args,
                                            name='directory_filter')
    if directory_filter == 'ALL':
        directory_filter = None
    current_app.logger.info(f'Getting {status} questions in '
                            f'directory {directory_filter}')

    questions = server.get_questions(
        question_status=status, directory_filter=directory_filter)
    current_app.logger.info(f'Returning {len(questions)} question results')
    return json.dumps(wrap_response_data(questions))