--- a/project/scipycon/registration/forms.py Tue Nov 30 18:34:12 2010 +0530
+++ b/project/scipycon/registration/forms.py Tue Nov 30 18:34:59 2010 +0530
@@ -94,12 +94,27 @@
sex = self.cleaned_data['sex']
accommodation_required = self.cleaned_data['accommodation_required']
- accommodation_days = self.cleaned_data['accommodation_days']
+
+ a1 = self.cleaned_data['accommodation_on_1st']
+ a2 = self.cleaned_data['accommodation_on_2nd']
+ a3 = self.cleaned_data['accommodation_on_3rd']
+ a4 = self.cleaned_data['accommodation_on_4th']
+ a5 = self.cleaned_data['accommodation_on_5th']
+ a6 = self.cleaned_data['accommodation_on_6th']
+
+ accommodation_days = [a1, a2, a3, a4, a5, a6].count(True)
acco.sex = sex
acco.accommodation_required = accommodation_required
- acco.accommodation_days = accommodation_days if (
- accommodation_days) else 0
+ acco.accommodation_days = accommodation_days
+
+ acco.accommodation_on_1st = a1
+ acco.accommodation_on_2nd = a2
+ acco.accommodation_on_3rd = a3
+ acco.accommodation_on_4th = a4
+ acco.accommodation_on_5th = a5
+ acco.accommodation_on_6th = a6
+
acco.save()
@@ -114,19 +129,35 @@
sex = self.cleaned_data['sex']
accommodation_required = self.cleaned_data['accommodation_required']
- accommodation_days = self.cleaned_data['accommodation_days']
+
+ a1 = self.cleaned_data['accommodation_on_1st']
+ a2 = self.cleaned_data['accommodation_on_2nd']
+ a3 = self.cleaned_data['accommodation_on_3rd']
+ a4 = self.cleaned_data['accommodation_on_4th']
+ a5 = self.cleaned_data['accommodation_on_5th']
+ a6 = self.cleaned_data['accommodation_on_6th']
- if accommodation_required and (not sex or not accommodation_days
- or accommodation_days == 0):
+ selected_a_date = any([a1, a2, a3, a4, a5, a6])
+
+ if accommodation_required and (not sex or not selected_a_date):
+ #or accommodation_days == 0):
raise forms.ValidationError(
- u"If accommodation is required both gender and number of "
- "days for which accommodation is required is mandatory.")
+ u"If accommodation is required please specify gender and"
+ " select the days number for which accommodation is required.")
return super(AccommodationForm, self).clean()
class Meta:
model = Accommodation
- fields = ('accommodation_required', 'sex', 'accommodation_days')
+ fields = ('accommodation_required',
+ 'sex',
+ 'accommodation_on_1st',
+ 'accommodation_on_2nd',
+ 'accommodation_on_3rd',
+ 'accommodation_on_4th',
+ 'accommodation_on_5th',
+ 'accommodation_on_6th',
+ )
class PaymentForm(forms.ModelForm):
--- a/project/scipycon/registration/models.py Tue Nov 30 18:34:12 2010 +0530
+++ b/project/scipycon/registration/models.py Tue Nov 30 18:34:59 2010 +0530
@@ -73,6 +73,19 @@
verbose_name="Accommodation required",
help_text="Check if you need accommodation.")
+ accommodation_on_1st = models.BooleanField(
+ default=False, verbose_name="Required for 12th Night")
+ accommodation_on_2nd = models.BooleanField(
+ default=False, verbose_name="Required for 13th Night")
+ accommodation_on_3rd = models.BooleanField(
+ default=False, verbose_name="Required for 14th Night")
+ accommodation_on_4th = models.BooleanField(
+ default=False, verbose_name="Required for 15th Night")
+ accommodation_on_5th = models.BooleanField(
+ default=False, verbose_name="Required for 16th Night")
+ accommodation_on_6th = models.BooleanField(
+ default=False, verbose_name="Required for 17th Night")
+
accommodation_days = models.IntegerField(
default=0, blank=True,
verbose_name="Number of days",
--- a/project/scipycon/registration/views.py Tue Nov 30 18:34:12 2010 +0530
+++ b/project/scipycon/registration/views.py Tue Nov 30 18:34:59 2010 +0530
@@ -139,7 +139,12 @@
'scope': acco.scope,
'sex': acco.sex,
'accommodation_required': acco.accommodation_required,
- 'accommodation_days': acco.accommodation_days,
+ 'accommodation_on_1st': acco.accommodation_on_1st,
+ 'accommodation_on_2nd': acco.accommodation_on_2nd,
+ 'accommodation_on_3rd': acco.accommodation_on_3rd,
+ 'accommodation_on_4th': acco.accommodation_on_4th,
+ 'accommodation_on_5th': acco.accommodation_on_5th,
+ 'accommodation_on_6th': acco.accommodation_on_6th,
})
payment_form = PaymentForm(initial={
'user': payment.user,
--- a/project/templates/registration/submit-registration.html Tue Nov 30 18:34:12 2010 +0530
+++ b/project/templates/registration/submit-registration.html Tue Nov 30 18:34:59 2010 +0530
@@ -7,16 +7,32 @@
$(document).ready(function(){
if (!$('#id_accommodation_required').is(':checked')) {
- $('#id_accommodation_days').attr('disabled', 'disabled');
$('#id_sex').attr('disabled', 'disabled');
+ $('#id_accommodation_on_1st').attr('disabled', 'disabled');
+ $('#id_accommodation_on_2nd').attr('disabled', 'disabled');
+ $('#id_accommodation_on_3rd').attr('disabled', 'disabled');
+ $('#id_accommodation_on_4th').attr('disabled', 'disabled');
+ $('#id_accommodation_on_5th').attr('disabled', 'disabled');
+ $('#id_accommodation_on_6th').attr('disabled', 'disabled');
}
$('#id_accommodation_required').change(function() {
if (!$('#id_accommodation_required').is(':checked')) {
- $('#id_accommodation_days').attr('disabled', 'disabled');
$('#id_sex').attr('disabled', 'disabled');
+ $('#id_accommodation_on_1st').attr('disabled', 'disabled');
+ $('#id_accommodation_on_2nd').attr('disabled', 'disabled');
+ $('#id_accommodation_on_3rd').attr('disabled', 'disabled');
+ $('#id_accommodation_on_4th').attr('disabled', 'disabled');
+ $('#id_accommodation_on_5th').attr('disabled', 'disabled');
+ $('#id_accommodation_on_6th').attr('disabled', 'disabled');
} else {
- $('#id_accommodation_days').removeAttr('disabled');
- $('#id_sex').removeAttr('disabled');
+ $('#id_accommodation_days').removeAttr('disabled');
+ $('#id_sex').removeAttr('disabled');
+ $('#id_accommodation_on_1st').removeAttr('disabled', 'disabled');
+ $('#id_accommodation_on_2nd').removeAttr('disabled', 'disabled');
+ $('#id_accommodation_on_3rd').removeAttr('disabled', 'disabled');
+ $('#id_accommodation_on_4th').removeAttr('disabled', 'disabled');
+ $('#id_accommodation_on_5th').removeAttr('disabled', 'disabled');
+ $('#id_accommodation_on_6th').removeAttr('disabled', 'disabled');
}
});