Added list of My reviews.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Mon, 10 Aug 2009 03:54:33 +0530
changeset 31 ef9fdc847543
parent 30 94fe7fe7394d
child 32 b39994cca761
Added list of My reviews.
app/projrev/views/helpers/templatetags/review_helpers.py
app/projrev/views/proposal.py
app/templates/projrev/base.html
app/templates/projrev/proposal/myreviews.html
app/templates/projrev/templatetags/_as_my_review.html
app/urls.py
--- a/app/projrev/views/helpers/templatetags/review_helpers.py	Mon Aug 10 03:24:02 2009 +0530
+++ b/app/projrev/views/helpers/templatetags/review_helpers.py	Mon Aug 10 03:54:33 2009 +0530
@@ -21,3 +21,32 @@
                  review.attribute7 + review.attribute8 + review.attribute9)
 
   return {'review': review, 'total_score': total_score}
+
+@register.inclusion_tag('projrev/templatetags/_as_my_review.html')
+def as_my_review(review):
+  """Returns the comment contexts for the template tag.
+  """
+
+  total_score = (review.attribute1 + review.attribute2 + review.attribute3 + 
+                 review.attribute4 + review.attribute5 + review.attribute6 +
+                 review.attribute7 + review.attribute8 + review.attribute9)
+
+  project = review.project
+  proposal = project.proposal_set.all().order_by('-submitted_on')[0]
+
+  review_context = {
+      'review': review,
+      'total_score': total_score,
+      }
+
+  if proposal:
+    proposal_path = str(proposal.document)
+    proposal_name = proposal_path.split('/')[-1]
+    review_context['proposal_path'] = proposal_path
+    review_context['proposal_name'] = proposal_name
+    review_context['institution'] = project.institution
+    review_context['state'] = project.state
+    review_context['district'] = project.district
+    review_context['line_item'] = project.line_item
+
+  return review_context
--- a/app/projrev/views/proposal.py	Mon Aug 10 03:24:02 2009 +0530
+++ b/app/projrev/views/proposal.py	Mon Aug 10 03:54:33 2009 +0530
@@ -20,6 +20,7 @@
 
 from projrev.models import Project
 from projrev.models import Proposal
+from projrev.models import Review
 from projrev.views.helpers import access 
 from projrev.views.helpers import forms as projrev_forms
 
@@ -406,5 +407,14 @@
   """
   context = {}
 
-  template = ''
-  return render_to_response()
\ No newline at end of file
+  # Get all the reviews and put them to context.
+  reviews = Review.objects.all().order_by('reviewed_on')
+  nr_reviews = len(reviews)
+  if reviews:
+    context['reviews'] = reviews
+    context['last_reviewed'] = reviews[len(reviews)-1].reviewed_on
+    context['nr_reviews'] = nr_reviews
+  
+  template = 'projrev/proposal/myreviews.html'
+
+  return render_to_response(template, RequestContext(request, context))
\ No newline at end of file
--- a/app/templates/projrev/base.html	Mon Aug 10 03:24:02 2009 +0530
+++ b/app/templates/projrev/base.html	Mon Aug 10 03:54:33 2009 +0530
@@ -61,6 +61,7 @@
             {% if user.is_staff%}
               <li><a href="/proposal/review/" class="top">Review Proposals</a></li>
               <li><a href="/proposal/rank/" class="top">Aggregated Scores for Proposals</a></li>
+              <li><a href="/proposal/myreviews/" class="top">Show all my reviews</a></li>
             {% else %}
               <li><a href="/proposal/submit/" class="top">Create/Edit Proposals</a></li>
             {% endif %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/templates/projrev/proposal/myreviews.html	Mon Aug 10 03:54:33 2009 +0530
@@ -0,0 +1,19 @@
+{% extends "projrev/base.html" %}
+{% load review_helpers %}
+
+{% block content %}
+<div class="post">
+			
+	<a name="TemplateInfo"></a>	
+	<h1>My reivews</h1>
+				
+	<p>List of all the reviews given my me.</p>
+
+  {% if reviews %}
+  {% for review in reviews %}
+    {% as_my_review review %}
+  {% endfor %}
+  </p>
+  {% endif %}
+</div>
+{% endblock content %}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/templates/projrev/templatetags/_as_my_review.html	Mon Aug 10 03:54:33 2009 +0530
@@ -0,0 +1,23 @@
+<p class="post-footer align-right">
+  On <strong>{{ review.reviewed_on|date:"jS F Y h:iA" }}</strong>
+  Total Score: <strong>{{ total_score }}</strong>
+  Proposal: <strong>
+   <a href="/site-content/{{ proposal_path }}">{{ proposal_name }}</a>
+   </strong>
+  Institution: <strong>{{ institution }}</strong>
+  State: <strong>{{ state }}</strong>
+  District: <strong>{{ district }}</strong><br />
+  Line Item: <strong>{{ line_item }}</strong><br />
+  Attribute 1: <strong>{{ review.attribute1 }},</strong> 
+  Attribute 2: <strong>{{ review.attribute2 }},</strong>
+  Attribute 3: <strong>{{ review.attribute3 }},</strong>
+  Attribute 4: <strong>{{ review.attribute4 }},</strong>
+  Attribute 5: <strong>{{ review.attribute5 }},</strong>
+  Attribute 6: <strong>{{ review.attribute6 }},</strong>
+  Attribute 7: <strong>{{ review.attribute7 }},</strong>
+  Attribute 8: <strong>{{ review.attribute8 }},</strong>
+  Attribute 9: <strong>{{ review.attribute9 }}</strong>
+</p>
+<div class="review-center-box">
+  {{ review.comment }}
+</div>
\ No newline at end of file
--- a/app/urls.py	Mon Aug 10 03:24:02 2009 +0530
+++ b/app/urls.py	Mon Aug 10 03:54:33 2009 +0530
@@ -36,6 +36,8 @@
     (r'^proposal/rank/$', 'app.projrev.views.proposal.rank'),
     (r'^proposal/rank/(?P<micr_code>[A-Z]{6}\d{9})/$',
      'app.projrev.views.proposal.rank'),
+     (r'^proposal/myreviews/$', 
+      'app.projrev.views.proposal.listMyReviews'),
     (r'^site-content/(?P<path>.*)', 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT}),