app/soc/views/models/student_proposal.py
changeset 1741 0da1285f5bc0
parent 1715 3ec1a9518452
child 1752 255117ccd6a0
equal deleted inserted replaced
1740:fbc2ad561c4b 1741:0da1285f5bc0
   252 
   252 
   253   def _public(self, request, entity, context):
   253   def _public(self, request, entity, context):
   254     """See base.View._public().
   254     """See base.View._public().
   255     """
   255     """
   256 
   256 
       
   257     from soc.logic.models.review import logic as review_logic
       
   258 
   257     context['student_name'] = entity.scope.name()
   259     context['student_name'] = entity.scope.name()
   258 
   260 
   259     if entity.mentor:
   261     context['public_reviews'] = review_logic.getReviewsForEntity(entity,
   260       context['mentor_name'] = entity.mentor.name()
   262         is_public=True, order=['created'])
   261     else:
       
   262       context['mentor_name'] = "No mentor assigned"
       
   263 
   263 
   264   @decorators.merge_params
   264   @decorators.merge_params
   265   @decorators.check_access
   265   @decorators.check_access
   266   def apply(self, request, access_type,
   266   def apply(self, request, access_type,
   267              page_name=None, params=None, **kwargs):
   267              page_name=None, params=None, **kwargs):
   553       context['possible_mentors'] = ', '.join(mentor_names)
   553       context['possible_mentors'] = ', '.join(mentor_names)
   554 
   554 
   555     # TODO(ljvderijk) listing of total given scores per mentor
   555     # TODO(ljvderijk) listing of total given scores per mentor
   556     # a dict with key as role.user ?
   556     # a dict with key as role.user ?
   557 
   557 
       
   558     # order the reviews by ascending creation date
       
   559     order = ['created']
       
   560 
   558     # get the public reviews
   561     # get the public reviews
   559     fields = {'scope': entity,
   562     context['public_reviews'] = review_logic.getReviewsForEntity(entity,
   560               'is_public': True}
   563         is_public=True, order=order)
   561 
       
   562     order = ['modified']
       
   563 
       
   564     query = review_logic.getQueryForFields(filter=fields, order=order)
       
   565     context['public_reviews'] = review_logic.getAll(query)
       
   566 
   564 
   567     # get the private reviews
   565     # get the private reviews
   568     fields['is_public'] = False
   566     context['private_reviews'] = review_logic.getReviewsForEntity(entity,
   569 
   567         is_public=False, order=order)
   570     query = review_logic.getQueryForFields(filter=fields, order=order)
       
   571     context['private_reviews'] = review_logic.getAll(query)
       
   572 
   568 
   573     # which button should we show to the mentor?
   569     # which button should we show to the mentor?
   574     if mentor:
   570     if mentor:
   575       if mentor.key() in possible_mentors:
   571       if mentor.key() in possible_mentors:
   576         # show "No longer willing to mentor"
   572         # show "No longer willing to mentor"