Added six fields corresponding to accomodation in the accomodation model and made corresponding changes to view and form
--- a/project/development.py Tue Nov 30 15:44:14 2010 +0530
+++ b/project/development.py Tue Nov 30 15:51:23 2010 +0530
@@ -24,7 +24,7 @@
'project.scipycon.talk',
'tagging',
'robots',
- 'south',
+ #'south',
)
DATABASE_ENGINE = 'sqlite3'
--- a/project/scipycon/registration/forms.py Tue Nov 30 15:44:14 2010 +0530
+++ b/project/scipycon/registration/forms.py Tue Nov 30 15:51:23 2010 +0530
@@ -94,12 +94,26 @@
sex = self.cleaned_data['sex']
accommodation_required = self.cleaned_data['accommodation_required']
- accommodation_days = self.cleaned_data['accommodation_days']
+ accommodation_days = sum(filter([a1, a2, a3, a4, a5, a6]))
+
+ a1 = self.cleaned_data['accomodation_on_1st']
+ a2 = self.cleaned_data['accomodation_on_2nd']
+ a3 = self.cleaned_data['accomodation_on_3rd']
+ a4 = self.cleaned_data['accomodation_on_4th']
+ a5 = self.cleaned_data['accomodation_on_5th']
+ a6 = self.cleaned_data['accomodation_on_6th']
acco.sex = sex
acco.accommodation_required = accommodation_required
- acco.accommodation_days = accommodation_days if (
- accommodation_days) else 0
+ acco.accommodation_days = accomodation_days
+
+ acco.accomodation_on_1st = a1
+ acco.accomodation_on_2nd = a2
+ acco.accomodation_on_3rd = a3
+ acco.accomodation_on_4th = a4
+ acco.accomodation_on_5th = a5
+ acco.accomodation_on_6th = a6
+
acco.save()
@@ -114,19 +128,35 @@
sex = self.cleaned_data['sex']
accommodation_required = self.cleaned_data['accommodation_required']
- accommodation_days = self.cleaned_data['accommodation_days']
+
+ a1 = self.cleaned_data['accomodation_on_1st']
+ a2 = self.cleaned_data['accomodation_on_2nd']
+ a3 = self.cleaned_data['accomodation_on_3rd']
+ a4 = self.cleaned_data['accomodation_on_4th']
+ a5 = self.cleaned_data['accomodation_on_5th']
+ a6 = self.cleaned_data['accomodation_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',
+ 'accomodation_on_1st',
+ 'accomodation_on_2nd',
+ 'accomodation_on_3rd',
+ 'accomodation_on_4th',
+ 'accomodation_on_5th',
+ 'accomodation_on_6th',
+ )
class PaymentForm(forms.ModelForm):
--- a/project/scipycon/registration/models.py Tue Nov 30 15:44:14 2010 +0530
+++ b/project/scipycon/registration/models.py Tue Nov 30 15:51:23 2010 +0530
@@ -73,6 +73,19 @@
verbose_name="Accommodation required",
help_text="Check if you need accommodation.")
+ accomodation_on_1st = models.BooleanField(default=False,
+ verbose_name="First day")
+ accomodation_on_2nd = models.BooleanField(default=False,
+ verbose_name="Second day")
+ accomodation_on_3rd = models.BooleanField(default=False,
+ verbose_name="Third day")
+ accomodation_on_4th = models.BooleanField(default=False,
+ verbose_name="Fourth day")
+ accomodation_on_5th = models.BooleanField(default=False,
+ verbose_name="Fifth day")
+ accomodation_on_6th = models.BooleanField(default=False,
+ verbose_name="Sixth day")
+
accommodation_days = models.IntegerField(
default=0, blank=True,
verbose_name="Number of days",
--- a/project/templates/registration/submit-registration.html Tue Nov 30 15:44:14 2010 +0530
+++ b/project/templates/registration/submit-registration.html Tue Nov 30 15:51:23 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_accomodation_on_1st').attr('disabled', 'disabled');
+ $('#id_accomodation_on_2nd').attr('disabled', 'disabled');
+ $('#id_accomodation_on_3rd').attr('disabled', 'disabled');
+ $('#id_accomodation_on_4th').attr('disabled', 'disabled');
+ $('#id_accomodation_on_5th').attr('disabled', 'disabled');
+ $('#id_accomodation_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_accomodation_on_1st').attr('disabled', 'disabled');
+ $('#id_accomodation_on_2nd').attr('disabled', 'disabled');
+ $('#id_accomodation_on_3rd').attr('disabled', 'disabled');
+ $('#id_accomodation_on_4th').attr('disabled', 'disabled');
+ $('#id_accomodation_on_5th').attr('disabled', 'disabled');
+ $('#id_accomodation_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_accomodation_on_1st').removeAttr('disabled', 'disabled');
+ $('#id_accomodation_on_2nd').removeAttr('disabled', 'disabled');
+ $('#id_accomodation_on_3rd').removeAttr('disabled', 'disabled');
+ $('#id_accomodation_on_4th').removeAttr('disabled', 'disabled');
+ $('#id_accomodation_on_5th').removeAttr('disabled', 'disabled');
+ $('#id_accomodation_on_6th').removeAttr('disabled', 'disabled');
}
});