Browse Source

Add annotation by users of services

devel
Dmitry Novikov 8 years ago
parent
commit
97cc853e00
  1. 6
      agent/mod_mikrotik.py
  2. 3
      tariff_app/locale/ru/LC_MESSAGES/django.po
  3. 6
      tariff_app/templates/tariff_app/tarifs.html
  4. 2
      tariff_app/views.py

6
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):

3
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 "Кол. пользователей"

6
tariff_app/templates/tariff_app/tarifs.html

@ -31,6 +31,7 @@
</a>
{% if order_by == 'amount' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
</th>
<th>{% trans 'Users count' %}</th>
<th width="250">{% trans 'Script' %}</th>
<th width="50">#</th>
</tr>
@ -49,6 +50,7 @@
<td>{{ tar.speedIn }}</td>
<td>{{ tar.speedOut }}</td>
<td>{{ tar.amount }} {% trans 'currency' %}</td>
<td>{{ tar.usercount }}</td>
<td>{{ tar.get_calc_type_display }}</td>
<td>
{% if can_del_trf %}
@ -60,7 +62,7 @@
</tr>
{% empty %}
<tr>
<td colspan="6">{% trans 'Services does not exist yet' %}.
<td colspan="7">{% trans 'Services does not exist yet' %}.
{% if perms.tariff_app.add_tariff %}
<a href="{% url 'tarifs:add' %}" class="lgtbx">{% trans 'Create' %}</a>
{% endif %}
@ -73,7 +75,7 @@
{% if perms.tariff_app.add_tariff %}
<tfoot>
<tr>
<td colspan="6">
<td colspan="7">
<a href="{% url 'tarifs:add' %}" class="btn btn-sm btn-success">
<span class="glyphicon glyphicon-plus"></span> {% trans 'Add' %}
</a>

2
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

Loading…
Cancel
Save