app/soc/views/models/student_proposal.py
changeset 2258 280d2cf745f2
parent 2191 d20557e217dc
child 2260 129901892999
equal deleted inserted replaced
2257:7c0af7e05257 2258:280d2cf745f2
    84     rights['apply'] = [
    84     rights['apply'] = [
    85         ('checkIsStudent', ['scope_path', ['active']]),
    85         ('checkIsStudent', ['scope_path', ['active']]),
    86         ('checkCanStudentPropose', ['scope_path', True])]
    86         ('checkCanStudentPropose', ['scope_path', True])]
    87     rights['review'] = [('checkRoleAndStatusForStudentProposal',
    87     rights['review'] = [('checkRoleAndStatusForStudentProposal',
    88             [['org_admin', 'mentor', 'host'], 
    88             [['org_admin', 'mentor', 'host'], 
    89             ['active'], ['new', 'pending', 'invalid']])]
    89             ['active'],
       
    90             ['new', 'pending', 'accepted', 'rejected', 'invalid']])]
    90 
    91 
    91     new_params = {}
    92     new_params = {}
    92     new_params['logic'] = soc.logic.models.student_proposal.logic
    93     new_params['logic'] = soc.logic.models.student_proposal.logic
    93     new_params['rights'] = rights
    94     new_params['rights'] = rights
    94     new_params['name'] = "Student Proposal"
    95     new_params['name'] = "Student Proposal"
   144         'link_id': forms.CharField(widget=forms.HiddenInput)
   145         'link_id': forms.CharField(widget=forms.HiddenInput)
   145         }
   146         }
   146 
   147 
   147     new_params['edit_template'] = 'soc/student_proposal/edit.html'
   148     new_params['edit_template'] = 'soc/student_proposal/edit.html'
   148     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'
   149 
   151 
   150     params = dicts.merge(params, new_params)
   152     params = dicts.merge(params, new_params)
   151 
   153 
   152     super(View, self).__init__(params=params)
   154     super(View, self).__init__(params=params)
   153 
   155 
   613     """View that allows Organization Admins and Mentors to review the proposal.
   615     """View that allows Organization Admins and Mentors to review the proposal.
   614 
   616 
   615        For Args see base.View.public().
   617        For Args see base.View.public().
   616     """
   618     """
   617 
   619 
       
   620     from soc.logic.helper import timeline as timeline_helper
       
   621 
       
   622 
   618     try:
   623     try:
   619       entity = self._logic.getFromKeyFieldsOr404(kwargs)
   624       entity = self._logic.getFromKeyFieldsOr404(kwargs)
   620     except out_of_band.Error, error:
   625     except out_of_band.Error, error:
   621       return helper.responses.errorResponse(
   626       return helper.responses.errorResponse(
   622           error, request, template=params['error_public'])
   627           error, request, template=params['error_public'])
   627     context['page_name'] = '%s "%s" from %s' % (page_name, entity.title,
   632     context['page_name'] = '%s "%s" from %s' % (page_name, entity.title,
   628                                                 entity.scope.name())
   633                                                 entity.scope.name())
   629     context['entity'] = entity
   634     context['entity'] = entity
   630     context['entity_type'] = params['name']
   635     context['entity_type'] = params['name']
   631     context['entity_type_url'] = params['url_name']
   636     context['entity_type_url'] = params['url_name']
       
   637 
       
   638     program_entity = entity.program
       
   639 
       
   640     if timeline_helper.isAfterEvent(program_entity.timeline, 'accepted_students_announced_deadline'):
       
   641       return self.reviewAfterDeadline(request, context, params, entity,
       
   642                                       **kwargs)
   632 
   643 
   633     # get the roles important for reviewing an application
   644     # get the roles important for reviewing an application
   634     filter = {'user': user_logic.logic.getForCurrentAccount(),
   645     filter = {'user': user_logic.logic.getForCurrentAccount(),
   635         'scope': entity.org,
   646         'scope': entity.org,
   636         'status': 'active'}
   647         'status': 'active'}
   748     choice = get_dict.get('mentor')
   759     choice = get_dict.get('mentor')
   749     if mentor and choice:
   760     if mentor and choice:
   750       self._adjustPossibleMentors(entity, mentor, choice)
   761       self._adjustPossibleMentors(entity, mentor, choice)
   751 
   762 
   752     ineligible = get_dict.get('ineligible')
   763     ineligible = get_dict.get('ineligible')
   753     
   764 
   754     if org_admin:
   765     if org_admin:
   755       reviewer = org_admin
   766       reviewer = org_admin
   756     elif mentor:
   767     elif mentor:
   757       reviewer = mentor
   768       reviewer = mentor
   758     
   769 
   759     if (org_admin or mentor) and ineligible != None:
   770     if (org_admin or mentor) and (ineligible != None) and (
       
   771         entity.status not in ['accepted', 'rejected']):
   760       ineligible = int(ineligible)
   772       ineligible = int(ineligible)
   761       if ineligible == 1:
   773       if ineligible == 1:
   762         # mark the proposal invalid and return to the list
   774         # mark the proposal invalid and return to the list
   763         properties = {'status': 'invalid'}
   775         properties = {'status': 'invalid'}
   764         self._logic.updateEntityProperties(entity, properties)
   776         self._logic.updateEntityProperties(entity, properties)
   862     # get all the extra information that should be in the context
   874     # get all the extra information that should be in the context
   863     review_context = self._getDefaultReviewContext(entity, org_admin, mentor)
   875     review_context = self._getDefaultReviewContext(entity, org_admin, mentor)
   864     context = dicts.merge(context, review_context)
   876     context = dicts.merge(context, review_context)
   865 
   877 
   866     template = params['review_template']
   878     template = params['review_template']
       
   879 
       
   880     return responses.respond(request, template, context=context)
       
   881 
       
   882   def reviewAfterDeadline(self,request, context, params, entity,**kwargs):
       
   883     """View that shows the review view after the accepted students announced deadline.
       
   884 
       
   885     For Args see base.View.public().
       
   886     """
       
   887 
       
   888     review_context = self._getDefaultReviewContext(entity, None, None)
       
   889     context = dicts.merge(context, review_context)
       
   890 
       
   891     template = params['review_after_deadline_template']
   867 
   892 
   868     return responses.respond(request, template, context=context)
   893     return responses.respond(request, template, context=context)
   869 
   894 
   870   def _getDefaultReviewContext(self, entity, org_admin,
   895   def _getDefaultReviewContext(self, entity, org_admin,
   871                                mentor):
   896                                mentor):