app/projrev/views/helpers/forms.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Mon, 10 Aug 2009 19:38:53 +0530
changeset 38 3cb38edbe05f
parent 30 94fe7fe7394d
child 39 e7880a8f7e04
permissions -rw-r--r--
Form changes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
"""This module contains the form helpers
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
"""
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
__authors__ = [
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
  '"Madhusudan.C.S" <madhusudancs@gmail.com>',
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
]
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
6
17cab73c49eb Request context.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 4
diff changeset
     9
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
from django import forms
26
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    11
from django.contrib.auth.models import User
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
from projrev.models import Project
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
from projrev.models import Review
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
class ProposalForm(forms.ModelForm):
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
  """Creates a form for the project.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
  """
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
24
7257b66a6766 Purr implemented for submit form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 19
diff changeset
    20
  document = forms.FileField(required=False, help_text='Select the document path from your local file system.')
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
  class Meta:
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
    # We store most of the data in Project model. So even though the
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
    # name and the purpose of the form is for Proposal acceptance, we
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
    # use Project model here.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
    model = Project
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
    # fields in the Project that must not appear in the form, but have
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
    # be automatically generated.
38
3cb38edbe05f Form changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 30
diff changeset
    30
    fields = ('title', 'line_item', 'institution', 'address', 'city',
3cb38edbe05f Form changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 30
diff changeset
    31
              'pin_code', 'state', 'district', 'mobile_num', 'fax_num')
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
30
94fe7fe7394d Complete star plugin implmentation on backend with database writes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 26
diff changeset
    33
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
class ReviewForm(forms.ModelForm):
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
  """Creates a form for review of proposal.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
  """
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
  project = forms.ModelChoiceField(queryset=Project.objects.all(), 
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
                                   widget=forms.HiddenInput(),
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
                                   required=False)
26
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    41
  reviewer = forms.ModelChoiceField(queryset=User.objects.all(), 
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    42
                                    widget=forms.HiddenInput(),
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    43
                                    required=False)
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
  class Meta:
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    46
    # Create a form from Review data model.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    47
    model = Review