app/projrev/views/helpers/forms.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 04 Aug 2009 19:42:47 +0530
changeset 1 324233b04d76
parent 0 c94bd9ae70d2
child 4 8d9da911ed7d
permissions -rw-r--r--
Login mechanism.
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
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
from django import forms
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
from projrev.models import Project
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
from projrev.models import Review
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
class ProposalForm(forms.ModelForm):
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
  """Creates a form for the project.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
  """
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
  document = forms.FileField()
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
  micr_code = forms.CharField(max_length=15, required=False)
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
  class Meta:
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
    # 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
    23
    # name and the purpose of the form is for Proposal acceptance, we
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
    # use Project model here.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
    model = Project
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
    # 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
    28
    # be automatically generated.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
    fields = ('micr_code', 'line_item', 'institution', 'state', 'district')
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
class ReviewForm(forms.ModelForm):
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
  """Creates a form for review of proposal.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
  """
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
  project = forms.ModelChoiceField(queryset=Project.objects.all(), 
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
                                   widget=forms.HiddenInput(),
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
                                   required=False)
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
  class Meta:
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
    # Create a form from Review data model.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
    model = Review
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
1
324233b04d76 Login mechanism.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 0
diff changeset
    43
    exclude = ('reviewer')