def SignIn(request): if request.method == "GET": return render(request, 'common/signin.html.j2', context={ "title": "Healthprovider Login", "route": "/healthprovider", "color": "primary" }) elif request.method == "POST": if signin("healthprovider", request): return redirect('healthprovider:dashboard_home') return redirect('healthprovider:signin')
def branch_new(request): ''' route for branch - new ''' p = Provider.objects.filter(poc__email=request.session['email']).first() class BranchForm(forms.ModelForm): class Meta: model = Provider fields = ( 'name', 'type', ) if request.method == "POST": new_branch = BranchForm(request.POST, request.FILES) if new_branch.is_valid(): branch = new_branch.save(commit=False) branch.is_branch = True branch.parent_provider = p branch.poc = p.poc branch.save() return redirect("healthprovider:branch_view") return render(request, 'healthprovider/dashboard/branch/new.html.j2', context={ 'title': "branch - new", })
def cancel_appointment(request, id): p = get_provider(request.session['email']) a = Appointment.objects.filter(id=id).first() if a.provider == p: a.status = 'cancelled' a.save() else: # add appropriate error handling print("*** Authorization failed ***") return JsonResponse({'status': 'Auth Error'}) return redirect('healthprovider:appointment_daily')
def otp(request): if request.method == "POST": if (int(request.POST['otp']) == int(request.session['otp'])): request.POST = request.session['userdata'] uform = UserForm(request.POST) prform = ProviderregForm(request.POST) prpost = prform.save(commit=False) upost = uform.save(commit=False) upost.role = "healthprovider" upost.password = make_password(request.POST['password']) upost.save() prpost.poc = User.objects.get(pk=upost.pk) prpost.save() return redirect('healthprovider:signin') else: return render(request, 'healthseeker/registration/otp.html', {'error': "Invalid Otp"}) else: return render(request, 'healthseeker/registration/otp.html', {})
def SignUp(request): if request.method == 'POST': uform = UserForm(request.POST) if uform.is_valid(): #otp here mobile = request.POST['mobile'] mutable = request.POST._mutable request.POST._mutable = True request.POST['username'] = request.POST['email'] request.POST._mutable = mutable request.session['userdata'] = request.POST otp = randint(1, 99999) request.session['otp'] = otp base_url = "http://api.msg91.com/api/sendhttp.php" params = { 'sender': "CLICKH", 'route': 4, 'country': 91, 'mobiles': [mobile], 'authkey': '182461AjomJGPHB5a0041cb', 'message': "Verification OTP : %d" % otp } r = requests.get(base_url, params=params) return redirect('healthprovider:otp') else: uform = UserForm() prform = ProviderregForm() return render(request, 'healthprovider/registration.html.j2', context={ "uform": uform, "prform": prform, })