|
@@ -117,7 +117,8 @@ class ResourceAllocation(models.Model):
|
|
|
|
|
|
@property
|
|
|
def active(self):
|
|
|
- return ResourceAllocation.objects.filter(pk=self.pk).filter(get_active_filter()).exists()
|
|
|
+ now = timezone.now()
|
|
|
+ return self.start <= now and (self.end is None or self.end >= now)
|
|
|
|
|
|
def clean(self):
|
|
|
super().clean()
|
|
@@ -134,12 +135,6 @@ class ResourceAllocation(models.Model):
|
|
|
raise ValidationError("La période d’allocation de cette ressource chevauche "
|
|
|
"avec une période d’allocation précédente.")
|
|
|
|
|
|
- # Penser à appeler la méthode save !
|
|
|
- def deallocate(self):
|
|
|
- if not self.active:
|
|
|
- raise PermissionDenied
|
|
|
- self.end = timezone.now()
|
|
|
-
|
|
|
class Meta:
|
|
|
verbose_name = 'allocation'
|
|
|
verbose_name_plural = 'allocations'
|