Élie Bouttier 7 years ago
parent
commit
c23fa83c9f

+ 2 - 2
services/admin.py

@@ -84,9 +84,9 @@ class ActiveServiceFilter(admin.SimpleListFilter):
 
     def queryset(self, request, queryset):
         if self.value() == '0': # inactif
-            return queryset.filter(has_active_allocation=False)
+            return queryset.filter(has_active_allocations=False)
         if self.value() == '1': # actif
-            return queryset.filter(has_active_allocation=True)
+            return queryset.filter(has_active_allocations=True)
 
 
 class RouteFilter(admin.SimpleListFilter):

+ 3 - 3
services/models.py

@@ -77,13 +77,13 @@ class ActiveServiceManager(models.Manager):
     def get_queryset(self):
         qs = super().get_queryset()
         qs = qs.annotate(
-                    has_active_allocation=models.Case(
+                    has_active_allocations=models.Case(
                         models.When(get_active_filter('allocation'), then=True),
                         default=False,
                         output_field=models.BooleanField()
                     )
         )
-        qs = qs.order_by('pk', '-has_active_allocation').distinct() # complicated things here, do not touch if you're not sure
+        qs = qs.order_by('pk', '-has_active_allocations').distinct() # complicated things here, do not touch if you're not sure
         return qs
 
 
@@ -155,7 +155,7 @@ class Service(models.Model):
             raise ValidationError("Un service du même type existe déjà avec ce label.")
 
     def is_active(self):
-        return self.has_active_allocation
+        return self.has_active_allocations
     is_active.boolean = True
     is_active.short_description = 'Actif'
 

+ 2 - 2
services/templates/services/service_detail.html

@@ -6,7 +6,7 @@
 {% block corptab %}{% if service.adhesion != request.user.profile.adhesion %} active{% endif %}{% endblock %}
 
 {% block content %}
-<div class="panel panel-{{ service.active|yesno:"success,danger"}}">
+<div class="panel panel-{{ service.is_active|yesno:"success,danger"}}">
     <div class="panel-heading">
         <h3>{{ service.service_type }}</h3>
         {% if service.label %}
@@ -21,7 +21,7 @@
         {% else %}
         <p>Contribution : pas de contribution</p>
         {% endif %}
-        <p>Actif : {{ service.active|yesno:"oui,non" }}</p>
+        <p>Actif : {{ service.is_active|yesno:"oui,non" }}</p>
         <p>
             IP allouée{{ service.active_allocations.count|pluralize }} :
             {% for allocation in service.active_allocations %}

+ 2 - 2
services/templatetags/services.py

@@ -8,12 +8,12 @@ register = template.Library()
 
 @register.filter
 def active(services):
-    return services.filter(has_active_allocation=True)
+    return services.filter(has_active_allocations=True)
 
 
 @register.filter
 def inactive(services):
-    return services.filter(has_active_allocation=False)
+    return services.filter(has_active_allocations=False)
 
 
 @register.inclusion_tag('services/tags/deallocate_modal_div.html')