Commit fdeb4a72 authored by Élie Bouttier's avatar Élie Bouttier

ajout de préfix IP

parent a68e6794
......@@ -384,12 +384,16 @@ class ServiceAdmin(admin.ModelAdmin):
class IPPrefixAdmin(admin.ModelAdmin):
readonly_fields = ('prefix',)
def has_delete_permission(self, request, obj=None):
# Interdiction de supprimer le préfix s’il est assigné à une route
# Interdiction de supprimer le préfix s’il est assigné à un tunnel
return obj and obj.tunnel_set.exists()
def has_change_permission(self, request, obj=None):
if obj:
return False
else:
return True
# pour embêcher de by-passer le check has_delete_permission, on désactive l’action delete
def get_actions(self, request):
actions = super().get_actions(request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment