Esempio n. 1
0
def task_add():
    ticket_form = TicketForm()
    task_info = ticket_status()
    ticket_form.site.choices = [(site.site, site.site) for site in Site.query.order_by(Site.site.asc()).all()]
    if ticket_form.validate_on_submit():
        ticket = Ticket(
            sales=current_user.alias,
            task=ticket_form.task.data,
            site=ticket_form.site.data,
            client=ticket_form.client.data,
            linkman=ticket_form.linkman.data,
            contack=ticket_form.contack.data,
            body=ticket_form.body.data,
            status="audit"
        )
        add_sql = edit(ticket, record=False)
        add_sql.run('add')
        sms = SendSms(ticket)
        sms.run()
        flash(u'任务添加成功')
        return redirect(url_for('.task_search', search='status==audit'))
    else:
        for key in check_field :
            if ticket_form.errors.get(key, None):
                flash(ticket_form.errors[key][0])
                break
    return render_template('ticket/task_add.html', task_info=task_info, sidebar=sidebar, 
                            ticket_form=ticket_form)
Esempio n. 2
0
def task_audit():
    # 审核工单
    ticket_id = int(request.form["ticket_id"])
    result = request.form["result"]
    headnote = request.form["headnote"]
    if len(headnote) > 32:
        return "审核失败 审核批注最多32个字符" 
    ticket =Ticket.query.filter_by(id=ticket_id).first()
    if result == "agree":
        state = "approved"
    else:
        state = "failure"
        change_sql = edit(ticket, 'end_datetime', datetime.datetime.now(), record=False)
        change_sql.run('change')
    if ticket:
        if ticket.auditor:
            return "审核失败 这个工单已审核"
        change_sql = edit(ticket, 'auditor', current_user.alias, record=False)
        change_sql.run('change')
        change_sql = edit(ticket, 'results', result, record=False)
        change_sql.run('change')
        change_sql = edit(ticket, 'headnote', headnote, record=False)
        change_sql.run('change')
        change_sql = edit(ticket, 'status', state, record=False)
        change_sql.run('change')
        sms = SendSms(ticket)
        sms.run()
        return "OK"
    return u"审核失败 没有找到这个工单"
Esempio n. 3
0
def task_status():
    # 更改工单状态
    ticket_id = int(request.form["ticket_id"])
    state = request.form["state"]
    ticket =Ticket.query.filter_by(id=ticket_id).first()
    if ticket:
        if not ticket.auditor:
            return "更改失败 这个工单未审核" 
        
        if ticket.status in ["success", "failure"]:
            return "更改失败 这个工单已经结束"
        
        if current_user.role in ["QUERY", "ALL_QUERY", "AUDIT_QUERY", "ADVANCED_QUERY"]:
            # 获取评价
            evaluate = request.form["evaluate"]
            if ticket.status != "processing":
                return "更改失败 这个任务还没有处理"
            # 防止其他用户提交
            elif current_user.alias == ticket.sales and \
                    state not in ["success", "failure"]:
                return "更改失败 没有更改这个状态权限"
            if len(evaluate) > 32:
                return "更改失败 评价最多32个字符"
            elif state in ["success", "failure"]:
                change_sql = edit(ticket, 'end_datetime', datetime.datetime.now(), record=False)
                change_sql.run('change')
                change_sql = edit(ticket, 'evaluate', evaluate, record=False)
                change_sql.run('change')
        
        if current_user.role == "ALTER":
            if ticket.support:
                return "更改失败 已经更改这个状态"
            if state !="processing":
                return "更改失败 没有更改这个状态的权限"
            change_sql = edit(ticket, 'support', current_user.alias, record=False)
            change_sql.run('change')
        change_sql = edit(ticket, 'status', state, record=False)
        change_sql.run('change')
        sms = SendSms(ticket)
        sms.run()
        return "OK"
    return "更改失败 没有找到这个工单"