def test_send_mail_after_proposal_cancellation(self, mock_send_mail): proposal = self._create_proposal( prop_type=proposal_type.ProposalType.SUPPRESSION.name, prop_state=proposal_state.ProposalState.FACULTY.name) lu_proposal_business.cancel_proposal(proposal, author=PersonFactory(), send_mail=True) self.assertTrue(mock_send_mail.called)
def test_cancel_proposal_of_type_suppression_case_success(self): proposal = self._create_proposal( prop_type=proposal_type.ProposalType.SUPPRESSION.name, prop_state=proposal_state.ProposalState.FACULTY.name) lu_proposal_business.cancel_proposal(proposal) self.assertCountEqual( list( mdl_base.proposal_learning_unit.ProposalLearningUnit.objects. filter(learning_unit_year=self.learning_unit_year)), [])
def test_cancel_proposal_of_type_creation_case_success(self): proposal = self._create_proposal( prop_type=proposal_type.ProposalType.CREATION.name, prop_state=proposal_state.ProposalState.FACULTY.name) lu = proposal.learning_unit_year.learning_unit lu_proposal_business.cancel_proposal(proposal, PersonFactory()) self.assertCountEqual( list( mdl_base.proposal_learning_unit.ProposalLearningUnit.objects. filter(learning_unit_year=self.learning_unit_year)), []) self.assertCountEqual( list(mdl_base.learning_unit.LearningUnit.objects.filter(id=lu.id)), [])
def cancel_proposal_of_learning_unit(request, learning_unit_year_id): user_person = get_object_or_404(Person, user=request.user) learning_unit_proposal = get_object_or_404( ProposalLearningUnit, learning_unit_year=learning_unit_year_id) messages_by_level = business_proposal.cancel_proposal( learning_unit_proposal, author=user_person, send_mail=True) display_success_messages(request, messages_by_level[messages.SUCCESS]) display_error_messages(request, messages_by_level[messages.ERROR]) if LearningUnitYear.objects.filter(pk=learning_unit_year_id).exists(): return redirect('learning_unit', learning_unit_year_id=learning_unit_year_id) return redirect('learning_units_proposal')