예제 #1
0
def ticketAction2(ticket_id, action):

    start_time = time()

    result = create_default_result()
    result2 = create_default_result()

    if request.query.o == '' or not user_auth.check_id(request.query.o):
        result.update({'message': ''})
        return template('auth', result)

    # Apply the action to the ticket
    result.update(
        ticket_actions(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)), ticket_id,
            action, request.query.email,
            user_auth.get_email_from_id(request.query.o)))

    # Update table for this user
    result.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)),
            request.query.email))

    result2.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)), "inbox"))

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': request.query.email})
    result.update({'username_id': request.query.o})

    # 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)})

    result2.update({'urgent': get_urgent_tickets(rt_object)})

    result2.update({'summary': get_summary_info()})

    result2.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

    if request.query.email == 'inbox' or request.query.email == 'unknown':
        return template('ticket_list', result)
    else:
        return template('detail', result, tickets2=result2)
예제 #2
0
def archivedTickets():

    global emailGlobal
    email = emailGlobal

    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)

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': email})
    result.update({'username_id': request.query.o})

    result.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)), email))

    # 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)})

    result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

    return template('archive', result, tickets2=result)
예제 #3
0
파일: server.py 프로젝트: FranciscoMSM/ES
def email_detail(email):
    global emailGlobal
    emailGlobal = email

    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)

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': email})
    result.update({'username_id': request.query.o})

    result.update(user_tickets_details(
        user_auth.get_rt_object_from_email(
            user_auth.get_email_from_id(request.query.o)
        ), email))

    # Is there any URGENT ticket?
    result.update({'urgent': get_urgent_tickets(rt_object)})

    result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

    result.update({'summary:': get_summary_info()})
    if email == 'dir' or email == 'dir-inbox' or email == 'unknown' or not email:
        return template('ticket_list', result)
    else:
        return template('detail', result)
예제 #4
0
def test_user_tickets_details_unknown_email():
    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',
    ])
    test_config = DITICConfig()
    test_config.email_to_user = {
        '*****@*****.**': 'Vapi',
        '*****@*****.**': 'Alex',
    }
    with pytest.raises(ValueError) as value_error:
        user_tickets_details(rt_object, '*****@*****.**')
    assert 'Unknown email/user:' in str(value_error)
예제 #5
0
def test_user_tickets_details_unknown_email():
    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',
    ])
    test_config = DITICConfig()
    test_config.email_to_user = {
        '*****@*****.**': 'Vapi',
        '*****@*****.**': 'Alex',
    }
    with pytest.raises(ValueError) as value_error:
        user_tickets_details(rt_object, '*****@*****.**')
    assert 'Unknown email/user:' in str(value_error)
예제 #6
0
def test_user_tickets_details_known_email():
    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',
    ])
    result = user_tickets_details(rt_object, '*****@*****.**')
    assert result == {
        'email_limit':
            {
                'new': 7,
                'open': 1,
                'rejected': 7
            },
        'number_tickets_per_status':
            {
                u'open': 1
            },
        'tickets':
            {
                u'open':
                    {
                        u'26':
                            [
                                {
                                    u'cf.{is - informatica e sistemas}': u'dir-inbox',
                                    u'cf.{servico}': u'csc-gsiic',
                                    'id': u'887677',
                                    'kanban_actions':
                                        {
                                            'back': True,
                                            'decrease_priority': True,
                                            'forward': True,
                                            'increase_priority': True,
                                            'interrupted': True,
                                            'stalled': True
                                        },
                                    u'owner': u'*****@*****.**',
                                    u'priority': u'26',
                                    u'status': u'open',
                                    u'subject': u'create rt dashboard'
                                }
                            ]
                    }
            }
    }
예제 #7
0
def test_user_tickets_details_dir_inbox():
    rt_object = RTApiMock()
    rt_object.set_return([
                u'id: ticket/887677',
                u'owner: nobody',
                u'subject: create rt dashboard',
                u'status: open',
                u'priority: 26',
                u'cf.{servico}: csc-gsiic',
                u'cf.{is - informatica e sistemas}: dir-inbox',
    ])
    result = user_tickets_details(rt_object, 'dir-inbox')
    assert rt_object.data == {
        'query': 'Queue = "general" AND "CF.{IS - Informatica e Sistemas}" = "DIR-INBOX" '
                 'AND Owner = "Nobody"  AND Status != "resolved" AND Status != "deleted" ',
        'format': 'l'
    }
    assert result == {
        'tickets':
            {
                u'26':
                    [
                        {
                            u'status': u'open',
                            u'priority': u'26',
                            'kanban_actions':
                                {
                                    'increase_priority': True,
                                    'decrease_priority': True,
                                    'back': True,
                                    'interrupted': False,
                                    'stalled': False,
                                    'forward': False
                                },
                            u'owner': u'nobody',
                            u'cf.{is - informatica e sistemas}': u'dir-inbox',
                            u'id': u'887677',
                            u'cf.{servico}': u'csc-gsiic',
                            u'subject': u'create rt dashboard'
                        }
                    ]
            },
        'email_limit': {},
        'number_tickets_per_status':
            {
                'dir-inbox': 1
            }
    }
예제 #8
0
def test_user_tickets_details_unknown():
    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',
        ]
    )
    result = user_tickets_details(rt_object, 'unknown')
    assert 'Owner != "Nobody"' in rt_object.data['query']
    assert result == {
        'tickets':
            {
                u'26':
                    [
                        {
                            u'status': u'open',
                            u'priority': u'26',
                            'kanban_actions':
                                {
                                    'increase_priority': False,
                                    'decrease_priority': False,
                                    'back': False,
                                    'interrupted': False,
                                    'stalled': False,
                                    'forward': False
                                },
                            u'owner': u'*****@*****.**',
                            u'cf.{is - informatica e sistemas}': u'dir-inbox',
                            u'id': u'887677',
                            u'cf.{servico}': u'csc-gsiic',
                            u'subject': u'create rt dashboard'
                        }
                    ]
            },
        'email_limit': {},
        'number_tickets_per_status':
            {
                'unknown': 1
            }
    }
예제 #9
0
파일: server.py 프로젝트: tomascarvalho/ES
def ticket_action2(ticket_id, action):
	
	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)

	# Apply the action to the ticket
	result.update(ticket_actions(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		),
		ticket_id,
		action,
		request.query.email, user_auth.get_email_from_id(request.query.o)
	))

	# Update table for this user
	result.update(user_tickets_details(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		), request.query.email))

	result.update({'username': user_auth.get_email_from_id(request.query.o)})
	result.update({'email': request.query.email})
	result.update({'username_id': request.query.o})

	# Is there any URGENT ticket?
	result.update({'urgent': get_urgent_tickets(rt_object)})

	result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

	#update all

	if request.query.email == 'dir' or request.query.email == 'dir-inbox' or request.query.email == 'unknown':
		return template('ticket_list', result)

	elif request.query.email == 'history':
		return template('history', result)

	else:
		return template('detail', result)
예제 #10
0
def archive_ticket(ticket_id,action):
	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)

	# Apply the action to the ticket
	result.update(ticket_actions(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		),
		ticket_id,
		action,
		request.query.email, user_auth.get_email_from_id(request.query.o)
	))

	# Update table for this user
	result.update(user_tickets_details(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		), request.query.email))

	result.update({'username': user_auth.get_email_from_id(request.query.o)})
	result.update({'email': request.query.email})
	result.update({'username_id': request.query.o})

	# Is there any URGENT ticket?
	result.update({'urgent': get_urgent_tickets(rt_object)})

	result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})


	modify_ticket(
			rt_object,
			ticket_id,
			{
				'status': 'archived',
				
			}
		)

	return template('history', result)
예제 #11
0
파일: server.py 프로젝트: FranciscoMSM/ES
def archive_tickets_server(email):

    start_time = time()

    result = create_default_result()

    dictResultRes = user_get_resolved_tickets(rt_object, email)
    listTickets = getTicketsIds(dictResultRes)

    if request.query.o == '' or not user_auth.check_id(request.query.o):
        result.update({'message': ''})
        return template('auth', result)

    for i in range(len(listTickets)):
        # Apply the action to the ticket
        result.update(ticket_actions(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)
            ),
            listTickets[i],
            'forward',
            request.query.email, user_auth.get_email_from_id(request.query.o)
        ))

    # Update table for this user
    result.update(user_tickets_details(
        user_auth.get_rt_object_from_email(
            user_auth.get_email_from_id(request.query.o)
        ), request.query.email))

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': request.query.email})
    result.update({'username_id': request.query.o})

    # Is there any URGENT ticket?
    result.update({'urgent': get_urgent_tickets(rt_object)})

    result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})
    result.update({'summary:': get_summary_info()})

    os.system('update_statistics')
    os.system("generate_summary_file")

    return template('detail', result)
예제 #12
0
def test_user_tickets_details_dir_inbox():
    rt_object = RTApiMock()
    rt_object.set_return([
        u'id: ticket/887677',
        u'owner: nobody',
        u'subject: create rt dashboard',
        u'status: open',
        u'priority: 26',
        u'cf.{servico}: csc-gsiic',
        u'cf.{is - informatica e sistemas}: dir-inbox',
    ])
    result = user_tickets_details(rt_object, 'dir-inbox')
    assert rt_object.data == {
        'query':
        'Queue = "general" AND "CF.{IS - Informatica e Sistemas}" = "DIR-INBOX" '
        'AND Owner = "Nobody"  AND Status != "resolved" AND Status != "deleted" ',
        'format':
        'l'
    }
    assert result == {
        'tickets': {
            u'26': [{
                u'status': u'open',
                u'priority': u'26',
                'kanban_actions': {
                    'increase_priority': True,
                    'decrease_priority': True,
                    'back': True,
                    'interrupted': False,
                    'stalled': False,
                    'forward': False
                },
                u'owner': u'nobody',
                u'cf.{is - informatica e sistemas}': u'dir-inbox',
                u'id': u'887677',
                u'cf.{servico}': u'csc-gsiic',
                u'subject': u'create rt dashboard'
            }]
        },
        'email_limit': {},
        'number_tickets_per_status': {
            'dir-inbox': 1
        }
    }
예제 #13
0
def test_user_tickets_details_known_email():
    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',
    ])
    result = user_tickets_details(rt_object, '*****@*****.**')
    assert result == {
        'email_limit': {
            'new': 7,
            'open': 1,
            'rejected': 7
        },
        'number_tickets_per_status': {
            u'open': 1
        },
        'tickets': {
            u'open': {
                u'26': [{
                    u'cf.{is - informatica e sistemas}': u'dir-inbox',
                    u'cf.{servico}': u'csc-gsiic',
                    'id': u'887677',
                    'kanban_actions': {
                        'back': True,
                        'decrease_priority': True,
                        'forward': True,
                        'increase_priority': True,
                        'interrupted': True,
                        'stalled': True
                    },
                    u'owner': u'*****@*****.**',
                    u'priority': u'26',
                    u'status': u'open',
                    u'subject': u'create rt dashboard'
                }]
            }
        }
    }
예제 #14
0
def email_detail(email):
    global emailGlobal
    emailGlobal = email

    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)

    result.update({'username': user_auth.get_email_from_id(request.query.o)})
    result.update({'email': email})
    result.update({'username_id': request.query.o})

    result.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(
                user_auth.get_email_from_id(request.query.o)), email))

    # Is there any URGENT ticket?
    result.update({'urgent': get_urgent_tickets(rt_object)})

    result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})

    result.update({'summary:': get_summary_info()})

    result.update({'dir_inbox_limit': my_config.get_dir_inbox_limit()})

    if email == 'dir':
        print email
        return template('dir', result)
    elif email == 'dir-inbox':
        print email
        return template('dir-inbox', result)
    elif email == 'unknown' or not email:
        print email
        return template('ticket_list', result)
    else:
        print email
        return template('detail', result)
예제 #15
0
def test_user_tickets_details_unknown():
    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',
    ])
    result = user_tickets_details(rt_object, 'unknown')
    assert 'Owner != "Nobody"' in rt_object.data['query']
    assert result == {
        'tickets': {
            u'26': [{
                u'status': u'open',
                u'priority': u'26',
                'kanban_actions': {
                    'increase_priority': False,
                    'decrease_priority': False,
                    'back': False,
                    'interrupted': False,
                    'stalled': False,
                    'forward': False
                },
                u'owner': u'*****@*****.**',
                u'cf.{is - informatica e sistemas}': u'dir-inbox',
                u'id': u'887677',
                u'cf.{servico}': u'csc-gsiic',
                u'subject': u'create rt dashboard'
            }]
        },
        'email_limit': {},
        'number_tickets_per_status': {
            'unknown': 1
        }
    }
예제 #16
0
파일: server.py 프로젝트: brpv/Projeto
def ticket_action_2(ticket_id, action):
    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)

    # Apply the action to the ticket
    result.update(
        ticket_actions(
            user_auth.get_rt_object_from_email(user_auth.get_email_from_id(request.query.o)),
            ticket_id,
            action,
            request.query.email,
            user_auth.get_email_from_id(request.query.o),
        )
    )

    # Update table for this user
    result.update(
        user_tickets_details(
            user_auth.get_rt_object_from_email(user_auth.get_email_from_id(request.query.o)), request.query.email
        )
    )

    result.update({"username": user_auth.get_email_from_id(request.query.o)})
    result.update({"email": request.query.email})
    result.update({"username_id": request.query.o})

    # Is there any URGENT ticket?
    result.update({"urgent": get_urgent_tickets(rt_object)})

    result.update({"time_spent": "%0.2f seconds" % (time() - start_time)})
    if request.query.email == "dir" or request.query.email == "dir-inbox" or request.query.email == "unknown":
        return template("ticket_list", result)
    else:
        return template("detail", result)
예제 #17
0
def email_detail(email):
	start_time = time()
	global emailGlobal
	emailGlobal=email
	result = create_default_result()
	if request.query.o == '' or not user_auth.check_id(request.query.o):
		result.update({'message': ''})
		return template('auth', result)

	result.update({'username': user_auth.get_email_from_id(request.query.o)})
	result.update({'email': email})
	result.update({'username_id': request.query.o})
	
	result.update(user_tickets_details(
		user_auth.get_rt_object_from_email(
		    user_auth.get_email_from_id(request.query.o)
		), email))

	# Is there any URGENT ticket?
	result.update({'urgent': get_urgent_tickets(rt_object)})

	today = date.today().isoformat()
	result.update({'time_spent': '%0.2f seconds' % (time() - start_time)})
	result.update({'statistics': get_statistics(get_date(30, today), today)})

	if email == 'dir' or email == 'dir-inbox':
		return template('dir', result)
	elif email == 'history':
		return template('history', result)
	elif email == 'main' or email == 'unknown':
		return template('entrance_summary', result)
	elif email == 'new_ticket':
		return template('newticket', result)
	elif email == 'statistic':
		return template('statistic', result)
	else:
		return template('detail', result)
예제 #18
0
파일: server.py 프로젝트: brpv/Projeto
def email_detail(email):
    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)

    result.update({"username": user_auth.get_email_from_id(request.query.o)})
    result.update({"email": email})
    result.update({"username_id": request.query.o})

    result.update(
        user_tickets_details(user_auth.get_rt_object_from_email(user_auth.get_email_from_id(request.query.o)), email)
    )

    # Is there any URGENT ticket?
    result.update({"urgent": get_urgent_tickets(rt_object)})

    result.update({"time_spent": "%0.2f seconds" % (time() - start_time)})
    if email == "dir" or email == "dir-inbox" or email == "unknown":
        return template("ticket_list", result)
    else:
        return template("detail", result)
예제 #19
0
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)