app/projrev/views/proposal.py
changeset 12 aac4944aca52
parent 8 294ff7ac9cb6
child 13 684540719344
--- a/app/projrev/views/proposal.py	Thu Aug 06 22:48:30 2009 +0530
+++ b/app/projrev/views/proposal.py	Fri Aug 07 01:03:56 2009 +0530
@@ -22,6 +22,7 @@
 from projrev.views.helpers import forms as projrev_forms
 
 
+@access.register('proposer')
 @access.checkAccess
 def getMicr(request):
   """View to get MICR Code from the user.
@@ -62,7 +63,7 @@
 
     return render_to_response(template, RequestContext(request, context))
 
-
+@access.register('proposer')
 @access.checkAccess
 def submit(request, micr_code=None):
   """View for proposal submission.
@@ -109,7 +110,8 @@
 
     # Create a proposal for the project.
     proposal = project.proposal_set.create(
-        document=prop_form.cleaned_data['document'], rev_num = 0)
+        document=prop_form.cleaned_data['document'], 
+        submitted_by=request.user, rev_num = 0)
 
     proposal.save()
 
@@ -137,7 +139,8 @@
     prop_form = projrev_forms.ProposalForm(
         initial=initial_vals, instance=project)
 
-    proposal_path = str(project.proposal_set.all()[0].document)
+    proposal_path = str(
+        project.proposal_set.all().order_by('-submitted_on')[0].document)
 
     proposal_name = proposal_path.split('/')[-1]
 
@@ -164,6 +167,7 @@
 
   return render_to_response(template, RequestContext(request, context))
 
+@access.register('proposer')
 @access.checkAccess
 def withdraw(request, micr_code=None):
   """View Method for withdrawal of proposal.
@@ -182,6 +186,7 @@
 
   return render_to_response(template, RequestContext(request, context))
 
+@access.register('reviewer')
 @access.checkAccess
 def review(request, micr_code=None):
   """View for reviewing the proposal.
@@ -226,7 +231,8 @@
     rev_form = projrev_forms.ReviewForm()
 
   proposal_path = str(Project.objects.get(
-          micr_code=micr_code).proposal_set.all()[0].document)
+          micr_code=micr_code).proposal_set.all().order_by(
+              '-submitted_on')[0].document)
 
   proposal_name = proposal_path.split('/')[-1]
 
@@ -241,6 +247,7 @@
 
   return render_to_response(template, RequestContext(request, context))
 
+@access.register('reviewer')
 @access.checkAccess
 def rank(request, micr_code=None):
   """
@@ -272,7 +279,8 @@
 
   projects = Project.objects.get(micr_code=micr_code)
 
-  proposal_path = str(projects.proposal_set.all()[0].document)
+  proposal_path = str(
+      projects.proposal_set.all().order_by('-submitted_on')[0].document)
 
   proposal_name = proposal_path.split('/')[-1]