--- a/project/scipycon/registration/views.py Mon Nov 15 15:00:35 2010 +0530
+++ b/project/scipycon/registration/views.py Mon Nov 15 15:10:08 2010 +0530
@@ -12,8 +12,10 @@
from project.scipycon.registration.forms import RegistrationEditForm
from project.scipycon.registration.forms import RegistrationSubmitForm
from project.scipycon.registration.forms import AccommodationForm
+from project.scipycon.registration.forms import PaymentForm
from project.scipycon.registration.forms import WifiForm
from project.scipycon.registration.models import Accommodation
+from project.scipycon.registration.models import Payment
from project.scipycon.registration.models import Registration
from project.scipycon.registration.models import Wifi
from project.scipycon.registration.utils import send_confirmation
@@ -59,11 +61,13 @@
reg = Registration.objects.get(pk=id)
wifi = Wifi.objects.get(user=reg.registrant)
- # TODO: This is an ugly hack to add accommodation form
- # details at later stage for SciPy.in 2010. This must be
- # removed for SciPy.in 2011
+ # TODO: This is an ugly hack to add accommodation and payment forms
+ # details at later stage for SciPy.in 2010. This must be removed for
+ # SciPy.in 2011
acco, acco_created = Accommodation.objects.get_or_create(
user=reg.registrant, scope=scope_entity)
+ payment, payment_created = Payment.objects.get_or_create(
+ user=reg.registrant, scope=scope_entity)
if reg.registrant != request.user:
redirect_to = reverse('scipycon_account', kwargs={'scope': scope})
@@ -77,9 +81,10 @@
registration_form = RegistrationEditForm(data=request.POST)
wifi_form = WifiForm(data=request.POST)
acco_form = AccommodationForm(data=request.POST)
+ payment_form = PaymentForm(data=request.POST)
if (registration_form.is_valid() and wifi_form.is_valid() and
- acco_form.is_valid()):
+ acco_form.is_valid() and payment_form.is_valid()):
reg.organisation = registration_form.data.get('organisation')
reg.occupation = registration_form.data.get('occupation')
reg.city = registration_form.data.get('city')
@@ -98,6 +103,7 @@
wifi = wifi_form.save(reg.registrant, reg.scope)
acco = acco_form.save(reg.registrant, reg.scope)
+ payment = payment_form.save(reg.registrant, reg.scope)
# Saved.. redirect
redirect_to = reverse('scipycon_account', kwargs={'scope': scope})
@@ -130,6 +136,13 @@
'accommodation_required': acco.accommodation_required,
'accommodation_days': acco.accommodation_days,
})
+ payment_form = PaymentForm(initial={
+ 'user': payment.user,
+ 'scope': payment.scope,
+ 'paid': payment.paid,
+ 'type': payment.type,
+ 'details': payment.details,
+ })
return render_to_response(
template_name, RequestContext(request, {
@@ -137,7 +150,8 @@
'registration': {'id': id},
'registration_form': registration_form,
'wifi_form': wifi_form,
- 'acco_form': acco_form}))
+ 'acco_form': acco_form,
+ 'payment_form': payment_form}))
def submit_registration(request, scope,
template_name='registration/submit-registration.html'):
@@ -175,6 +189,7 @@
registrant_form = RegistrantForm(data=request.POST)
wifi_form = WifiForm(data=request.POST)
acco_form = AccommodationForm(data=request.POST)
+ payment_form = PaymentForm(data=request.POST)
if request.POST.get('action', None) == 'login':
login_form = AuthenticationForm(data=request.POST)
@@ -210,7 +225,7 @@
newuser = user
if (registration_form.is_valid() and newuser and wifi_form.is_valid()
- and acco_form.is_valid()):
+ and acco_form.is_valid() and payment_form.is_valid()):
allow_contact = registration_form.cleaned_data.get(
'allow_contact') and True or False
conference = registration_form.cleaned_data.get(
@@ -246,6 +261,7 @@
wifi = wifi_form.save(registrant, scope_entity)
acco = acco_form.save(registrant, scope_entity)
+ payment = payment_form.save(registrant, scope_entity)
send_confirmation(registrant, scope_entity,password=passwd)
@@ -260,6 +276,7 @@
registrant_form = RegistrantForm()
wifi_form = WifiForm()
acco_form = AccommodationForm()
+ payment_form = PaymentForm()
login_form = AuthenticationForm()
@@ -270,6 +287,7 @@
'registrant_form' : registrant_form,
'over_reg' : reg_count >= REG_TOTAL and True or False,
'acco_form': acco_form,
+ 'payment_form': payment_form,
'wifi_form' : wifi_form,
'message' : message,
'login_form' : login_form