# HG changeset patch # User Madhusudan.C.S # Date 1249856673 -19800 # Node ID ef9fdc847543531fd42455730bf4994933903dcd # Parent 94fe7fe7394d7ccdf8882dcd8c9ae7ae6d48cfac Added list of My reviews. diff -r 94fe7fe7394d -r ef9fdc847543 app/projrev/views/helpers/templatetags/review_helpers.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 diff -r 94fe7fe7394d -r ef9fdc847543 app/projrev/views/proposal.py --- 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 diff -r 94fe7fe7394d -r ef9fdc847543 app/templates/projrev/base.html --- 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%}
  • Review Proposals
  • Aggregated Scores for Proposals
  • +
  • Show all my reviews
  • {% else %}
  • Create/Edit Proposals
  • {% endif %} diff -r 94fe7fe7394d -r ef9fdc847543 app/templates/projrev/proposal/myreviews.html --- /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 %} +
    + + +

    My reivews

    + +

    List of all the reviews given my me.

    + + {% if reviews %} + {% for review in reviews %} + {% as_my_review review %} + {% endfor %} +

    + {% endif %} +
    +{% endblock content %} \ No newline at end of file diff -r 94fe7fe7394d -r ef9fdc847543 app/templates/projrev/templatetags/_as_my_review.html --- /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 @@ +

    + On {{ review.reviewed_on|date:"jS F Y h:iA" }} + Total Score: {{ total_score }} + Proposal: + {{ proposal_name }} + + Institution: {{ institution }} + State: {{ state }} + District: {{ district }}
    + Line Item: {{ line_item }}
    + Attribute 1: {{ review.attribute1 }}, + Attribute 2: {{ review.attribute2 }}, + Attribute 3: {{ review.attribute3 }}, + Attribute 4: {{ review.attribute4 }}, + Attribute 5: {{ review.attribute5 }}, + Attribute 6: {{ review.attribute6 }}, + Attribute 7: {{ review.attribute7 }}, + Attribute 8: {{ review.attribute8 }}, + Attribute 9: {{ review.attribute9 }} +

    +
    + {{ review.comment }} +
    \ No newline at end of file diff -r 94fe7fe7394d -r ef9fdc847543 app/urls.py --- 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[A-Z]{6}\d{9})/$', 'app.projrev.views.proposal.rank'), + (r'^proposal/myreviews/$', + 'app.projrev.views.proposal.listMyReviews'), (r'^site-content/(?P.*)', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),