Browse Source

Simplify delete_atomic().

Hugo Lefeuvre 10 years ago
parent
commit
5bdc5b0238
2 changed files with 5 additions and 7 deletions
  1. 3 1
      coin/utils.py
  2. 2 6
      coin/vpn/admin.py

+ 3 - 1
coin/utils.py

@@ -68,8 +68,10 @@ def send_templated_email(subject, to, template_to_use, context, attachements, fr
     #Send email
     msg.send()
 
-def delete_atomic(modeladmin, request, queryset):
+def delete_selected(modeladmin, request, queryset):
     """Overrides QuerySet's delete() function to remove objects one by one 
     so, that they are deleted in the LDAP (Redmine issue #195)."""
     for obj in queryset:
         obj.delete()
+
+delete_selected.short_description = "Supprimer tous les objets sélectionnés."

+ 2 - 6
coin/vpn/admin.py

@@ -4,7 +4,7 @@ from polymorphic.admin import PolymorphicChildModelAdmin
 
 from coin.vpn.models import VPNConfiguration
 from coin.configuration.admin import ConfigurationAdminFormMixin
-from coin.utils import delete_atomic
+from coin.utils import delete_selected
 
 class VPNConfigurationInline(admin.StackedInline):
     model = VPNConfiguration
@@ -22,7 +22,7 @@ class VPNConfigurationAdmin(ConfigurationAdminFormMixin, PolymorphicChildModelAd
                      'administrative_subscription__member__first_name',
                      'administrative_subscription__member__last_name',
                      'administrative_subscription__member__email')
-    actions = ("delete_selected", "generate_endpoints", "generate_endpoints_v4",
+    actions = (delete_selected, "generate_endpoints", "generate_endpoints_v4",
                "generate_endpoints_v6", "activate", "deactivate")
     exclude = ("password",)
     inline = VPNConfigurationInline
@@ -33,10 +33,6 @@ class VPNConfigurationAdmin(ConfigurationAdminFormMixin, PolymorphicChildModelAd
         else:
             return []
 
-    def delete_selected(self, *args):
-        delete_atomic(*args)
-    delete_selected.short_description = "Supprimer tous les objets sélectionnés."
-
     def set_activation(self, request, queryset, value):
         count = 0
         # We must update each object individually, because we want to run