app/projrev/views/helpers/templatetags/review_helpers.py
changeset 31 ef9fdc847543
parent 27 37612f295cd4
child 41 64249ebaf65a
equal deleted inserted replaced
30:94fe7fe7394d 31:ef9fdc847543
    19   total_score = (review.attribute1 + review.attribute2 + review.attribute3 + 
    19   total_score = (review.attribute1 + review.attribute2 + review.attribute3 + 
    20                  review.attribute4 + review.attribute5 + review.attribute6 +
    20                  review.attribute4 + review.attribute5 + review.attribute6 +
    21                  review.attribute7 + review.attribute8 + review.attribute9)
    21                  review.attribute7 + review.attribute8 + review.attribute9)
    22 
    22 
    23   return {'review': review, 'total_score': total_score}
    23   return {'review': review, 'total_score': total_score}
       
    24 
       
    25 @register.inclusion_tag('projrev/templatetags/_as_my_review.html')
       
    26 def as_my_review(review):
       
    27   """Returns the comment contexts for the template tag.
       
    28   """
       
    29 
       
    30   total_score = (review.attribute1 + review.attribute2 + review.attribute3 + 
       
    31                  review.attribute4 + review.attribute5 + review.attribute6 +
       
    32                  review.attribute7 + review.attribute8 + review.attribute9)
       
    33 
       
    34   project = review.project
       
    35   proposal = project.proposal_set.all().order_by('-submitted_on')[0]
       
    36 
       
    37   review_context = {
       
    38       'review': review,
       
    39       'total_score': total_score,
       
    40       }
       
    41 
       
    42   if proposal:
       
    43     proposal_path = str(proposal.document)
       
    44     proposal_name = proposal_path.split('/')[-1]
       
    45     review_context['proposal_path'] = proposal_path
       
    46     review_context['proposal_name'] = proposal_name
       
    47     review_context['institution'] = project.institution
       
    48     review_context['state'] = project.state
       
    49     review_context['district'] = project.district
       
    50     review_context['line_item'] = project.line_item
       
    51 
       
    52   return review_context