Пример #1
0
def tickets_tasks_detail_GET(**kwargs):
    user = auth.authenticate()
    if not user.can_view_tasks():
        abort(403)

    id = kwargs['id']
    t_id = kwargs['t_id']
    task = dbhandler.tickets_tasks_get_detail(t_id, id)

    response = {}
    response['id'] = task[TASK_ID]
    response['ticket'] = task[TASK_TICKET]
    response['ticket_name'] = dbhandler.get_ticket_name(task[TASK_TICKET])
    response['author_id'] = task[TASK_AUTHOR]
    response['author_nickname'] = dbhandler.get_user_name(task[TASK_AUTHOR])
    response['name'] = task[TASK_NAME]
    response['descr'] = task[TASK_DESCR]
    response['state'] = task[TASK_STATE]
    response['ewt'] = task[TASK_EWT]
    response['ats'] = task[TASK_ATS]
    response['created'] = task[TASK_CREATED]
    response['employee_id'] = dbhandler.get_employee(t_id)
    response['employee_name'] = dbhandler.get_user_name(response['employee_id'])

    return jsonify(response)
Пример #2
0
def tickets_detail_GET(**kwargs):
    user = auth.authenticate()
    if not user.can_view_tickets():
        abort(403)

    id = kwargs['id']
    ticket = dbhandler.get_specified_ticket(id)

    response = {}
    response['ticket_id'] = ticket[TICKET_ID]
    response['author_nickname'] = dbhandler.get_user_name(ticket[TICKET_AUTHOR])
    response['author_id'] = ticket[TICKET_AUTHOR]
    response['name'] = ticket[TICKET_NAME]
    response['state'] = ticket[TICKET_STATE]
    response['creation_date'] = ticket[TICKET_CREATED]
    response['product_id'] = ticket[TICKET_PRODUCT]
    response['product_name'] = dbhandler.get_product_name(ticket[TICKET_PRODUCT])
    response['part_id'] = ticket[TICKET_PRODUCT_PART]
    response['part_name'] = dbhandler.get_product_part_name(ticket[TICKET_PRODUCT_PART])
    response['description'] = ticket[TICKET_DESCR]

    # Get the images id list.
    response['images'] = list(map(lambda x: x[0], dbhandler.get_ticket_images(id)))

    return jsonify(response)
Пример #3
0
def tickets_GET(**kwargs):
    user = auth.authenticate()
    if not user.can_view_tickets():
        abort(403)

    help_response = {}
    response = []

    rows = dbhandler.list_tickets()
    for item in rows:
        help_response['ticket_id'] = item[TICKET_ID]
        help_response['author_nickname'] = dbhandler.get_user_name(item[TICKET_AUTHOR])
        help_response['author_id'] = item[TICKET_AUTHOR]
        help_response['name'] = item[TICKET_NAME]
        help_response['state'] = item[TICKET_STATE]
        response.append(help_response)
        help_response = {}

    return jsonify(response)
Пример #4
0
def tickets_tasks_GET(**kwargs):
    user = auth.authenticate()
    if not user.can_view_tasks():
        abort(403)

    help_response = {}
    response = []

    id = kwargs['id']
    tasks = dbhandler.get_ticket_tasks(id)

    for row in tasks:
        help_response['id'] = row[TASK_ID]
        help_response['author_id'] = row[TASK_AUTHOR]
        help_response['author_nickname'] = dbhandler.get_user_name(row[TASK_AUTHOR])
        help_response['name'] = row[TASK_NAME]
        help_response['state'] = row[TASK_STATE]
        response.append(help_response)
        help_response = {}

    return jsonify(response)
Пример #5
0
def tickets_comment_GET(**kwargs):
    user = auth.authenticate()
    if not user.can_view_tickets():
        abort(403)

    help_response = {}
    response = []

    id = kwargs['id']
    comments = dbhandler.get_comments(id)

    for item in comments:
        help_response['id'] = item[COMMENT_ID]
        help_response['author'] = dbhandler.get_user_name(item[COMMENT_AUTHOR])
        help_response['author_id'] = item[COMMENT_AUTHOR]
        help_response['creation_date'] = item[COMMENT_DATE]
        help_response['text'] = item[COMMENT_TEXT]
        response.append(help_response)
        help_response = {}

    return jsonify(response)