def donate_direct(request): make_donation = None teacher_donation = None c = Context(dict( page_title='Donator', donate=True, reply_to=settings.EMAIL_HOST_USER, )) if request.POST: make_donation = request.POST.get('make_donation') teacher_donation = request.POST.get('teacher_donation') form = DonationForm(request.POST) if form.is_valid(): teacher = Teacher.objects.get(pk=request.POST.get('student_teacher_id')) first_name = request.POST.get('student_first_name').strip() last_name = request.POST.get('student_last_name').strip() per_lap = request.POST.get('per_lap') identifier = '{0}-{1}-{2}'.format(replace_space(first_name), replace_space(last_name), teacher.room_number) try: student = Student.objects.get(identifier=identifier) except Exception, e: student = Student( first_name=first_name, last_name=last_name, date_added=date.datetime.now(pytz.utc), identifier=identifier, teacher=teacher, ) student.save() try: donation = Donation.objects.create( first_name=request.POST.get('first_name'), last_name=request.POST.get('last_name'), email_address=request.POST.get('email_address'), phone_number=request.POST.get('phone_number'), per_lap=per_lap and int(per_lap) or 0, donation=request.POST.get('donation'), date_added=date.datetime.now(pytz.utc), student=student, ) messages.success(request, 'Thank you for making a pledge to {0}'.format(teacher_donation and donation.first_name or student.full_name())) # add to cart add_to_cart(request, 'donation', donation.id, 1) # update totals donation.calculate_totals(donation.id) # calculate_totals_signal.send(sender=None, donation=donation) c['success'] = True c['donate_url'] = student.donate_url() c['student_full_name'] = student.full_name() c['student_identifier'] = student.identifier c['amount'] = donation.donation c['full_name'] = donation.full_name() c['is_per_lap'] = donation.per_lap c['payment_url'] = donation.payment_url() c['email_address'] = donation.email_address c['subject'] = 'Hicks Canyon Jog-A-Thon: Thank you for making a Pledge' c['domain'] = Site.objects.get_current().domain if not teacher_donation: _send_email_teamplate('donate', c) except Exception, e: messages.error(request, str(e))
def donate_direct(request): make_donation = None teacher_donation = None c = Context(dict(page_title="Donator", donate=True, reply_to=settings.EMAIL_HOST_USER)) if request.POST: make_donation = request.POST.get("make_donation") teacher_donation = request.POST.get("teacher_donation") form = DonationForm(request.POST) if form.is_valid(): teacher = Teacher.objects.get(pk=request.POST.get("student_teacher_id")) first_name = request.POST.get("student_first_name").strip() last_name = request.POST.get("student_last_name").strip() per_lap = request.POST.get("per_lap") identifier = "{0}-{1}-{2}".format(replace_space(first_name), replace_space(last_name), teacher.room_number) try: student = Student.objects.get(identifier=identifier) except Exception, e: student = Student( first_name=first_name, last_name=last_name, date_added=date.datetime.now(pytz.utc), identifier=identifier, teacher=teacher, ) student.save() try: donation = Donation.objects.create( first_name=request.POST.get("first_name"), last_name=request.POST.get("last_name"), email_address=request.POST.get("email_address"), phone_number=request.POST.get("phone_number"), per_lap=per_lap and int(per_lap) or 0, donation=request.POST.get("donation"), date_added=date.datetime.now(pytz.utc), student=student, ) messages.success( request, "Thank you for making a pledge to {0}".format( teacher_donation and donation.first_name or student.full_name() ), ) # add to cart add_to_cart(request, "donation", donation.id, 1) # update totals donation.calculate_totals(donation.id) # calculate_totals_signal.send(sender=None, donation=donation) c["success"] = True c["donate_url"] = student.donate_url() c["student_full_name"] = student.full_name() c["student_identifier"] = student.identifier c["amount"] = donation.donation c["full_name"] = donation.full_name() c["is_per_lap"] = donation.per_lap c["payment_url"] = donation.payment_url() c["email_address"] = donation.email_address c["subject"] = "Hicks Canyon Jog-A-Thon: Thank you for making a Pledge" c["domain"] = Site.objects.get_current().domain if not teacher_donation: _send_email_teamplate("donate", c) except Exception, e: messages.error(request, str(e))
def donate(request, identifier=None): student = Student.objects.get(identifier=identifier) make_donation = None teacher_donation = None c = Context(dict( page_title='Donate', teachers_donate=Teacher().get_donate_list(), student=student, has_error=False, donate=True, reply_to=settings.EMAIL_HOST_USER, )) if request.POST: make_donation = request.POST.get('make_donation') teacher_donation = request.POST.get('teacher_donation') per_lap = request.POST.get('per_lap') form = DonationForm(request.POST) if form.is_valid(): try: donation = Donation.objects.create( first_name=request.POST.get('first_name'), last_name=request.POST.get('last_name'), email_address=request.POST.get('email_address'), phone_number=request.POST.get('phone_number'), donation=float(request.POST.get('donation')), per_lap=per_lap and int(per_lap) or 0, date_added=date.datetime.now(pytz.utc), type=0, student=student, ) if teacher_donation: donation.type = donation.first_name == 'Mrs. Agopian' and 2 or 1 messages.success(request, 'Thank you for making a pledge to {0}'.format(teacher_donation and donation.first_name or student.full_name())) # add to cart add_to_cart(request, 'donation', donation.id, 1) # update totals donation.calculate_totals(donation.id) # calculate_totals_signal.send(sender=None, donation=donation) c['success'] = True c['donate_url'] = student.donate_url() c['student_full_name'] = student.full_name() c['student_identifier'] = student.identifier c['amount'] = donation.donation c['full_name'] = donation.full_name() c['is_per_lap'] = donation.per_lap c['payment_url'] = donation.payment_url() c['email_address'] = donation.email_address c['paypal_ipn_url'] = settings.PAYPAL_IPN_URL # c['encrypted_block'] = donation.encrypted_block() c['subject'] = 'Hicks Canyon Jog-A-Thon: Thank you for making a Pledge' c['domain'] = Site.objects.get_current().domain if not teacher_donation: _send_email_teamplate('donate', c) except Exception, e: c['make_donation'] = make_donation or False c['has_error'] = True messages.error(request, str(e)) else: c['make_donation'] = make_donation or False c['has_error'] = True messages.error(request, 'Failed to Add {0}'.format(teacher_donation and 'Donation' or 'Sponsor')) c['form'] = form
def donate(request, identifier=None): student = Student.objects.get(identifier=identifier) make_donation = None teacher_donation = None c = Context( dict( page_title="Donate", teachers_donate=Teacher().get_donate_list(), student=student, has_error=False, donate=True, reply_to=settings.EMAIL_HOST_USER, ) ) if request.POST: make_donation = request.POST.get("make_donation") teacher_donation = request.POST.get("teacher_donation") per_lap = request.POST.get("per_lap") form = DonationForm(request.POST) if form.is_valid(): try: donation = Donation.objects.create( first_name=request.POST.get("first_name"), last_name=request.POST.get("last_name"), email_address=request.POST.get("email_address"), phone_number=request.POST.get("phone_number"), donation=float(request.POST.get("donation")), per_lap=per_lap and int(per_lap) or 0, date_added=date.datetime.now(pytz.utc), type=0, student=student, ) if teacher_donation: donation.type = donation.first_name == "Mrs. Agopian" and 2 or 1 messages.success( request, "Thank you for making a pledge to {0}".format( teacher_donation and donation.first_name or student.full_name() ), ) # add to cart add_to_cart(request, "donation", donation.id, 1) # update totals donation.calculate_totals(donation.id) # calculate_totals_signal.send(sender=None, donation=donation) c["success"] = True c["donate_url"] = student.donate_url() c["student_full_name"] = student.full_name() c["student_identifier"] = student.identifier c["amount"] = donation.donation c["full_name"] = donation.full_name() c["is_per_lap"] = donation.per_lap c["payment_url"] = donation.payment_url() c["email_address"] = donation.email_address c["paypal_ipn_url"] = settings.PAYPAL_IPN_URL # c['encrypted_block'] = donation.encrypted_block() c["subject"] = "Hicks Canyon Jog-A-Thon: Thank you for making a Pledge" c["domain"] = Site.objects.get_current().domain if not teacher_donation: _send_email_teamplate("donate", c) except Exception, e: c["make_donation"] = make_donation or False c["has_error"] = True messages.error(request, str(e)) else: c["make_donation"] = make_donation or False c["has_error"] = True messages.error(request, "Failed to Add {0}".format(teacher_donation and "Donation" or "Sponsor")) c["form"] = form