|
@@ -640,6 +640,10 @@ class RouteAdmin(admin.ModelAdmin):
|
|
|
return actions
|
|
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
|
+ if obj:
|
|
|
+ if obj.allocations.exists():
|
|
|
+ return False
|
|
|
+ return True
|
|
|
return False
|
|
|
|
|
|
|
|
@@ -649,6 +653,19 @@ class TunnelAdmin(admin.ModelAdmin):
|
|
|
ActiveTunnelFilter,
|
|
|
)
|
|
|
|
|
|
+ def get_actions(self, request):
|
|
|
+ actions = super().get_actions(request)
|
|
|
+ if 'delete_selected' in actions:
|
|
|
+ del actions['delete_selected']
|
|
|
+ return actions
|
|
|
+
|
|
|
+ def has_delete_permission(self, request, obj=None):
|
|
|
+ if obj:
|
|
|
+ if obj.allocations.exists():
|
|
|
+ return False
|
|
|
+ return True
|
|
|
+ return False
|
|
|
+
|
|
|
def active(self, obj):
|
|
|
return not obj.ended
|
|
|
active.short_description = 'Actif'
|