tag.py 657 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
from tag import *
from controller_utils import error_message

if request.env.http_origin:
    response.headers['Access-Control-Allow-Origin'] = request.env.http_origin  
    response.headers['Access-Control-Allow-Credentials'] = 'true'
    response.headers['Access-Control-Max-Age'] = 86400

def auto_complete():
    if "group_id" not in request.vars:
        return error_message("missing group id")

    if "query" not in request.vars or request.vars["query"][0] != "#":
        tags = []
    else:
16 17
        prefix = get_tag_prefix()
        tags = get_tags(db, request.vars["group_id"], request.vars["query"][len(prefix):])
18 19

    return tags_to_json(tags)