app/projrev/views/proposal.py
changeset 14 9d720dfded68
parent 13 684540719344
child 15 8c9e6c98de82
--- a/app/projrev/views/proposal.py	Fri Aug 07 03:04:57 2009 +0530
+++ b/app/projrev/views/proposal.py	Fri Aug 07 03:16:44 2009 +0530
@@ -157,7 +157,7 @@
 
       context['proposal_path'] = proposal_path
       context['proposal_name'] = proposal_name
-      context['last_submitted'] = proposal.submitted_on 
+      context['last_submitted'] = proposal.submitted_on
 
     if 'HTTP_REFERER' in request.META:
       referer = request.META['HTTP_REFERER'].split('/')
@@ -236,30 +236,37 @@
   """
   """
 
+  context = {}
+
   if not micr_code:
     template = 'projrev/proposal/list.html'
-    context = {
-        'projects': Project.objects.all().exclude(status__exact='invalid'),
-        'row_url': '/proposal/review/',
-        }
+    context['projects'] = Project.objects.all().exclude(status__exact='invalid')
+    context['row_url'] = '/proposal/review/'
 
     return render_to_response(template, RequestContext(request, context))
 
   if not rev_form:
     rev_form = projrev_forms.ReviewForm()
 
-  proposal_path = str(Project.objects.get(
-          micr_code=micr_code).proposal_set.all().order_by(
-              '-submitted_on')[0].document)
+  project = Project.objects.get(micr_code=micr_code)
+  context['form'] = rev_form
+  context['project'] = project
 
-  proposal_name = proposal_path.split('/')[-1]
+  proposal = project.proposal_set.all().order_by('-submitted_on')[0]
+
+  if proposal:
+    proposal_path = str(proposal.document)
 
-  context = {
-      'form': rev_form,
-      'project': Project.objects.get(micr_code=micr_code),
-      'proposal_path': proposal_path,
-      'proposal_name': proposal_name,
-      }
+    proposal_name = proposal_path.split('/')[-1]
+
+    context['proposal_path'] = proposal_path
+    context['proposal_name'] = proposal_name
+    context['last_submitted'] = proposal.submitted_on
+
+  reviews = project.review_set.all().order_by('-reviewed_on')
+  if reviews:
+    context['last_reviewed'] = reviews[0].reviewed_on
+    context['nr_reviews'] = len(reviews)
 
   template = 'projrev/proposal/review.html'