Project

General

Profile

« Previous | Next » 

Revision 5b90c12e

Added by Serghei Mihai over 11 years ago

Group absences refactored

View differences:

calebasse/personnes/models.py
338 338
    def for_worker(self, worker):
339 339
        filter_query = models.Q(worker=worker) \
340 340
              | models.Q(worker__isnull=True,
341
                           service=None) \
341
                           services = None) \
342 342
              | models.Q(worker__isnull=True,
343
                           service__in=worker.services.all())
343
                           services__in = worker.services.all())
344 344
        return self.filter(filter_query)
345 345

  
346 346
    def for_worker_id(self, worker_id):
......
351 351
            return None
352 352
        filter_query = models.Q(worker=worker) \
353 353
              | models.Q(worker__isnull=True,
354
                           service=None) \
354
                           services = None) \
355 355
              | models.Q(worker__isnull=True,
356
                           service__in=worker.services.all())
356
                           services__in = worker.services.all())
357 357
        return self.filter(filter_query)
358 358

  
359 359
    def for_type(self, holiday_type):
360
        return self.filter(holiday_type=holiday_type)
360
        return self.filter(holiday_type = holiday_type)
361 361

  
362 362
    def for_service(self, service):
363
        return self.filter(worker__isnull=True) \
364
                   .filter(models.Q(service=service)
365
                          |models.Q(service__isnull=True))
363
        return self.filter(worker__isnull = True) \
364
                   .filter(models.Q(services = service)
365
                          |models.Q(services__isnull = True))
366 366

  
367 367
    def for_service_workers(self, service):
368
        return self.filter(models.Q(worker__services=service)
369
                |models.Q(service=service)
370
                |models.Q(worker__isnull=True, service__isnull=True))
368
        return self.filter(models.Q(worker__services = [service])
369
                |models.Q(services__in = [service])
370
                |models.Q(worker__isnull=True, services__isnull = True))
371 371

  
372 372
    def future(self):
373 373
        return self.filter(end_date__gte=date.today())
......
405 405
            verbose_name=u'Type de congé')
406 406
    worker = models.ForeignKey(Worker, blank=True, null=True,
407 407
            verbose_name=u"Personnel")
408
    service = models.ForeignKey(Service, blank=True, null=True,
409
            verbose_name=u"Service")
410
    services = models.ManyToManyField(Service, null = True, blank = True, related_name = 'new_services')
408
    services = models.ManyToManyField(Service, null = True,
409
                                      blank = True, verbose_name = u'Services')
411 410
    start_date = models.DateField(verbose_name=u"Date de début",
412 411
        help_text=u'format: jj/mm/aaaa')
413 412
    end_date = models.DateField(verbose_name=u"Date de fin",
......
426 425
    def is_current(self):
427 426
        return self.start_date <= date.today() <= self.end_date
428 427

  
428
    def for_all_services(self):
429
        return self.services.count() == Service.objects.count()
430

  
429 431
    def __unicode__(self):
430 432
        ret = ''
431 433
        if self.start_date == self.end_date:

Also available in: Unified diff