def test_find_before_mandate_state(self): self.assertEqual( len( find_before_mandate_state(self.mandate, reviewer_role.SUPERVISION)), 2) self.assertTrue(self.review1 in find_before_mandate_state( self.mandate, reviewer_role.SUPERVISION))
def test_should_consider_role_as_main_one_when_find_before_mandate_state_is_called_with_assistant_role( self): result = find_before_mandate_state(self.mandate, reviewer_role.SUPERVISION_ASSISTANT) self.assertQuerysetEqual( result, [self.research_review, self.supervision_review], lambda obj: obj)
def get_reviews_for_mandate(current_user_role, mandate, style): data = generate_headers( ['reviewer', 'review', 'remark', 'justification', 'confidential'], style) if current_user_role is user_role.ADMINISTRATOR: reviews = review.find_by_mandate(mandate.id) else: reviews = find_before_mandate_state(mandate, current_user_role) for rev in reviews: if rev.status == review_status.IN_PROGRESS: break if rev.reviewer is None: person = "{} {}<br/>({})".format( mandate.assistant.supervisor.first_name, mandate.assistant.supervisor.last_name, str(_('supervisor'))) else: person = "{} {}<br/>({})".format( rev.reviewer.person.first_name, rev.reviewer.person.last_name, entity_version.get_last_version(rev.reviewer.entity).acronym) data.append([ Paragraph(person, style), Paragraph(_(rev.advice), style), Paragraph(rev.remark or '', style), Paragraph(rev.justification or '', style), Paragraph(rev.confidential or '', style) ]) return data
def test_should_order_queryset_by_role(self): result = find_before_mandate_state(self.mandate, reviewer_role.VICE_RECTOR_ASSISTANT) self.assertQuerysetEqual(result, [ self.research_review, self.supervision_review, self.vice_rectore_assistant_review ], transform=lambda obj: obj)
def add_mandate_content(content, mandate, styles, current_user_role): content.append( create_paragraph( "%s (%s)" % (mandate.assistant.person, mandate.academic_year), get_administrative_data(mandate), styles['StandardWithBorder'] ) ) content.append(create_paragraph("%s" % (_('entities')), get_entities(mandate), styles['StandardWithBorder'])) content.append(create_paragraph("<strong>%s</strong>" % (_('absences')), get_absences(mandate), styles['StandardWithBorder'])) content.append(create_paragraph("<strong>%s</strong>" % (_('comment')), get_comment(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) if mandate.assistant_type == assistant_type.ASSISTANT: content.append(create_paragraph("%s" % (_('doctorate')), get_phd_data(mandate.assistant), styles['StandardWithBorder'])) content.append(create_paragraph("%s" % (_('research')), get_research_data(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) content.append(create_paragraph("%s<br />" % (_('tutoring_learning_units')), '', styles["BodyText"])) write_table(content, get_tutoring_learning_unit_year(mandate, styles['Tiny']), COLS_WIDTH_FOR_TUTORING) content.append(PageBreak()) content.append(create_paragraph("%s" % (_('representation_activities')), get_representation_activities(mandate), styles['StandardWithBorder'], " (%s)" % (_('hours_per_year')))) content.append(create_paragraph("%s" % (_('service_activities')), get_service_activities(mandate), styles['StandardWithBorder'], " (%s)" % (_('hours_per_year')))) content.append(create_paragraph("%s" % (_('formation_activities')), get_formation_activities(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) content.append(create_paragraph("%s" % (_('summary')), get_summary(mandate), styles['StandardWithBorder'])) content += [draw_time_repartition(mandate)] content.append(PageBreak()) if current_user_role is not user_role.ASSISTANT: content.append(create_paragraph("%s<br />" % (_('reviews')), '', styles["BodyText"])) if current_user_role is user_role.ADMINISTRATOR: reviews = review.find_by_mandate(mandate.id) else: reviews = find_before_mandate_state(mandate, current_user_role) for rev in reviews: if rev.status == review_status.IN_PROGRESS: break content.append(create_paragraph( str(_(rev.advice)), get_review_details_for_mandate(mandate, rev), styles['StandardWithBorder']) ) content.append(PageBreak())
def test_should_return_reviews_of_roles_with_less_or_equal_privilege(self): result = find_before_mandate_state(self.mandate, reviewer_role.SUPERVISION) self.assertQuerysetEqual( result, [self.research_review, self.supervision_review], lambda obj: obj)
def add_mandate_content(content: List[Union[Paragraph, PageBreak]], mandate: assistant_mandate.AssistantMandate, styles: StyleSheet1, current_user_roles: List[str]) -> None: content.append( create_paragraph( "%s (%s)" % (mandate.assistant.person, mandate.academic_year), get_administrative_data(mandate), styles['StandardWithBorder'])) content.append( create_paragraph("%s" % (_('Entities')), get_entities(mandate), styles['StandardWithBorder'])) content.append( create_paragraph("<strong>%s</strong>" % (_('Absences')), get_absences(mandate), styles['StandardWithBorder'])) content.append( create_paragraph("<strong>%s</strong>" % (_('Comment')), get_comment(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) if mandate.assistant_type == assistant_type.ASSISTANT: content.append( create_paragraph("%s" % (_('Ph.D.')), get_phd_data(mandate.assistant), styles['StandardWithBorder'])) content.append( create_paragraph("%s" % (_('Research')), get_research_data(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) content.append( create_paragraph("%s<br />" % (_('Course units')), '', styles["BodyText"])) write_table(content, get_tutoring_learning_unit_year(mandate, styles['Tiny']), COLS_WIDTH_FOR_TUTORING) content.append(PageBreak()) content.append( create_paragraph("%s" % (_('Representation activities at UCL')), get_representation_activities(mandate), styles['StandardWithBorder'], " (%s)" % (_('number of hours per year')))) content.append( create_paragraph("%s" % (_('Service activities')), get_service_activities(mandate), styles['StandardWithBorder'], " (%s)" % (_('number of hours per year')))) content.append( create_paragraph("%s" % (_('Training activities')), get_formation_activities(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) content.append( create_paragraph("%s" % (_('Summary')), get_summary(mandate), styles['StandardWithBorder'])) content += [draw_time_repartition(mandate)] content.append(PageBreak()) if user_role.ASSISTANT not in current_user_roles: content.append( create_paragraph("%s<br />" % (_('Opinions')), '', styles["BodyText"])) if user_role.ADMINISTRATOR in current_user_roles: reviews = review.find_by_mandate(mandate.id) else: reviews = find_before_mandate_state(mandate, current_user_roles) for rev in reviews: if rev.status == review_status.IN_PROGRESS: break content.append( create_paragraph(str(_(rev.advice)), get_review_details_for_mandate(mandate, rev), styles['StandardWithBorder'])) content.append(PageBreak())
def add_mandate_content(content, mandate, styles, current_user_role): content.append( create_paragraph( "%s (%s)" % (mandate.assistant.person, mandate.academic_year), get_administrative_data(mandate), styles['StandardWithBorder'])) content.append( create_paragraph("%s" % (_('entities')), get_entities(mandate), styles['StandardWithBorder'])) content.append( create_paragraph("<strong>%s</strong>" % (_('absences')), get_absences(mandate), styles['StandardWithBorder'])) content.append( create_paragraph("<strong>%s</strong>" % (_('comment')), get_comment(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) if mandate.assistant_type == assistant_type.ASSISTANT: content.append( create_paragraph("%s" % (_('doctorate')), get_phd_data(mandate.assistant), styles['StandardWithBorder'])) content.append( create_paragraph("%s" % (_('research')), get_research_data(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) content.append( create_paragraph("%s<br />" % (_('tutoring_learning_units')), '', styles["BodyText"])) write_table(content, get_tutoring_learning_unit_year(mandate, styles['Tiny']), COLS_WIDTH_FOR_TUTORING) content.append(PageBreak()) content.append( create_paragraph("%s" % (_('representation_activities')), get_representation_activities(mandate), styles['StandardWithBorder'], " (%s)" % (_('hours_per_year')))) content.append( create_paragraph("%s" % (_('service_activities')), get_service_activities(mandate), styles['StandardWithBorder'], " (%s)" % (_('hours_per_year')))) content.append( create_paragraph("%s" % (_('formation_activities')), get_formation_activities(mandate), styles['StandardWithBorder'])) content.append(PageBreak()) content.append( create_paragraph("%s" % (_('summary')), get_summary(mandate), styles['StandardWithBorder'])) content += [draw_time_repartition(mandate)] content.append(PageBreak()) if current_user_role is not user_role.ASSISTANT: content.append( create_paragraph("%s<br />" % (_('reviews')), '', styles["BodyText"])) if current_user_role is user_role.ADMINISTRATOR: reviews = review.find_by_mandate(mandate.id) else: reviews = find_before_mandate_state(mandate, current_user_role) for rev in reviews: if rev.status == review_status.IN_PROGRESS: break content.append( create_paragraph(str(_(rev.advice)), get_review_details_for_mandate(mandate, rev), styles['StandardWithBorder'])) content.append(PageBreak())