|
@@ -192,12 +192,6 @@ class AllocationInline(admin.TabularInline):
|
|
|
formset.request = request
|
|
|
return formset
|
|
|
|
|
|
- def get_max_num(self, request, obj=None, **kwargs):
|
|
|
- existing = obj.allocations.count() if obj else 0
|
|
|
- # pour simplifier la validation, on ajoute qu’une allocation à la fois
|
|
|
- # il faudrait surcharger la méthode clean du formset pour supprimer cette limite
|
|
|
- return existing + 1
|
|
|
-
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
|
return False
|
|
|
|
|
@@ -205,12 +199,19 @@ class AllocationInline(admin.TabularInline):
|
|
|
class ActiveAllocationMixin:
|
|
|
verbose_name_plural = 'Allocations actives'
|
|
|
|
|
|
+ def get_max_num(self, request, obj=None, **kwargs):
|
|
|
+ existing = obj.allocations.count() if obj else 0
|
|
|
+ # pour simplifier la validation, on ajoute qu’une allocation à la fois
|
|
|
+ # il faudrait surcharger la méthode clean du formset pour supprimer cette limite
|
|
|
+ return existing + 1
|
|
|
+
|
|
|
def get_queryset(self, request):
|
|
|
return super().get_queryset(request).filter(active=True)
|
|
|
|
|
|
|
|
|
class InactiveAllocationMixin:
|
|
|
verbose_name_plural = 'Anciennes allocations'
|
|
|
+ max_num = 0
|
|
|
|
|
|
def get_queryset(self, request):
|
|
|
return super().get_queryset(request).filter(active=False)
|