# -*- encoding: utf-8 -*-
import datetime
-from django.core.management.base import BaseCommand, CommandError
-from project.rh.models import Poste, Employe
+from django import forms
+from django.core.management.base import BaseCommand
+from project.rh.models import Poste, Employe, Dossier
def flag_vacant():
e.nb_postes = total
e.save()
+def check_employes():
+
+ for e in Employe.objects.all():
+ dossiers = e.rh_dossiers.all()
+ for d in dossiers:
+ try:
+ d.full_clean()
+ except Exception, e:
+ print "DOSSIER %s: %s" % (d.id, d)
+ for f, msgs in e.message_dict.items():
+ for m in msgs:
+ print "* %s: %s" % (f, m)
+ print ""
+
+ try:
+ d.poste.full_clean()
+ except Exception, e:
+ print "POSTE %s: %s" % (d.poste.id, d.poste)
+ for f, msgs in e.message_dict.items():
+ for m in msgs:
+ print "* %s: %s" % (f, m)
+ print ""
+
class Command(BaseCommand):
def handle(self, *args, **options):
+ if args[0] == "check_data":
+ check_employes()
+
if args[0] == "cron":
flag_vacant()
flag_nb_postes()