示例#1
0
 def parse_installers(cls, auth):
     login = NewDesign(auth['login'], auth['operator'], auth['password'])
     tickets = login.retrive_tickets()
     sw_tickets, sw_today = login.switched_tickets(tickets)
     for ticket in sw_tickets:
         info_data = login.ticket_info(ticket.id)
         name, phone = cls.find_installer_in_text(info_data.comments)
         try:
             installer, created = cls.objects.update_or_create(full_name=name)
             if not created:
                 installer.number = phone
                 installer.save()
             else:
                 cls(full_name=name, number=phone).save()
         except:
             continue
示例#2
0
def update_date_for_assigned():
    auth = NewDesign(os.getenv('SELL_CODE'), os.getenv('S_OPERATOR'),
                     os.getenv('S_PASS'))
    AssignedTickets = apps.get_model(app_label='tickets_handler',
                                     model_name='AssignedTickets')
    db_tickets = AssignedTickets.objects.filter(when_assigned=None)
    ticket_with_id = ''
    for ticket in db_tickets:
        supervisors_tickets = cache.get('supervisors_tickets')
        for sp_ticket in supervisors_tickets['all_tickets']:
            if hasattr(
                    sp_ticket.ticket_paired_info, 'number'
            ) and sp_ticket.ticket_paired_info.number == ticket.ticket_number:
                ticket_with_id = sp_ticket
        if not ticket_with_id:
            continue
        ticket_info = auth.ticket_info(ticket_with_id.ticket_paired_info.id)
        ticket.when_assigned = dmYHM_to_datetime(
            ticket_info.assigned_date) if ticket_info.assigned_date else None
        ticket.save()
示例#3
0
def ticket_info_json(request, id):
    auth = NewDesign(os.getenv('SELL_CODE'), request.session['operator'],
                     request.session['password'])
    ticket = auth.ticket_info(id).__dict__
    return JsonResponse(ticket, safe=False)