def test_email_new_dissert(self): self.dissertation_test_email = DissertationFactory( author=self.student, title='Dissertation_test_email', education_group_year=self.education_group_year1, proposition_dissertation=self.proposition_dissertation, status='DRAFT', active=True, dissertation_role__adviser=self.teacher, dissertation_role__status=dissertation_role_status.PROMOTEUR) self.client.force_login(self.manager.person.user) count_messages_before_status_change = len( message_history.find_my_messages(self.teacher.person.id)) self.dissertation_test_email.go_forward() message_history_result = message_history.find_my_messages( self.teacher.person.id) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result)) self.assertNotEqual( message_template.find_by_reference( 'dissertation_adviser_new_project_dissertation_txt'), None) self.assertNotEqual( message_template.find_by_reference( 'dissertation_adviser_new_project_dissertation_html'), None) self.assertIn('Vous avez reçu une demande d\'encadrement de mémoire', message_history_result.last().subject)
def test_email_dissert_commission_accept_3(self): dissert = DissertationFactory( author=self.student, title='Dissertation_test_email', offer_year_start=self.offer_year_start2, proposition_dissertation=self.proposition_dissertation, status='COM_SUBMIT', active=True, dissertation_role__adviser=self.teacher, dissertation_role__status='PROMOTEUR') count_message_history_result_author = \ message_history.find_my_messages(dissert.author.person.id).count() count_message_history_result_promotor = \ message_history.find_my_messages(self.teacher.person.id).count() dissert.manager_accept() message_history_result_author_after_change = message_history.find_my_messages( dissert.author.person.id) message_history_result_promotor_after_change = message_history.find_my_messages( self.teacher.person.id) self.assertEqual(count_message_history_result_author + 1, len(message_history_result_author_after_change)) self.assertEqual(count_message_history_result_promotor, len(message_history_result_promotor_after_change)) self.assertIn( 'La commission Mémoires a accepté votre projet de mémoire', message_history_result_author_after_change.last().subject)
def test_go_forward_emails_new_dissert_2(self): count_messages_before_status_change = message_history.find_my_messages(self.teacher.person.id).count() self.dissertation_test_email.status = dissertation_status.DIR_KO self.dissertation_test_email.go_forward() message_history_result = message_history.find_my_messages(self.teacher.person.id) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result)) self.assertIsNotNone(message_template.find_by_reference('dissertation_adviser_new_project_dissertation_txt')) self.assertIsNotNone(message_template.find_by_reference('dissertation_adviser_new_project_dissertation_html')) self.assertIn('Vous avez reçu une demande d\'encadrement de mémoire', message_history_result.last().subject)
def test_email_new_dissert_accept(self): count_messages_before_status_change = message_history.find_my_messages( self.dissertation_test_email.author.person.id).count() self.dissertation_test_email.status = 'DIR_SUBMIT' self.dissertation_test_email.go_forward() self.dissertation_test_email.manager_accept() message_history_result_after = message_history.find_my_messages( self.dissertation_test_email.author.person.id) self.assertIn('Votre projet de mémoire est validé par votre promoteur', message_history_result_after.last().subject) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result_after))
def test_email_new_dissert_refuse(self): count_messages_before_status_change = message_history.find_my_messages( self.dissertation_test_email.author.person.id).count() self.dissertation_test_email.status = 'DIR_SUBMIT' self.dissertation_test_email.refuse() message_history_result = message_history.find_my_messages( self.dissertation_test_email.author.person.id) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result)) self.assertIn( 'Votre projet de mémoire n\'a pas été validé par votre promoteur', message_history_result.last().subject)
def test_refuse_DIR_SUBMIT(self): count_messages_before_status_change = message_history.find_my_messages(self.student.person.id).count() self.offer_prop2 = OfferPropositionFactory(education_group=self.education_group2, ) self.dissertation1 = DissertationFactory(status=dissertation_status.DIR_SUBMIT, education_group_year=self.education_group_year2, author=self.student) self.dissertation1.refuse() message_history_result = message_history.find_my_messages(self.student.person.id) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result)) self.assertEqual(self.dissertation1.status, dissertation_status.DIR_KO) self.assertIn('Votre projet de mémoire n\'a pas été validé par votre promoteur', message_history_result.last().subject)
def test_go_forward_emails_acknowledge(self): self.dissertation_test_email.status = dissertation_status.TO_RECEIVE count_message_history_author = message_history.find_my_messages( self.dissertation_test_email.author.person.id ).count() self.dissertation_test_email.go_forward() message_history_result_author_after_change = message_history.find_my_messages( self.dissertation_test_email.author.person.id ) count_message_history_result_author = len(message_history_result_author_after_change) self.assertEqual(count_message_history_author + 1, count_message_history_result_author) self.assertIn('bien été réceptionné', message_history_result_author_after_change.last().subject)
def test_teacher_accept_1(self): count_messages_before_status_change = message_history.find_my_messages(self.student.person.id).count() self.offer_prop2 = OfferPropositionFactory(education_group=self.education_group2, validation_commission_exists=True, evaluation_first_year=True) self.dissertation1 = DissertationFactory(status=dissertation_status.DIR_SUBMIT, education_group_year=self.education_group_year2, author=self.student) self.dissertation1.teacher_accept() message_history_result = message_history.find_my_messages(self.student.person.id) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result)) self.assertEqual(self.dissertation1.status, dissertation_status.COM_SUBMIT) self.assertIn('Votre projet de mémoire est validé par votre promoteur', message_history_result.last().subject)
def test_refuse_COM_SUBMIT(self): count_messages_before_status_change = message_history.find_my_messages(self.student.person.id).count() self.offer_prop2 = OfferPropositionFactory(education_group=self.education_group2, validation_commission_exists=True, evaluation_first_year=True) self.dissertation1 = DissertationFactory(status=dissertation_status.COM_SUBMIT, education_group_year=self.education_group_year2, author=self.student) self.dissertation1.refuse() message_history_result = message_history.find_my_messages(self.student.person.id) self.assertEqual(count_messages_before_status_change + 1, len(message_history_result)) self.assertEqual(self.dissertation1.status, dissertation_status.COM_KO) self.assertIn('n\'a pas validé', message_history_result.last().subject)
def test_email_dissert_commission_accept_2(self): count_message_history_result_author = message_history. \ find_my_messages(self.dissertation_test_email.author.person.id).count() count_message_history_result_promotor = len( message_history.find_my_messages(self.teacher.person.id)) self.dissertation_test_email.status = 'COM_SUBMIT' self.dissertation_test_email.manager_accept() message_history_result_author_after_change = message_history.find_my_messages( self.dissertation_test_email.author.person.id) message_history_result_promotor_after_change = message_history.find_my_messages( self.teacher.person.id) self.assertEqual(count_message_history_result_author + 1, len(message_history_result_author_after_change)) self.assertEqual(count_message_history_result_promotor + 1, len(message_history_result_promotor_after_change)) self.assertIn( 'La commission Mémoires a accepté le projet de Mémoire :', message_history_result_promotor_after_change.last().subject) self.assertIn( 'La commission Mémoires a accepté votre projet de mémoire', message_history_result_author_after_change.last().subject)
def my_messages_index(request): person = mdl.person.find_by_user(request.user) my_messages = message_history_mdl.find_my_messages(person.id) my_messages_formset = None if not my_messages: messages.add_message(request, messages.INFO, _('No Messages')) else: my_messages_formset = get_messages_formset(my_messages) return render( request, "my_osis/my_messages.html", { 'my_messages_formset': my_messages_formset, 'my_message_action_form': MyMessageActionForm() })
def my_messages_index(request): person = mdl.person.find_by_user(request.user) my_messages = message_history_mdl.find_my_messages(person.id) my_messages_formset = None if not my_messages: messages.add_message(request, messages.INFO, _('no_messages')) else: initial_formset_content = [{'selected': False, 'subject': message_hist.subject, 'created': message_hist.created, 'id': message_hist.id, 'read': message_hist.read_by_user } for message_hist in my_messages] my_messages_formset = formset_factory(MyMessageForm, extra=0)(initial=initial_formset_content) return layout.render(request, "my_osis/my_messages.html", { 'my_messages_formset': my_messages_formset, 'my_message_action_form': MyMessageActionForm() })