project/scipycon/registration/forms.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Thu, 18 Nov 2010 15:02:40 +0530
branchsouth-migration
changeset 272 4801b7adbbc5
parent 199 97cbeda302a9
child 276 325ec5a41269
permissions -rw-r--r--
Add registration_id field to Wifi model and make necessary changes in the form.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
from django import forms
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
from django.core.exceptions import ObjectDoesNotExist
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
     4
from project.scipycon.registration.models import SIZE_CHOICES
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
     5
from project.scipycon.registration.models import OCCUPATION_CHOICES
199
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
     6
from project.scipycon.registration.models import Accommodation
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
     7
from project.scipycon.registration.models import Wifi
96
178b89a3ca4f Removed unwanted files and made more changes to make SciPyCon a clean app.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 94
diff changeset
     8
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
class RegistrationSubmitForm(forms.Form):
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    11
    """SciPyCon registration form
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
    """
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    13
    #tshirt = forms.ChoiceField(choices=SIZE_CHOICES, required=True,
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    14
    #    label=u'T-shirt size', help_text=u'Yes, we all get a t-shirt!')
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
    organisation = forms.CharField(required=True, label=u'Organisation',
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
        help_text=u'The primary organisation that you are a member of.',
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
        max_length=255,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
        widget=forms.TextInput(attrs={'size':'50'}))
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    19
    occupation = forms.ChoiceField(choices=OCCUPATION_CHOICES,
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    20
        required=True, label=u'Occupation',
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    21
        help_text=u'Title of your occupation')
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    22
    city = forms.CharField(required=False, label=u'City',
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    23
        help_text=u'Your city of residence',
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
        max_length=255,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
        widget=forms.TextInput(attrs={'size':'50'}))
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
    postcode = forms.CharField(required=False, label=u'Postcode',
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    27
        help_text=u'PIN Code of your area',
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
        max_length=10,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
        widget=forms.TextInput(attrs={'size':'10'}))
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    30
    phone_num = forms.CharField(required=False, label=u'Phone Number',
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    31
        help_text=u'Phone number. Although optional, please provide it for '
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    32
        'faster correspondence', max_length=14,
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    33
        widget=forms.TextInput(attrs={'size':'20'}))
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
    allow_contact = forms.BooleanField(required=False, label=u'Contact',
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
        help_text=u'May organizers of SciPy.in contact you after the event?')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
    conference = forms.BooleanField(required=False, label=u'Conference',
191
0eb941d14ec3 Changing the fee details in the registration form to the link.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 137
diff changeset
    37
        help_text=u"""Do you intend to attend SciPy.in 2010 conference?""")
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
    tutorial = forms.BooleanField(required=False, label=u'Tutorial',
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
        help_text=u'Do you intend to attend the tutorials?')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
    sprint = forms.BooleanField(required=False, label=u'Sprint',
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
        help_text=u'Do you intend to attend the sprints?')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    43
    def occupation_fields(self):
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
        return (self['organisation'],
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    45
                self['occupation'])
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    46
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    47
    def demographic_fields(self):
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    48
        return (self['city'],
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    49
                self['postcode'],
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    50
                self['phone_num'])
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
    def personal_fields(self):
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    53
        return (#self['tshirt'],
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
                self['conference'],
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    55
                self['tutorial'],
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    56
                self['sprint'],
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    57
                self['allow_contact'])
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    58
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    59
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    60
class RegistrationEditForm(RegistrationSubmitForm):
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    61
    id = forms.CharField(widget=forms.HiddenInput)
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    62
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    63
class WifiForm(forms.ModelForm):
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    64
    """PyCon wifi form
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    65
    """
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    66
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    67
    def save(self, user, scope):
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    68
        try:
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    69
            wifi = Wifi.objects.get(user=user, scope=scope)
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    70
        except ObjectDoesNotExist:
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    71
            wifi = Wifi(user=user, scope=scope)
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    72
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    73
        wifi.wifi = self.cleaned_data['wifi']
272
4801b7adbbc5 Add registration_id field to Wifi model and make necessary changes in the form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 199
diff changeset
    74
        wifi.registration_id = self.cleaned_data['registration_id']
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    75
        wifi.save()
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
    76
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    77
        return wifi
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    78
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    79
    class Meta:
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    80
        model = Wifi
272
4801b7adbbc5 Add registration_id field to Wifi model and make necessary changes in the form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 199
diff changeset
    81
        fields = ('wifi', 'registration_id')
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    82
199
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    83
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    84
class AccommodationForm(forms.ModelForm):
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    85
    """PyCon Accommodation form
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    86
    """
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    87
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    88
    def save(self, user, scope):
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    89
        try:
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    90
            acco = Accommodation.objects.get(user=user, scope=scope)
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    91
        except ObjectDoesNotExist:
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    92
            acco = Accommodation(user=user, scope=scope)
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    93
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    94
        sex = self.cleaned_data['sex']
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    95
        accommodation_required = self.cleaned_data['accommodation_required']
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    96
        accommodation_days = self.cleaned_data['accommodation_days']
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    97
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    98
        acco.sex = sex
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
    99
        acco.accommodation_required = accommodation_required
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   100
        acco.accommodation_days = accommodation_days if (
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   101
            accommodation_days) else 0
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   102
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   103
        acco.save()
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   104
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   105
        return acco
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   106
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   107
    def clean(self):
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   108
        """Makes sure that accommodation form is correct, i.e. sex
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   109
        and number of days required are filled in when the accommodation
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   110
        is required.
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   111
        """
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   112
        cleaned = self.cleaned_data
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   113
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   114
        sex = self.cleaned_data['sex']
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   115
        accommodation_required = self.cleaned_data['accommodation_required']
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   116
        accommodation_days = self.cleaned_data['accommodation_days']
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   117
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   118
        if accommodation_required and (not sex or not accommodation_days
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   119
            or accommodation_days == 0):
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   120
            raise forms.ValidationError(
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   121
                u"If accommodation is required both gender and number of "
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   122
                "days for which accommodation is required is mandatory.")
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   123
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   124
        return super(AccommodationForm, self).clean()
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   125
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   126
    class Meta:
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   127
        model = Accommodation
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   128
        fields = ('accommodation_required', 'sex', 'accommodation_days')
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   129
97cbeda302a9 Added accommodation Django form, wrote the save method and overwrote the cleaner.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 191
diff changeset
   130
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   131
PC = (
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   132
        ('all', 'all'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   133
        ('paid', 'paid'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   134
        ('not paid', 'not paid')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   135
        )
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   136
HC = (
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   137
        ('all', 'all'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   138
        ('party', 'party'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   139
        ('no party', 'no party')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   140
        )
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   141
AC = (
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   142
        ('all', 'all'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   143
        ('0', '0'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   144
        ('10', '10'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   145
        ('20', '20'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   146
        ('40', '40'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   147
        )
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   148
OC = (
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   149
        ('email', 'email'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   150
        ('amount', 'amount'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   151
        )
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   152
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   153
IC = (
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   154
        ('Name', 'name'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   155
        ('Email', 'email'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   156
        ('Amount', 'amount'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   157
        ('Organisation', 'organisation'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   158
        ('Conference', 'conference'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   159
        ('Tutorial', 'tutorial'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   160
        ('Sprint', 'sprint'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   161
        ('T-size', 'tshirt'),
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   162
        )
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   163
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
   164
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   165
class RegistrationAdminSelectForm(forms.Form):
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   166
    """
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   167
    Used to make selection for csv download
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   168
    """
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   169
    by_payment = forms.ChoiceField(choices=PC, required=False,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   170
        label=u'By payment')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   171
    by_amount = forms.MultipleChoiceField(choices=AC, required=False,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   172
        label=u'By amount')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   173
    by_party = forms.ChoiceField(choices=HC, required=False,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   174
        label=u'by party')
137
ec6e58c639bf Added phone number, modified Occupation to be choice field.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 96
diff changeset
   175
    by_tshirt = forms.ChoiceField(choices=SIZE_CHOICES, required=False,
94
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   176
        label=u'by tshirt size')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   177
    order_by = forms.ChoiceField(choices=OC, required=False,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   178
        label=u'order results')
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   179
    include = forms.MultipleChoiceField(choices=IC, required=False,
87e77aa18610 Moved the files to new Django app named scipycon and modified settings.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
   180
        label=u'Include fields')