vacant filter
[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 test != vacant:
21 p.vacant = vacant
22 p.save()
23
24
25 class Command(BaseCommand):
26
27 def handle(self, *args, **options):
28 if args[0] == "vacant":
29 flag_vacant()
30 self.stdout.write("Flag vacant mis à jour\n")