def matching_phones(request): center_id = request.GET.get('center_id') if not center_id or not is_center_id_valid(center_id): return get_bogus_arg_error(request) # user bypassed form validation matches = StaffPhone.objects.filter( registration_center__center_id=center_id) if not matches.exists(): if not RegistrationCenter.objects.filter(center_id=center_id).exists(): return get_invalid_center_error(request, center_id) else: return get_no_matching_phones_error(request) for phone in matches: try: phone.whitelist = Whitelist.objects.get( phone_number=phone.phone_number) except Whitelist.DoesNotExist: pass return render( request, 'vr_dashboard/phone_tool/phone_list.html', { 'phone_tool_page': True, 'staff_page': True, 'phones': matches, 'center_id': center_id, })
def whitelist_phone(request): phone_number = request.POST.get('phone') if not phone_number or not is_phone_number_valid(phone_number): return get_bogus_arg_error(request) # user bypassed form validation center_id = request.POST.get('center_id') if center_id: if not is_center_id_valid(center_id): return get_bogus_arg_error( request) # user bypassed form validation white_list = Whitelist(creation_date=now(), modification_date=now(), phone_number=phone_number) white_list.full_clean() white_list.save() # refresh the page that sent us here, now with the phone white-listed if center_id: query_args = '?center_id=%s' % center_id return HttpResponseRedirect( reverse('vr_dashboard:search-phones') + query_args) else: query_args = '?phone=%s' % phone_number return HttpResponseRedirect( reverse('vr_dashboard:phone-history') + query_args)
def whitelist_phone(request): phone_number = request.POST.get('phone') if not phone_number or not is_phone_number_valid(phone_number): return get_bogus_arg_error(request) # user bypassed form validation center_id = request.POST.get('center_id') if center_id: if not is_center_id_valid(center_id): return get_bogus_arg_error(request) # user bypassed form validation white_list = Whitelist(creation_date=now(), modification_date=now(), phone_number=phone_number) white_list.full_clean() white_list.save() # refresh the page that sent us here, now with the phone white-listed if center_id: query_args = '?center_id=%s' % center_id return HttpResponseRedirect(reverse('vr_dashboard:search-phones') + query_args) else: query_args = '?phone=%s' % phone_number return HttpResponseRedirect(reverse('vr_dashboard:phone-history') + query_args)
def matching_phones(request): center_id = request.GET.get('center_id') if not center_id or not is_center_id_valid(center_id): return get_bogus_arg_error(request) # user bypassed form validation matches = StaffPhone.objects.filter(registration_center__center_id=center_id) if not matches.exists(): if not RegistrationCenter.objects.filter(center_id=center_id).exists(): return get_invalid_center_error(request, center_id) else: return get_no_matching_phones_error(request) for phone in matches: try: phone.whitelist = Whitelist.objects.get(phone_number=phone.phone_number) except Whitelist.DoesNotExist: pass return render(request, 'vr_dashboard/phone_tool/phone_list.html', { 'phone_tool_page': True, 'staff_page': True, 'phones': matches, 'center_id': center_id, })