diff --git a/agent/mod_mikrotik.py b/agent/mod_mikrotik.py index 469d67f..a29173f 100644 --- a/agent/mod_mikrotik.py +++ b/agent/mod_mikrotik.py @@ -405,7 +405,11 @@ class MikrotikTransmitter(BaseTransmitter, ApiRos, metaclass=type('_ABC_Lazy_mcs def remove_user(self, user: AbonStruct): self.remove_queue(user) - firewall_ip_list_ids = (self.find_ip(ip, LIST_USERS_ALLOWED).get('=.id') for ip in user.ips) + def _finder(ips): + for ip in ips: + r = self.find_ip(ip, LIST_USERS_ALLOWED) + if r: yield r.get('=.id') + firewall_ip_list_ids = _finder(user.ips) self.remove_ip_range(firewall_ip_list_ids) def update_user(self, user: AbonStruct, *args): diff --git a/tariff_app/locale/ru/LC_MESSAGES/django.po b/tariff_app/locale/ru/LC_MESSAGES/django.po index 8815cb3..63a500a 100644 --- a/tariff_app/locale/ru/LC_MESSAGES/django.po +++ b/tariff_app/locale/ru/LC_MESSAGES/django.po @@ -211,3 +211,6 @@ msgstr "Нет подтверждения удаления" msgid "" "Service with this Speed In, Speed Out, Price and Script already exists." msgstr "Услуга с такой скоростью, ценой и логикой уже есть" + +msgid "Users count" +msgstr "Кол. пользователей" \ No newline at end of file diff --git a/tariff_app/templates/tariff_app/tarifs.html b/tariff_app/templates/tariff_app/tarifs.html index 76cd346..c564035 100644 --- a/tariff_app/templates/tariff_app/tarifs.html +++ b/tariff_app/templates/tariff_app/tarifs.html @@ -31,6 +31,7 @@ {% if order_by == 'amount' %}{% endif %} + {% trans 'Users count' %} {% trans 'Script' %} # @@ -49,6 +50,7 @@ {{ tar.speedIn }} {{ tar.speedOut }} {{ tar.amount }} {% trans 'currency' %} + {{ tar.usercount }} {{ tar.get_calc_type_display }} {% if can_del_trf %} @@ -60,7 +62,7 @@ {% empty %} - {% trans 'Services does not exist yet' %}. + {% trans 'Services does not exist yet' %}. {% if perms.tariff_app.add_tariff %} {% trans 'Create' %} {% endif %} @@ -73,7 +75,7 @@ {% if perms.tariff_app.add_tariff %} - + {% trans 'Add' %} diff --git a/tariff_app/views.py b/tariff_app/views.py index 1ee6d62..0aa4abf 100644 --- a/tariff_app/views.py +++ b/tariff_app/views.py @@ -1,4 +1,5 @@ from django.contrib.auth.decorators import login_required +from django.db.models import Count from django.urls import reverse_lazy from django.utils.decorators import method_decorator from django.utils.translation import ugettext as _ @@ -22,6 +23,7 @@ class TariffsListView(OrderedFilteredList): template_name = 'tariff_app/tarifs.html' context_object_name = 'tariflist' model = Tariff + queryset = Tariff.objects.annotate(usercount=Count('linkto_tariff__abon')) @login_required