217 mentor_review_form = dynaform.newDynaForm(dynamodel=None, |
217 mentor_review_form = dynaform.newDynaForm(dynamodel=None, |
218 dynabase=helper.forms.BaseForm, dynainclude=None, |
218 dynabase=helper.forms.BaseForm, dynainclude=None, |
219 dynaexclude=None, dynaproperties=dynaproperties) |
219 dynaexclude=None, dynaproperties=dynaproperties) |
220 params['mentor_review_form'] = mentor_review_form |
220 params['mentor_review_form'] = mentor_review_form |
221 |
221 |
222 # TODO see if autocomplete can be used for this field |
222 # TODO see if autocomplete can be used for mentor field |
223 dynafields = [ |
223 dynafields = [ |
|
224 {'name': 'rank', |
|
225 'base': forms.IntegerField, |
|
226 'label': 'Set to rank', |
|
227 'help_text': 'Set this proposal to the given rank (ignores the given score)', |
|
228 'min_value': 1, |
|
229 'required': False, |
|
230 'passthrough': ['min_value', 'required', 'help_text'], |
|
231 }, |
224 {'name': 'mentor', |
232 {'name': 'mentor', |
225 'base': forms.CharField, |
233 'base': forms.CharField, |
226 'label': 'Assign Mentor (Link ID)', |
234 'label': 'Assign Mentor (Link ID)', |
227 'required': False |
235 'required': False |
228 }, |
236 }, |
493 list_params['list_description'] = 'List of my %(name_plural)s' % list_params |
501 list_params['list_description'] = 'List of my %(name_plural)s' % list_params |
494 |
502 |
495 return self.list(request, access_type=access_type, page_name=page_name, |
503 return self.list(request, access_type=access_type, page_name=page_name, |
496 params=list_params, filter=filter, **kwargs) |
504 params=list_params, filter=filter, **kwargs) |
497 |
505 |
498 |
|
499 @decorators.merge_params |
506 @decorators.merge_params |
500 @decorators.check_access |
507 @decorators.check_access |
501 def review(self, request, access_type, |
508 def review(self, request, access_type, |
502 page_name=None, params=None, **kwargs): |
509 page_name=None, params=None, **kwargs): |
503 """View that allows Organization Admins and Mentors to review the proposal. |
510 """View that allows Organization Admins and Mentors to review the proposal. |
579 |
586 |
580 return self._constructResponse(request, entity=entity, context=context, |
587 return self._constructResponse(request, entity=entity, context=context, |
581 form=form, params=params, template=params['review_template']) |
588 form=form, params=params, template=params['review_template']) |
582 |
589 |
583 fields = form.cleaned_data |
590 fields = form.cleaned_data |
|
591 is_public = fields['public'] |
|
592 comment = fields['comment'] |
|
593 given_score = int(fields['score']) |
584 |
594 |
585 if org_admin: |
595 if org_admin: |
586 # org admin found, try to adjust the assigned mentor |
596 # org admin found, try to adjust the assigned mentor |
587 self._adjustMentor(entity, fields['mentor']) |
597 self._adjustMentor(entity, fields['mentor']) |
588 reviewer = org_admin |
598 reviewer = org_admin |
|
599 |
|
600 # try to see if the rank is given and adjust the given_score if needed |
|
601 rank = fields['rank'] |
|
602 if rank: |
|
603 ranker = self._logic.getRankerFor(entity) |
|
604 # if a very high rank is filled in use the highest one that returns a score |
|
605 rank = min(ranker.TotalRankedScores(), rank) |
|
606 # ranker uses zero-based ranking |
|
607 score_and_rank = ranker.FindScore(rank-1) |
|
608 # get the score at the requested rank |
|
609 score_at_rank = score_and_rank[0][0] |
|
610 # calculate the score that should be given to end up at the given rank |
|
611 given_score = score_at_rank - entity.score |
589 else: |
612 else: |
590 # might be None (if Host or Developer is commenting) |
613 # might be None (if Host or Developer is commenting) |
591 reviewer = mentor |
614 reviewer = mentor |
592 |
|
593 is_public = fields['public'] |
|
594 comment = fields['comment'] |
|
595 given_score = int(fields['score']) |
|
596 |
615 |
597 if reviewer and (not is_public) and (given_score is not 0): |
616 if reviewer and (not is_public) and (given_score is not 0): |
598 # if it is not a public comment and it's made by a member of the |
617 # if it is not a public comment and it's made by a member of the |
599 # organization we update the score of the proposal |
618 # organization we update the score of the proposal |
600 new_score = given_score + entity.score |
619 new_score = given_score + entity.score |