def payment_redirect(request): referrer_url = "" notes = "" if request.method == 'POST': # If the form has been submitted... form = PaymentTempForm(request.POST) # A form bound to the POST data referrer_url = form.data['referrer_url'] notes = form.data['flex_field'] if form.is_valid(): # All validation rules passes # Process the data in form.cleaned_data amount = form.cleaned_data['amount'] email_address = form.cleaned_data['email_address'] email_receipt = form.cleaned_data['email_receipt'] pan_card = form.cleaned_data['pan_card'] if referrer_url == '/applicants' and notes <> "": notes = "Internship Sponroship for " + notes print "Creating PaymentTemp" pt = PaymentTemp.objects.create(amount=amount, email_address=email_address, email_receipt=email_receipt, pan_card=pan_card) transaction_id = pt.id if settings.ENV == "stage": transaction_id = "stage" + str(pt.id) callback_url = "http://www.thelakshyafoundation.org/accounts/payment-return" context = {"payment_dict" : get_post_object(callback_url, amount, email_address, transaction_id, notes)} return render_to_response("payment_redirect.html", RequestContext(request, context)) else: form = PaymentTempForm() # An unbound form if referrer_url == '/applicants': return render(request, 'research_facilitator_applicants.html', { 'form': form, }) elif referrer_url == '/donate' or 'pledge' in referrer_url: return render(request, 'donate.html', { 'form': form, })
def payment_redirect(request): referrer_url = "" notes = "" if request.method == "POST": # If the form has been submitted... form = PaymentTempForm(request.POST) # A form bound to the POST data referrer_url = form.data["referrer_url"] notes = form.data["flex_field"] if form.is_valid(): # All validation rules passes # Process the data in form.cleaned_data amount = form.cleaned_data["amount"] email_address = form.cleaned_data["email_address"] email_receipt = form.cleaned_data["email_receipt"] if referrer_url == "/applicants" and notes <> "": notes = "Internship Sponroship for " + notes pt = PaymentTemp.objects.create(amount=amount, email_address=email_address, email_receipt=email_receipt) transaction_id = pt.id if settings.ENV == "stage": transaction_id = "stage" + str(pt.id) callback_url = "http://www.thelakshyafoundation.org/accounts/payment-return" context = {"payment_dict": get_post_object(callback_url, amount, email_address, transaction_id, notes)} return render_to_response("payment_redirect.html", RequestContext(request, context)) else: form = PaymentTempForm() # An unbound form if referrer_url == "/applicants": return render(request, "research_facilitator_applicants.html", {"form": form}) elif referrer_url == "/donate": return render(request, "donate.html", {"form": form})
def post(self, request, *args, **kwargs): form = PaymentTempForm(request.POST) referrer_url = form.data['referrer_url'] print referrer_url notes = form.data['flex_field'] if form.is_valid(): # All validation rules passes # Process the data in form.cleaned_data amount = form.cleaned_data['amount'] email_address = form.cleaned_data['email_address'] try: pt_id = int(form.data['pt_id']) pt = PaymentTemp.objects.get(id=pt_id) except ValueError: raise Http404 transaction_id = pt.id if settings.ENV == "stage": transaction_id = "stage" + str(pt.id) callback_url = "http://www.thelakshyafoundation.org/crowdfunding/payment-return" context = { "payment_dict": get_post_object(callback_url, amount, email_address, transaction_id, notes) } return render_to_response("payment_redirect.html", RequestContext(request, context))
def post(self, request, *args, **kwargs): form = PaymentTempForm(request.POST) referrer_url = form.data['referrer_url'] print referrer_url notes = form.data['flex_field'] if form.is_valid(): # All validation rules passes # Process the data in form.cleaned_data amount = form.cleaned_data['amount'] email_address = form.cleaned_data['email_address'] try: pt_id = int(form.data['pt_id']) pt = PaymentTemp.objects.get(id=pt_id) except ValueError: raise Http404 transaction_id = pt.id if settings.ENV == "stage": transaction_id = "stage" + str(pt.id) callback_url = "http://dev.thelakshyafoundation.org:8000/crowdfunding/payment-return" context = {"payment_dict": get_post_object(callback_url, amount, email_address, transaction_id, notes)} return render_to_response("payment_redirect.html", RequestContext(request, context))
def payment_redirect(request): referrer_url = "" notes = "" if request.method == 'POST': # If the form has been submitted... form = PaymentTempForm(request.POST) # A form bound to the POST data referrer_url = form.data['referrer_url'] notes = form.data['flex_field'] if form.is_valid(): # All validation rules passes # Process the data in form.cleaned_data amount = form.cleaned_data['amount'] email_address = form.cleaned_data['email_address'] email_receipt = form.cleaned_data['email_receipt'] pan_card = form.cleaned_data['pan_card'] if referrer_url == '/applicants' and notes <> "": notes = "Internship Sponroship for " + notes print "Creating PaymentTemp" pt = PaymentTemp.objects.create(amount=amount, email_address=email_address, email_receipt=email_receipt, pan_card=pan_card) transaction_id = pt.id if settings.ENV == "stage": transaction_id = "stage" + str(pt.id) callback_url = "http://www.thelakshyafoundation.org/accounts/payment-return" context = { "payment_dict": get_post_object(callback_url, amount, email_address, transaction_id, notes) } return render_to_response("payment_redirect.html", RequestContext(request, context)) else: form = PaymentTempForm() # An unbound form if referrer_url == '/applicants': return render(request, 'research_facilitator_applicants.html', { 'form': form, }) elif referrer_url == '/donate' or 'pledge' in referrer_url: return render(request, 'donate.html', { 'form': form, })
def donate_home(request): form = PaymentTempForm() form.fields['referrer_url'].initial = request.get_full_path() if '/applicants' in request.get_full_path(): return render(request, 'research_facilitator_applicants.html', {'form': form}) elif '/donate' in request.get_full_path(): testimonial_list = LakshyaTestimonial.objects.order_by('?')[:2] return render(request, 'donate.html', { 'form': form, 'testimonial_list': testimonial_list })
def get_context_data(self, **kwargs): context = super(FulfillPledgeView, self).get_context_data(**kwargs) try: context['pledge'] = pledge = Pledge.objects.get(id=pledge_id) project_id = pledge.project.id project = Project.objects.get(id=project_id) print "^&^&*************************^&%^&%^&" print project_id context['project'] = project except (Pledge.DoesNotExist, ValueError): raise Http404 payment_temp = PaymentTemp.objects.create( amount=pledge.amount, email_address=pledge.user.email, flex_field="Fulfillment of pledge " + str(pledge.id), referrer_url=self.request.get_full_path()) form = PaymentTempForm(instance=payment_temp) form.fields['referrer_url'].initial = self.request.get_full_path() context['form'] = form context['pt_id'] = payment_temp.id return context
def get_context_data(self, **kwargs): context = TemplateView.get_context_data(self, **kwargs) try: related_project_list = [] for related_project in Project.objects.exclude( id=kwargs.get('id')).order_by('?'): if not related_project.is_expired(): related_project_list.append(related_project) project = Project.objects.get(id=kwargs.get('id')) context['project'] = project # context['related_projects'] = Project.objects.exclude(id=kwargs.get('id').order_by('?'))[:3] context['related_projects'] = related_project_list[:3] context['pledges'] = Pledge.objects.filter( project=project).all().order_by('-pledge_fulfilled') context['total_pledge_fulfilled'] = Pledge.objects.filter( project=project, pledge_fulfilled=True).count() user = self.request.user if user.is_authenticated() and Pledge.objects.filter( project=project, user=user).exists(): # starts here context['user_pledge'] = pledge = Pledge.objects.filter( project=project, user=user).first() if project.is_expired(): # Below code is used if campaign expired and achieved its goal, to help user fulfill pledge payment_temp = PaymentTemp.objects.create( amount=pledge.amount, email_address=pledge.user.email, flex_field="Fulfillment of pledge " + str(pledge.id), referrer_url=self.request.get_full_path(), pledge_id=pledge.id) form = PaymentTempForm(instance=payment_temp) context['form'] = form context['pt_id'] = payment_temp.id # ends here except (Project.DoesNotExist, ValueError): raise Http404 return context