# -*- encoding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
-from project.rh.models import Poste
+from project.rh.models import Poste, Employe
def flag_vacant():
p.vacant = vacant
p.save()
+def flag_nb_postes():
+ """
+ """
+ for e in Employe.objects.all():
+ total = 0
+ test = e.nb_postes
+ for d in e.rh_dossiers.all():
+ if d.date_fin is None:
+ total +=1
+ if test != total:
+ e.nb_postes = total
+ e.save()
+
class Command(BaseCommand):
def handle(self, *args, **options):
+
if args[0] == "vacant":
flag_vacant()
self.stdout.write("Flag vacant mis à jour\n")
+
+ if args[0] == "nb_postes":
+ flag_nb_postes()
+ self.stdout.write("Flag nb_postes mis à jour\n")