c5e6206e2b21f6fa398bc7fb4deddfb38ab47892
[auf_rh_dae.git] / project / rh / management / commands / rh.py
1 # -*- encoding: utf-8 -*-
2
3 from django.core.management.base import BaseCommand, CommandError
4 from project.rh.models import Poste
5
6
7 def flag_vacant():
8 """
9 Mettre a jour le booleen de poste pour savoir si le poste
10 est vacant.
11 """
12 for p in Poste.objects.all():
13 test = p.vacant
14 employes = p.occupe_par()
15 if len(employes) > 0:
16 vacant = False
17 else:
18 vacant = True
19
20 if p.actif is False:
21 vacant = None
22
23 if test != vacant:
24 p.vacant = vacant
25 p.save()
26
27
28 class Command(BaseCommand):
29
30 def handle(self, *args, **options):
31 if args[0] == "vacant":
32 flag_vacant()
33 self.stdout.write("Flag vacant mis à jour\n")