示例#1
0
def get_switched_tickets(request):
    if request.method == "POST":
        params = unquote(request.POST.urlencode()).split('&')
        data = {
            param.split('=')[0]: param.split('=')[1]
            for param in params if param
        }
        auth = NewDesign(os.getenv('SELL_CODE'), data['operator'],
                         data['password'])
        tickets = auth.retrive_tickets()
        switched, count = auth.switched_tickets(tickets)
        t = jsonpickle.encode(switched)
        return JsonResponse({'tickets': t, 'count': count}, safe=False)
示例#2
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