From 07b40eda67962f5e31772c02c6e70f2281355acd Mon Sep 17 00:00:00 2001 From: davin baragiotta Date: Fri, 29 Apr 2011 17:00:16 -0400 Subject: [PATCH] rh.models refact --- project/dae/models.py | 3 +-- project/rh/models.py | 68 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/project/dae/models.py b/project/dae/models.py index a26afc9..1e57a52 100644 --- a/project/dae/models.py +++ b/project/dae/models.py @@ -276,8 +276,7 @@ class Employe(models.Model): verbose_name='Employé') nom = models.CharField(max_length=255) prenom = models.CharField(max_length=255, verbose_name='Prénom') - genre = models.CharField(max_length=1, choices=GENRE_CHOICES, - null=True, blank=True) + genre = models.CharField(max_length=1, choices=GENRE_CHOICES) def __unicode__(self): return u'%s %s' % (self.prenom, self.nom) diff --git a/project/rh/models.py b/project/rh/models.py index dae2e18..1cc2d26 100644 --- a/project/rh/models.py +++ b/project/rh/models.py @@ -21,6 +21,21 @@ def dossier_piece_dispatch(instance, filename): path = "dossier/%s/%s" % (instance.dossier_id, filename) return path +# Commentaires +class Commentaire(models.Model): + texte = models.TextField() + # Méta + date_creation = models.DateTimeField(auto_now_add=True) + date_modification = models.DateField(auto_now=True) + owner = models.ForeignKey("auth.User") + actif = models.BooleanField() + + class Meta: + abstract = True + +# Constantes +HELP_TEXT_DATE = "format: aaaa-mm-jj" + ### POSTE @@ -33,7 +48,7 @@ class Poste(models.Model): # Identification id = models.IntegerField(primary_key=True) nom = models.CharField(verbose_name="Titre du poste", max_length=255) - # nom_feminin + nom_feminin = models.CharField(verbose_name="Titre du poste", max_length=255) implantation = models.ForeignKey(ref.Implantation) type_poste = models.ForeignKey(rh.TypePoste, null=True, related_name='+') service = models.ForeignKey(rh.Service, related_name='+', @@ -63,8 +78,10 @@ class Poste(models.Model): choices=POSTE_APPEL_CHOICES) # Rémunération - classement_min = models.ForeignKey(rh.Classement, related_name='+') - classement_max = models.ForeignKey(rh.Classement, related_name='+') + classement_min = models.ForeignKey(rh.Classement, related_name='+', + blank=True, null=True) + classement_max = models.ForeignKey(rh.Classement, related_name='+', + blank=True, null=True) valeur_point_min = models.ForeignKey(rh.ValeurPoint, related_name='+', blank=True, null=True) valeur_point_max = models.ForeignKey(rh.ValeurPoint, related_name='+', @@ -112,14 +129,14 @@ class Poste(models.Model): justification = models.TextField() # Méta - date_validation = models.DateTimeField() # provenance : dae + date_validation = models.DateTimeField(null=True, blank=True) # de dae date_creation = models.DateTimeField(auto_now_add=True) date_modification = models.DateTimeField(auto_now=True) date_debut = models.DateField(verbose_name="Date de début", - help_text="format: aaaa-mm-jj") + help_text=HELP_TEXT_DATE) date_fin = models.DateField(null=True, blank=True, verbose_name="Date de fin", - help_text="format: aaaa-mm-jj") + help_text=) actif = models.BooleanField(default=True) def __unicode__(self): @@ -154,6 +171,8 @@ class PostePiece(models.Model): upload_to=poste_piece_dispatch, storage=storage_prive) +class PosteCommentaire(Commentaire): + poste = models.ForeignKey("Poste") ### EMPLOYÉ/PERSONNE @@ -178,8 +197,7 @@ class Employe(models.Model): date_naissance = models.DateField(null=True, blank=True) # Infos personnelles - genre = models.CharField(max_length=1, null=True, blank=True, - choices=GENRE_CHOICES) + genre = models.CharField(max_length=1, choices=GENRE_CHOICES) situation_famille = models.CharField(max_length=1, null=True, blank=True, choices=SITUATION_CHOICES) date_entree = models.DateField(verbose_name="Date d'entrée à l'AUF", @@ -200,7 +218,6 @@ class Employe(models.Model): # Métas date_creation = models.DateField(auto_now_add=True) date_maj = models.DateField(auto_now=True) # date_modification - commentaire = models.TextField(null=True, blank=True) def __unicode__(self): return u'%s %s' % (self.prenom, self.nom) @@ -215,6 +232,8 @@ class EmployePiece(models.Model): upload_to=dossier_piece_dispatch, storage=storage_prive) +class EmployeCommentaire(Commentaire): + employe = models.ForeignKey("Employe") LIEN_PARENTE_CHOICES = ( ('Conjoint', 'Conjoint'), @@ -242,6 +261,8 @@ class AyantDroit(models.Model): commentaire = models.TextField(null=True, blank=True) actif = models.BooleanField() +class AyantDroitCommentaire(Commentaire): + ayant_droit = models.ForeignKey("AyantDroit") ### DOSSIER @@ -277,7 +298,8 @@ class Dossier(models.Model): choices=STATUT_RESIDENCE_CHOICES) # Rémunération - classement = models.ForeignKey(rh.Classement, related_name='+') + classement = models.ForeignKey(rh.Classement, related_name='+', + null=True, blank=True) regime_travail = models.DecimalField(max_digits=12, decimal_places=2, verbose_name="Régime de travail", help_text="% du temps complet") # default = 100 @@ -285,17 +307,23 @@ class Dossier(models.Model): decimal_places=2, verbose_name="Nb. heures par semaine") # default = 35 # Occupation du Poste par cet Employe (anciennement "mandat") - date_debut = models.DateField(verbose_name="Date de début d'occupation de poste") - date_fin = models.DateField(verbose_name="Date de fin d'occupation de poste", - null=True, blank=True) + date_debut = models.DateField(help_text=HELP_TEXT_DATE, + verbose_name="Date de début d'occupation de poste") + date_fin = models.DateField(help_text=HELP_TEXT_DATE, + null=True, blank=True, + verbose_name="Date de fin d'occupation de poste") + date_debut = models.DateField(verbose_name="Date de début", + help_text=HELP_TEXT_DATE) + date_fin = models.DateField(null=True, blank=True, + verbose_name="Date de fin", + help_text=HELP_TEXT_DATE) # Contrat # m2m Contrat # Méta date_creation = models.DateTimeField(auto_now_add=True) date_modification = models.DateField(auto_now=True) - commentaire = models.TextField(null=True, blank=True) def __unicode__(self): return u'%s - %s' % (self.poste.nom, self.employe) @@ -310,12 +338,10 @@ class DossierPiece(models.Model): upload_to=dossier_piece_dispatch, storage=storage_prive) -class DossierCommentaire(models.Model): +class DossierCommentaire(Commentaire): dossier = models.ForeignKey("Dossier") - commentaire = models.TextField(null=True, blank=True) - # Méta qui quand... -### RÉMUNÉRATION +### RÉMUNÉRATION class Remuneration(models.Model): # Identification @@ -330,7 +356,7 @@ class Remuneration(models.Model): montant = models.FloatField(null=True, blank=True) # Annuel (12 mois, 52 semaines, 364 jours) devise = models.ForeignKey('Devise', to_field='code', db_column='devise')#, #null=True, blank=True) - precision = models.CharField(max_length=255, null=True, blank=True) # precision = commentaire + commentaire = models.CharField(max_length=255, null=True, blank=True) # commentaire = precision date_debut = models.DateField(null=True, blank=True) # anciennement date_effectif #date_fin = null=True @@ -585,9 +611,9 @@ class ResponsableImplantation(models.Model): class Contrat(models.Model): dossier = models.ForeignKey("Dossier") # 1 contrat peut être dans plusieurs dossier Dossier.contrat = m2m Contrat type_contrat = models.ForeignKey('TypeContrat', related_name='+') - date_debut = models.DateField(help_text="format: aaaa-mm-jj") + date_debut = models.DateField(help_text=HELP_TEXT_DATE) date_fin = models.DateField(null=True, blank=True, - help_text="format: aaaa-mm-jj") + help_text=HELP_TEXT_DATE) class Evenement(models.Models): pass -- 1.7.10.4