From 1dd2d51f7ff20686605fd41c8a4bd49daed938fd Mon Sep 17 00:00:00 2001 From: Nilovna Bascunan-Vasquez Date: Fri, 29 Jul 2011 15:59:01 -0400 Subject: [PATCH] =?utf8?q?Lors=20de=20l'ajout=20d'un=20candidat,=20cr=C3=A9e?= =?utf8?q?r=20automatiquement=20une=20EvaluationCandidat,=20si=20l'offre=20d?= =?utf8?q?'emploi=20a=20d=C3=A9j=C3=A0=20des=20=C3=A9valuateurs=20assign=C3=A9?= =?utf8?q?s.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- project/recrutement/forms.py | 2 +- src/auf.django.emploi/auf/django/emploi/models.py | 24 +++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/project/recrutement/forms.py b/project/recrutement/forms.py index 1c45df4..2392045 100644 --- a/project/recrutement/forms.py +++ b/project/recrutement/forms.py @@ -73,7 +73,7 @@ class OffreEmploiForm(ModelForm): if date_limite and debut_affectation: if date_limite > debut_affectation: - raise forms.ValidationError("La date limite ne peut être \ + raise forms.ValidationError("La date limite ne peut pas être \ supérieure à la date d'affection.") return cleaned_data diff --git a/src/auf.django.emploi/auf/django/emploi/models.py b/src/auf.django.emploi/auf/django/emploi/models.py index ebf2237..ffda33d 100755 --- a/src/auf.django.emploi/auf/django/emploi/models.py +++ b/src/auf.django.emploi/auf/django/emploi/models.py @@ -133,15 +133,31 @@ class Candidat(Metadata): pays = models.ForeignKey(ref.Pays, db_column='pays', related_name='+') - def __unicode__(self): - return '%s %s [%s]' % (self.nom, self.prenom, self.id) + class Meta: + db_table = 'emploi_candidat' + + def save(self, *args, **kwargs): + """ + Créer automatiquement des CandidatEvaluation, si des évaluateurs sont + déjà assignés à des offres d'emploi + """ + evaluateurs = OffreEmploi.objects.filter(id=self.offre_emploi.id) + + for evaluateur in evaluateurs: + candidat_evaluation = CandidatEvaluation() + candidat_evaluation.candidat = self + candidat_evaluation.evaluateur = evaluateur + candidat_evaluation.save() + super(Candidat, self).save(*args, **kwargs) + def pieces_jointes(self): return CandidatPiece.objects.filter(candidat=self) pieces_jointes.allow_tags = True - class Meta: - db_table = 'emploi_candidat' + def __unicode__(self): + return '%s %s [%s]' % (self.nom, self.prenom, self.id) + # Upload de fichiers storage_prive = FileSystemStorage(settings.PRIVE_MEDIA_ROOT, -- 1.7.10.4