app/soc/views/models/student_proposal.py
changeset 2360 e389d26949db
parent 2285 76707dc77b33
child 2748 7fbc98f3adde
equal deleted inserted replaced
2359:d4de17ab9a1f 2360:e389d26949db
   145         'link_id': forms.CharField(widget=forms.HiddenInput)
   145         'link_id': forms.CharField(widget=forms.HiddenInput)
   146         }
   146         }
   147 
   147 
   148     new_params['edit_template'] = 'soc/student_proposal/edit.html'
   148     new_params['edit_template'] = 'soc/student_proposal/edit.html'
   149     new_params['review_template'] = 'soc/student_proposal/review.html'
   149     new_params['review_template'] = 'soc/student_proposal/review.html'
   150     new_params['review_after_deadline_template'] = 'soc/student_proposal/review_after_deadline.html'
   150     new_params['review_after_deadline_template'] = \
       
   151         'soc/student_proposal/review_after_deadline.html'
   151 
   152 
   152     params = dicts.merge(params, new_params)
   153     params = dicts.merge(params, new_params)
   153 
   154 
   154     super(View, self).__init__(params=params)
   155     super(View, self).__init__(params=params)
   155 
   156 
   353     comment = fields['comment']
   354     comment = fields['comment']
   354 
   355 
   355     if comment:
   356     if comment:
   356       # create a new public review containing the comment
   357       # create a new public review containing the comment
   357       user_entity = user_logic.logic.getForCurrentAccount()
   358       user_entity = user_logic.logic.getForCurrentAccount()
   358 
   359       # pylint: disable-msg=E1103
   359       if user_entity.key() == entity.scope.user.key():
   360       if user_entity.key() == entity.scope.user.key():
   360         # student is posting
   361         # student is posting
   361         reviewer = entity.scope
   362         reviewer = entity.scope
   362       else:
   363       else:
   363         # check if the person commenting is an org_admin
   364         # check if the person commenting is an org_admin
   399 
   400 
   400       # get the current user
   401       # get the current user
   401       user_entity = user_logic.logic.getForCurrentAccount()
   402       user_entity = user_logic.logic.getForCurrentAccount()
   402 
   403 
   403       # create the fields that should be in the ReviewFollower entity
   404       # create the fields that should be in the ReviewFollower entity
       
   405       # pylint: disable-msg=E1103
   404       fields = {'link_id': user_entity.link_id,
   406       fields = {'link_id': user_entity.link_id,
   405                 'scope': entity,
   407                 'scope': entity,
   406                 'scope_path': entity.key().id_or_name(),
   408                 'scope_path': entity.key().id_or_name(),
   407                 'user': user_entity
   409                 'user': user_entity
   408                }
   410                }
   444     context['student_name'] = student_entity.name()
   446     context['student_name'] = student_entity.name()
   445 
   447 
   446     user_entity = user_logic.logic.getForCurrentAccount()
   448     user_entity = user_logic.logic.getForCurrentAccount()
   447 
   449 
   448     # check if the current user is the student
   450     # check if the current user is the student
       
   451     # pylint: disable-msg=E1103
   449     if user_entity.key() == student_entity.user.key():
   452     if user_entity.key() == student_entity.user.key():
   450       # show the proposal edit link
   453       # show the proposal edit link
   451       context['edit_link'] = redirects.getEditRedirect(entity, params)
   454       context['edit_link'] = redirects.getEditRedirect(entity, params)
   452 
   455 
   453     # check if the current user is subscribed to this proposal's public reviews
   456     # check if the current user is subscribed to this proposal's public reviews
   485       org_entity = org_logic.logic.getForFields(filter, unique=True)
   488       org_entity = org_logic.logic.getForFields(filter, unique=True)
   486 
   489 
   487       if org_entity:
   490       if org_entity:
   488         # organization found use special form and also seed this form
   491         # organization found use special form and also seed this form
   489         params['create_form'] = params['student_create_form']
   492         params['create_form'] = params['student_create_form']
       
   493         # pylint: disable-msg=E1103
   490         kwargs['organization'] = org_entity.link_id
   494         kwargs['organization'] = org_entity.link_id
   491         kwargs['content'] = org_entity.contrib_template
   495         kwargs['content'] = org_entity.contrib_template
   492 
   496 
   493     return super(View, self).create(request, access_type, page_name=page_name,
   497     return super(View, self).create(request, access_type, page_name=page_name,
   494                      params=params, **kwargs)
   498                      params=params, **kwargs)
   803     if public_subscription != None or private_subscription != None:
   807     if public_subscription != None or private_subscription != None:
   804       # get the current user
   808       # get the current user
   805       user_entity = user_logic.logic.getForCurrentAccount()
   809       user_entity = user_logic.logic.getForCurrentAccount()
   806 
   810 
   807       # create the fields that should be in the ReviewFollower entity
   811       # create the fields that should be in the ReviewFollower entity
       
   812       # pylint: disable-msg=E1103
   808       fields = {'link_id': user_entity.link_id,
   813       fields = {'link_id': user_entity.link_id,
   809                 'scope': entity,
   814                 'scope': entity,
   810                 'scope_path': entity.key().id_or_name(),
   815                 'scope_path': entity.key().id_or_name(),
   811                 'user': user_entity
   816                 'user': user_entity
   812                }
   817                }
   873 
   878 
   874     template = params['review_template']
   879     template = params['review_template']
   875 
   880 
   876     return responses.respond(request, template, context=context)
   881     return responses.respond(request, template, context=context)
   877 
   882 
   878   def reviewAfterDeadline(self,request, context, params, entity,**kwargs):
   883   def reviewAfterDeadline(self, request, context, params, entity, **kwargs):
   879     """View that shows the review view after the accepted students announced deadline.
   884     """View that shows the review view after the accepted students 
       
   885        announced deadline.
   880 
   886 
   881     For Args see base.View.public().
   887     For Args see base.View.public().
   882     """
   888     """
   883 
   889 
   884     review_context = self._getDefaultReviewContext(entity, None, None)
   890     review_context = self._getDefaultReviewContext(entity, None, None)
   987     fields = {'scope': entity,
   993     fields = {'scope': entity,
   988               'user': user_entity,}
   994               'user': user_entity,}
   989     follower_entity = review_follower_logic.getForFields(fields, unique=True)
   995     follower_entity = review_follower_logic.getForFields(fields, unique=True)
   990 
   996 
   991     if follower_entity:
   997     if follower_entity:
       
   998       # pylint: disable-msg=E1103
   992       context['is_subscribed_public'] =  follower_entity.subscribed_public
   999       context['is_subscribed_public'] =  follower_entity.subscribed_public
   993       context['is_subscribed_private'] = follower_entity.subscribed_private
  1000       context['is_subscribed_private'] = follower_entity.subscribed_private
   994 
  1001 
   995     return context
  1002     return context
   996 
  1003