app/projrev/views/helpers/forms.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Wed, 12 Aug 2009 22:41:21 +0530
changeset 43 55e650bb9dbe
parent 39 e7880a8f7e04
permissions -rw-r--r--
Star values recalled.
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
43
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    14
from projrev.models import Proposal
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
from projrev.models import Review
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
43
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    17
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
class ProposalForm(forms.ModelForm):
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
  """Creates a form for the project.
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
24
7257b66a6766 Purr implemented for submit form.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 19
diff changeset
    22
  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
    23
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
  class Meta:
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
    # 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
    26
    # name and the purpose of the form is for Proposal acceptance, we
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
    # use Project model here.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
    model = Project
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
    # 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
    31
    # be automatically generated.
38
3cb38edbe05f Form changes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 30
diff changeset
    32
    fields = ('title', 'line_item', 'institution', 'address', 'city',
39
e7880a8f7e04 Changes to the data model for including blank districts.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 38
diff changeset
    33
              'pin_code', 'state', 'district', 'phone_num', 'fax_num')
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
30
94fe7fe7394d Complete star plugin implmentation on backend with database writes.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 26
diff changeset
    35
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
class ReviewForm(forms.ModelForm):
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
  """Creates a form for review of proposal.
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
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
  project = forms.ModelChoiceField(queryset=Project.objects.all(), 
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
                                   widget=forms.HiddenInput(),
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
                                   required=False)
43
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    43
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    44
  proposal = forms.ModelChoiceField(queryset=Proposal.objects.all(), 
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    45
                                    widget=forms.HiddenInput(),
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    46
                                    required=False)
55e650bb9dbe Star values recalled.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 39
diff changeset
    47
26
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    48
  reviewer = forms.ModelChoiceField(queryset=User.objects.all(), 
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    49
                                    widget=forms.HiddenInput(),
97bd3c28c957 Renamed Comments to Reviews.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 24
diff changeset
    50
                                    required=False)
0
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
  class Meta:
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    53
    # Create a form from Review data model.
c94bd9ae70d2 First commit.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
    model = Review