Footer for reviews.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Fri, 07 Aug 2009 03:16:44 +0530
changeset 14 9d720dfded68
parent 13 684540719344
child 15 8c9e6c98de82
Footer for reviews.
app/projrev/views/proposal.py
app/templates/projrev/proposal/review.html
app/templates/projrev/proposal/submit.html
--- 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'
 
--- a/app/templates/projrev/proposal/review.html	Fri Aug 07 03:04:57 2009 +0530
+++ b/app/templates/projrev/proposal/review.html	Fri Aug 07 03:16:44 2009 +0530
@@ -55,14 +55,32 @@
       {{ form.as_p }}
 		<br />	
 		<input class="button" type="submit" value="Submit Review" />		
-		</p>		
+		</p>
 	</form>
 				
-	<p class="post-footer align-right">					
-		<span class="comments">Reviews (5)</span>
-		<span class="date">Last reviewed: Nov 11, 2006</span>
-		<span class="date">Last submitted: Nov 11, 2006</span>	
-	</p>
+	 <p class="post-footer align-right">
+    <span class="comments">Reviews:
+    {% if nr_reviews %}
+      {{ nr_reviews }}
+    {% else %}
+      (<i>None</i>)
+    {% endif %}
+    </span>
+    <span class="date">Last reviewed:
+    {% if last_reviewed %}
+      {{ last_reviewed|date:"jS F Y h:iA" }}
+    {% else %}
+      (<i>Not Reviewed</i>)
+    {% endif %}
+    </span>
+    <span class="date">Last submitted:
+    {% if last_submitted %}
+      {{ last_submitted|date:"jS F Y h:iA" }}
+    {% else %}
+      (<i>New Submission</i>)
+    {% endif %} 
+    </span> 
+  </p>
 				
 </div>
 {% endblock content %}
\ No newline at end of file
--- a/app/templates/projrev/proposal/submit.html	Fri Aug 07 03:04:57 2009 +0530
+++ b/app/templates/projrev/proposal/submit.html	Fri Aug 07 03:16:44 2009 +0530
@@ -43,14 +43,14 @@
 		</span>
 		<span class="date">Last reviewed:
 		{% if last_reviewed %}
-      {{ last_reviewed|date:"jS F Y H:i" }}
+      {{ last_reviewed|date:"jS F Y h:iA" }}
     {% else %}
       (<i>Not Reviewed</i>)
     {% endif %}
 		</span>
 		<span class="date">Last submitted:
 		{% if last_submitted %}
-      {{ last_submitted|date:"jS F Y H:i" }}
+      {{ last_submitted|date:"jS F Y h:iA" }}
     {% else %}
       (<i>New Submission</i>)
     {% endif %}