def search(): start_time = time() result = create_default_result() if request.query.o == '' or not user_auth.check_id(request.query.o): result.update({'message': ''}) return template('auth', result) if not request.forms.get('search'): redirect('/?o=%s' % request.query.o) search = request.forms.get('search') result.update({'username': user_auth.get_email_from_id(request.query.o)}) result.update({'email': search}) result.update({'username_id': request.query.o}) result.update(search_tickets( user_auth.get_rt_object_from_email( user_auth.get_email_from_id(request.query.o) ), search)) # Is there any URGENT ticket? result.update({'urgent': get_urgent_tickets(rt_object)}) result.update({'summary:': get_summary_info()}) result.update({'time_spent': '%0.2f seconds' % (time() - start_time)}) return template('search', result)
def test_search_tickets_With_result(): rt_object = RTApiMock() rt_object.set_return([ u'id: ticket/887677', u'owner: [email protected]', u'subject: create rt dashboard', u'status: open', u'priority: 26', u'cf.{servico}: csc-gsiic', u'cf.{is - informatica e sistemas}: dir-inbox', u'lastupdated: wed jul 15 21:16:50 2015', ]) result = search_tickets(rt_object, '*****@*****.**') assert result == { 'tickets': { '07/15': [{ u'status': u'open', u'priority': u'26', u'lastupdated': u'wed jul 15 21:16:50 2015', 'auxiliary_date': '07/15', u'owner': u'*****@*****.**', u'cf.{is - informatica e sistemas}': u'dir-inbox', 'id': u'887677', u'cf.{servico}': u'csc-gsiic', u'subject': u'create rt dashboard' }] }, 'no_result': False, 'number_tickets': 1, 'email_limit': { 'new': 7, 'open': 1, 'rejected': 7 } }
def search(): start_time = time() result = create_default_result() if request.query.o == '' or not user_auth.check_id(request.query.o): result.update({'message': ''}) return template('auth', result) if not request.forms.get('search'): redirect('/?o=%s' % request.query.o) search = request.forms.get('search') result.update({'username': user_auth.get_email_from_id(request.query.o)}) result.update({'email': search}) result.update({'username_id': request.query.o}) result.update( search_tickets( user_auth.get_rt_object_from_email( user_auth.get_email_from_id(request.query.o)), search)) # Is there any URGENT ticket? result.update({'urgent': get_urgent_tickets(rt_object)}) result.update({'summary:': get_summary_info()}) result.update({'time_spent': '%0.2f seconds' % (time() - start_time)}) return template('search', result)
def search(): start_time = time() result = create_default_result() if request.query.o == "" or not user_auth.check_id(request.query.o): result.update({"message": ""}) return template("auth", result) if not request.forms.get("search"): redirect("/?o=%s" % request.query.o) search = request.forms.get("search") result.update({"username": user_auth.get_email_from_id(request.query.o)}) result.update({"email": search}) result.update({"username_id": request.query.o}) result.update( search_tickets(user_auth.get_rt_object_from_email(user_auth.get_email_from_id(request.query.o)), search) ) # Is there any URGENT ticket? result.update({"urgent": get_urgent_tickets(rt_object)}) result.update({"time_spent": "%0.2f seconds" % (time() - start_time)}) return template("search", result)
def test_search_tickets_With_result(): rt_object = RTApiMock() rt_object.set_return([ u'id: ticket/887677', u'owner: [email protected]', u'subject: create rt dashboard', u'status: open', u'priority: 26', u'cf.{servico}: csc-gsiic', u'cf.{is - informatica e sistemas}: dir-inbox', u'lastupdated: wed jul 15 21:16:50 2015', ]) result = search_tickets(rt_object, '*****@*****.**') assert result == { 'tickets': { '07/15': [ { u'status': u'open', u'priority': u'26', u'lastupdated': u'wed jul 15 21:16:50 2015', 'auxiliary_date': '07/15', u'owner': u'*****@*****.**', u'cf.{is - informatica e sistemas}': u'dir-inbox', 'id': u'887677', u'cf.{servico}': u'csc-gsiic', u'subject': u'create rt dashboard' } ] }, 'no_result': False, 'number_tickets': 1, 'email_limit': { 'new': 7, 'open': 1, 'rejected': 7 } }
def search(): start_time = time() result = create_default_result() result2 = create_default_result() result3 = create_default_result() if request.query.o == '' or not user_auth.check_id(request.query.o): result.update({'message': ''}) return template('auth', result) search = request.forms.get('search') result2.update( user_tickets_details( user_auth.get_rt_object_from_email( user_auth.get_email_from_id(request.query.o)), "inbox")) result.update( search_tickets( user_auth.get_rt_object_from_email( user_auth.get_email_from_id(request.query.o)), search)) result3.update( user_tickets_details( user_auth.get_rt_object_from_email( user_auth.get_email_from_id(request.query.o)), user_auth.get_email_from_id(request.query.o))) # Is there any URGENT ticket? result3.update({'urgent': get_urgent_tickets(rt_object)}) result3.update({'summary': get_summary_info()}) result3.update({'time_spent': '%0.2f seconds' % (time() - start_time)}) result.update({'username': user_auth.get_email_from_id(request.query.o)}) result.update({'email': search}) result.update({'username_id': request.query.o}) result.update({'summary': get_summary_info()}) result2.update({'urgent': get_urgent_tickets(rt_object)}) result2.update({'summary': get_summary_info()}) result2.update({'time_spent': '%0.2f seconds' % (time() - start_time)}) result.update({'urgent': get_urgent_tickets(rt_object)}) result.update({'time_spent': '%0.2f seconds' % (time() - start_time)}) #Vamos buscar os campos de Tickets de um determinado utilizador e fazemos merge res2 = result2['tickets'] res3 = result3['tickets'] allTickets = res2.copy() res2.clear() lst2 = filterTicketStatus(res3) lst = refineTicketSearch(allTickets, lst2, search) ticketsDic = dict() ticketsDic['tickets'] = lst return template('search', result, tickets2=ticketsDic)