def get_next_status(dissert, operation):
    if operation == "go_forward":
        if dissert.status == 'DRAFT' or dissert.status == 'DIR_KO':
            return 'DIR_SUBMIT'

        elif dissert.status == 'TO_RECEIVE':
            return 'TO_DEFEND'

        elif dissert.status == 'TO_DEFEND':
            return 'DEFENDED'
        else:
            return dissert.status

    elif operation == "accept":

        offer_prop = get_object_or_none(
            OfferProposition,
            education_group=dissert.education_group_year.education_group)

        if offer_prop is None:
            return dissert.status

        if offer_prop.validation_commission_exists and dissert.status == 'DIR_SUBMIT':

            return 'COM_SUBMIT'

        elif offer_prop.evaluation_first_year and (
                dissert.status == 'DIR_SUBMIT' or dissert.status
                == 'COM_SUBMIT' or dissert.status == 'COM_KO'):
            return 'EVA_SUBMIT'

        elif offer_prop.evaluation_first_year and (dissert.status
                                                   == 'EVA_SUBMIT'):
            return 'TO_RECEIVE'

        elif dissert.status == 'DEFENDED':
            return 'ENDED_WIN'

        else:
            return 'TO_RECEIVE'

    elif operation == "refuse":
        if dissert.status == 'DIR_SUBMIT':
            return 'DIR_KO'

        elif dissert.status == 'COM_SUBMIT':
            return 'COM_KO'

        elif dissert.status == 'EVA_SUBMIT':
            return 'EVA_KO'

        elif dissert.status == 'DEFENDED':
            return 'ENDED_LOS'
        else:
            return dissert.status

    else:
        return dissert.status
Example #2
0
 def create(self, *args, **kwargs):
     master = get_object_or_none(
         InternshipMaster,
         person__email=self.validated_data['person']['email'])
     if not master:
         email = self.validated_data['person'].pop('email')
         person, created = Person.objects.get_or_create(
             email=email,
             defaults={
                 **self.validated_data['person'], 'source': INTERNSHIP
             })
         master = InternshipMaster(person=person,
                                   civility=self.validated_data['civility'])
         master.save()
     return master
 def manager_accept(self):
     if self.status == dissertation_status.DIR_SUBMIT:
         self.teacher_accept()
     elif self.status == dissertation_status.ENDED_LOS:
         self.set_status(dissertation_status.TO_RECEIVE)
     elif self.status == dissertation_status.COM_SUBMIT or self.status == dissertation_status.COM_KO:
         next_status = get_next_status(self, "accept")
         emails_dissert.send_email(self, 'dissertation_accepted_by_com',
                                   [self.author])
         if get_object_or_none(OfferProposition, education_group=self.education_group_year.education_group) \
                 .global_email_to_commission:
             emails_dissert.send_email_to_jury_members(self)
         self.set_status(next_status)
     elif self.status == dissertation_status.EVA_SUBMIT or \
             self.status == dissertation_status.EVA_KO or self.status == dissertation_status.DEFENDED:
         next_status = get_next_status(self, "accept")
         self.set_status(next_status)
Example #4
0
def _has_role(user, role):
    this_adviser = get_object_or_none(Adviser, person__user=user)
    return this_adviser.type == role if this_adviser else False
Example #5
0
 def test_get_object_or_none_error(self):
     with self.assertRaises(ValueError):
         get_object_or_none(None)
Example #6
0
 def test_get_object_or_none_does_not_exist(self):
     object = get_object_or_none(ModelWithoutUser, pk=None)
     self.assertIsNone(object)
Example #7
0
 def test_get_object_or_none_exists(self):
     model = ModelWithoutUser.objects.create(name='Dummy')
     object = get_object_or_none(ModelWithoutUser, pk=model.pk)
     self.assertEqual(object, model)
Example #8
0
def admission_getter(request, *view_args, **view_kwargs):
    return get_object_or_none(Admission.objects.select_related('formation'),
                              id=view_kwargs.get('admission_id'))