Browse Source

add page to view services users

devel
Dmitry Novikov 7 years ago
parent
commit
881d7f8c40
  1. 2
      install/install_debian.sh
  2. 97
      tariff_app/locale/ru/LC_MESSAGES/django.po
  3. 52
      tariff_app/templates/tariff_app/service_users.html
  4. 6
      tariff_app/templates/tariff_app/tarifs.html
  5. 1
      tariff_app/urls.py
  6. 43
      tariff_app/views.py

2
install/install_debian.sh

@ -48,7 +48,7 @@ find . -type d \( -path ./venv -o -path ./src -o -path ./.git \) -prune -o -type
# files # files
find . -type d \( -path ./venv -o -path ./src -o -path ./.git \) -prune -o -type f -exec chmod 640 {} \; find . -type d \( -path ./venv -o -path ./src -o -path ./.git \) -prune -o -type f -exec chmod 640 {} \;
# exec scripts # exec scripts
chmod 750 dhcp_lever.py manage.py periodic.py devapp/expect_scripts/dlink_DGS1100_reboot.exp
chmod 750 dhcp_lever.py manage.py periodic.py devapp/expect_scripts/dlink_DGS1100_reboot.exp agent/netflow/netflow_handler.py
chmod 400 djing/settings.py chmod 400 djing/settings.py
rm /etc/nginx/sites-enabled/default rm /etc/nginx/sites-enabled/default

97
tariff_app/locale/ru/LC_MESSAGES/django.po

@ -1,5 +1,3 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package. # This file is distributed under the same license as the PACKAGE package.
# Dmitry Novikov nerosketch@gmail.com, 2017. # Dmitry Novikov nerosketch@gmail.com, 2017.
# #
@ -8,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-08-09 15:01+0300\n"
"POT-Creation-Date: 2019-04-05 17:02+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Dmitry Novikov nerosketch@gmail.com\n" "Last-Translator: Dmitry Novikov nerosketch@gmail.com\n"
"Language: ru\n" "Language: ru\n"
@ -47,15 +45,15 @@ msgstr "Название тарифа"
msgid "Service description" msgid "Service description"
msgstr "Описание тарифа" msgstr "Описание тарифа"
#: models.py:20 templates/tariff_app/tarifs.html:18
#: models.py:20 templates/tariff_app/tarifs.html:17
msgid "Speed In" msgid "Speed In"
msgstr "Входящая скорость" msgstr "Входящая скорость"
#: models.py:21 templates/tariff_app/tarifs.html:24
#: models.py:21 templates/tariff_app/tarifs.html:23
msgid "Speed Out" msgid "Speed Out"
msgstr "Исходящая скорость" msgstr "Исходящая скорость"
#: models.py:22 templates/tariff_app/tarifs.html:30
#: models.py:22 templates/tariff_app/tarifs.html:29
msgid "Price" msgid "Price"
msgstr "Стоимость" msgstr "Стоимость"
@ -73,7 +71,8 @@ msgstr "Услуга"
#: models.py:56 templates/tariff_app/ext.html:7 #: models.py:56 templates/tariff_app/ext.html:7
#: templates/tariff_app/ext.html:12 templates/tariff_app/ext.html:21 #: templates/tariff_app/ext.html:12 templates/tariff_app/ext.html:21
#: templates/tariff_app/periodic_pays/add_edit.html:8
#: templates/tariff_app/periodic_pays/add_edit.html:7
#: templates/tariff_app/service_users.html:7
msgid "Services" msgid "Services"
msgstr "Тарифы" msgstr "Тарифы"
@ -93,56 +92,56 @@ msgstr "Алгоритм расчёта"
msgid "Total amount" msgid "Total amount"
msgstr "Стоимость" msgstr "Стоимость"
#: models.py:106
#: models.py:103
msgid "Periodic pay" msgid "Periodic pay"
msgstr "Периодический платёж" msgstr "Периодический платёж"
#: models.py:107 templates/tariff_app/ext.html:28
#: models.py:104 templates/tariff_app/ext.html:28
msgid "Periodic pays" msgid "Periodic pays"
msgstr "Периодические платежи" msgstr "Периодические платежи"
#: templates/tariff_app/editTarif.html:8
#: templates/tariff_app/editTarif.html:7
msgid "Tarifs" msgid "Tarifs"
msgstr "Тарифы" msgstr "Тарифы"
#: templates/tariff_app/editTarif.html:11
#: templates/tariff_app/editTarif.html:10
#: templates/tariff_app/periodic_pays/list.html:50 #: templates/tariff_app/periodic_pays/list.html:50
#: templates/tariff_app/tarifs.html:78
#: templates/tariff_app/tarifs.html:83
msgid "Add" msgid "Add"
msgstr "Добавить" msgstr "Добавить"
#: templates/tariff_app/editTarif.html:13
#: templates/tariff_app/editTarif.html:22
#: templates/tariff_app/editTarif.html:12
#: templates/tariff_app/editTarif.html:21
#: templates/tariff_app/periodic_pays/list.html:17 #: templates/tariff_app/periodic_pays/list.html:17
msgid "Edit" msgid "Edit"
msgstr "Редактировать" msgstr "Редактировать"
#: templates/tariff_app/editTarif.html:22 templates/tariff_app/tarifs.html:65
#: templates/tariff_app/editTarif.html:21 templates/tariff_app/tarifs.html:70
msgid "Create" msgid "Create"
msgstr "Создать" msgstr "Создать"
#: templates/tariff_app/editTarif.html:22 templates/tariff_app/tarifs.html:12
#: templates/tariff_app/editTarif.html:21 templates/tariff_app/tarifs.html:11
msgid "tariff" msgid "tariff"
msgstr "тариф" msgstr "тариф"
#: templates/tariff_app/editTarif.html:51
#: templates/tariff_app/periodic_pays/add_edit.html:47
#: templates/tariff_app/editTarif.html:50
#: templates/tariff_app/periodic_pays/add_edit.html:46
msgid "Save" msgid "Save"
msgstr "Сохранить" msgstr "Сохранить"
#: templates/tariff_app/editTarif.html:54
#: templates/tariff_app/editTarif.html:53
msgid "Reset" msgid "Reset"
msgstr "Сбросить" msgstr "Сбросить"
#: templates/tariff_app/periodic_pays/add_edit.html:10
#: templates/tariff_app/periodic_pays/add_edit.html:9
msgid "Change periodic pay" msgid "Change periodic pay"
msgstr "Может редактировать периодический платёж" msgstr "Может редактировать периодический платёж"
#: templates/tariff_app/periodic_pays/add_edit.html:12
#: templates/tariff_app/periodic_pays/add_edit.html:11
msgid "Add new periodic pay" msgid "Add new periodic pay"
msgstr "Добавить периодический платёж" msgstr "Добавить периодический платёж"
#: templates/tariff_app/periodic_pays/add_edit.html:32
#: templates/tariff_app/periodic_pays/add_edit.html:31
msgid "Pay details" msgid "Pay details"
msgstr "Подробности платежа" msgstr "Подробности платежа"
@ -150,6 +149,28 @@ msgstr "Подробности платежа"
msgid "The list is empty" msgid "The list is empty"
msgstr "Список пуст" msgstr "Список пуст"
#: templates/tariff_app/service_users.html:8
msgid "Service users"
msgstr "Пользователи услуг"
#: templates/tariff_app/service_users.html:13
#, python-format
msgid "'%(service_name)s' tariff users"
msgstr "Пользователи услуги '%(service_name)s'"
#: templates/tariff_app/service_users.html:14
msgid "Total:"
msgstr "Всего"
#: templates/tariff_app/service_users.html:25
#: templates/tariff_app/service_users.html:31
msgid "Username"
msgstr "Логин"
#: templates/tariff_app/service_users.html:46
msgid "Customers that uses this service not found."
msgstr "Не найдены абоненты использующие эту услугу."
#: templates/tariff_app/tariff_confirm_delete.html:9 #: templates/tariff_app/tariff_confirm_delete.html:9
msgid "Delete service" msgid "Delete service"
msgstr "Удалить тарифный план" msgstr "Удалить тарифный план"
@ -167,46 +188,34 @@ msgstr ""
"сразу потеряют услугу по этому тарифу. Так что сначала убедитесь что уже " "сразу потеряют услугу по этому тарифу. Так что сначала убедитесь что уже "
"никто не пользуется тарифом, и только после этого удалите его." "никто не пользуется тарифом, и только после этого удалите его."
#: templates/tariff_app/tarifs.html:33
msgid "Users count"
msgstr "Кол. пользователей"
#: templates/tariff_app/tarifs.html:51 #: templates/tariff_app/tarifs.html:51
msgid "currency" msgid "currency"
msgstr "руб." msgstr "руб."
#: templates/tariff_app/tarifs.html:63
#: templates/tariff_app/tarifs.html:68
msgid "Services does not exist yet" msgid "Services does not exist yet"
msgstr "Ещё нет созданных тарифов" msgstr "Ещё нет созданных тарифов"
#: views.py:44
#: views.py:60
msgid "Service has been saved" msgid "Service has been saved"
msgstr "Тариф успешно сохранён" msgstr "Тариф успешно сохранён"
#: views.py:47 views.py:103
#: views.py:63 views.py:123
msgid "Some fields were filled incorrect, please try again" msgid "Some fields were filled incorrect, please try again"
msgstr "Не все поля заполнены правильно, проверте и попробуйте ещё раз" msgstr "Не все поля заполнены правильно, проверте и попробуйте ещё раз"
#: views.py:66
#: views.py:86
msgid "Service has been deleted" msgid "Service has been deleted"
msgstr "Тарифный план успешно удалён" msgstr "Тарифный план успешно удалён"
#: views.py:97
#: views.py:117
msgid "New periodic pay successfully created" msgid "New periodic pay successfully created"
msgstr "Новый периодический платёж создан" msgstr "Новый периодический платёж создан"
#: views.py:99
#: views.py:119
msgid "Periodic pay has been changed" msgid "Periodic pay has been changed"
msgstr "Периодический платёж изменён" msgstr "Периодический платёж изменён"
msgid "Attention"
msgstr "Внимание"
msgid "Delete"
msgstr "Удалить"
msgid "Not have a confirmations of delete"
msgstr "Нет подтверждения удаления"
msgid ""
"Service with this Speed In, Speed Out, Price and Script already exists."
msgstr "Услуга с такой скоростью, ценой и логикой уже есть"
msgid "Users count"
msgstr "Кол. пользователей"

52
tariff_app/templates/tariff_app/service_users.html

@ -0,0 +1,52 @@
{% extends 'base.html' %}
{% load i18n dpagination %}
{% block breadcrumb %}
<ol class="breadcrumb">
<li><span class="glyphicon glyphicon-home"></span></li>
<li><a href="{% url 'tarifs:home' %}">{% trans 'Services' %}</a></li>
<li class="active">{% trans 'Service users' %}</li>
</ol>
{% endblock %}
{% block page-header %}
{% blocktrans with service_name=tariff.title %}'{{ service_name }}' tariff users{% endblocktrans %}.
<span class="small">{% trans 'Total:' %} {{ total }}</span>
{% endblock %}
{% block main %}
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>
<a href="{% url 'tarifs:service_users' tariff.id %}?{% url_order_by request order_by='username' %}">
{% trans 'Username' %}
</a>
{% if order_by == 'username' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
</th>
<th>
<a href="{% url 'tarifs:service_users' tariff.id %}?{% url_order_by request order_by='fio' %}">
{% trans 'Username' %}
</a>
{% if order_by == 'fio' %}<span class="glyphicon glyphicon-filter"></span>{% endif %}
</th>
<th width="50">#</th>
</tr>
</thead>
<tbody>
{% for customer in object_list %}
<tr>
<td><a href="{{ customer.get_absolute_url }}">{{ customer.username }}</a></td>
<td>{{ customer.fio }}</td>
</tr>
{% empty %}
<tr>
<td colspan="3">{% trans 'Customers that uses this service not found.' %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

6
tariff_app/templates/tariff_app/tarifs.html

@ -49,7 +49,11 @@
<td>{{ tar.speedIn }}</td> <td>{{ tar.speedIn }}</td>
<td>{{ tar.speedOut }}</td> <td>{{ tar.speedOut }}</td>
<td>{{ tar.amount }} {% trans 'currency' %}</td> <td>{{ tar.amount }} {% trans 'currency' %}</td>
<td>{{ tar.usercount }}</td>
<td>
{% if tar.usercount > 0 %}
<a href="{% url 'tariff_app:service_users' tar.pk %}">{{ tar.usercount }}</a>
{% else %}0{% endif %}
</td>
<td>{{ tar.get_calc_type_display }}</td> <td>{{ tar.get_calc_type_display }}</td>
<td> <td>
{% if can_del_trf %} {% if can_del_trf %}

1
tariff_app/urls.py

@ -7,6 +7,7 @@ app_name = 'tariff_app'
urlpatterns = [ urlpatterns = [
path('', views.TariffsListView.as_view(), name='home'), path('', views.TariffsListView.as_view(), name='home'),
path('<int:tarif_id>/', views.edit_tarif, name='edit'), path('<int:tarif_id>/', views.edit_tarif, name='edit'),
path('<int:tarif_id>/users/', views.ServiceUsers.as_view(), name='service_users'),
path('add/', views.edit_tarif, name='add'), path('add/', views.edit_tarif, name='add'),
path('del/<int:tid>/', views.TariffDeleteView.as_view(), name='del'), path('del/<int:tid>/', views.TariffDeleteView.as_view(), name='del'),

43
tariff_app/views.py

@ -1,7 +1,7 @@
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.db.models import Count from django.db.models import Count
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.shortcuts import render, get_object_or_404, redirect from django.shortcuts import render, get_object_or_404, redirect
from django.contrib import messages from django.contrib import messages
@ -10,6 +10,8 @@ from django.views.generic import DeleteView
from guardian.decorators import permission_required_or_403 as permission_required from guardian.decorators import permission_required_or_403 as permission_required
from djing.global_base_views import OrderedFilteredList from djing.global_base_views import OrderedFilteredList
from djing.lib.mixins import LoginAdminMixin
from abonapp.models import Abon
from .models import Tariff, PeriodicPay from .models import Tariff, PeriodicPay
from djing import lib from djing import lib
from djing.lib.decorators import only_admins from djing.lib.decorators import only_admins
@ -19,12 +21,11 @@ from . import forms
login_decs = login_required, only_admins login_decs = login_required, only_admins
@method_decorator(login_decs, name='dispatch')
@method_decorator(permission_required('tariff_app.view_tariff'), name='dispatch')
class TariffsListView(OrderedFilteredList):
class TariffsListView(LoginAdminMixin, PermissionRequiredMixin, OrderedFilteredList):
""" """
Show Services(Tariffs) list Show Services(Tariffs) list
""" """
permission_required = 'tariff_app.view_tariff'
template_name = 'tariff_app/tarifs.html' template_name = 'tariff_app/tarifs.html'
context_object_name = 'tariflist' context_object_name = 'tariflist'
model = Tariff model = Tariff
@ -69,9 +70,8 @@ def edit_tarif(request, tarif_id=0):
}) })
@method_decorator(login_decs, name='dispatch')
@method_decorator(permission_required('tariff_app.delete_tariff'), name='dispatch')
class TariffDeleteView(DeleteView):
class TariffDeleteView(LoginAdminMixin, PermissionRequiredMixin, DeleteView):
permission_required = 'tariff_app.delete_tariff'
model = Tariff model = Tariff
pk_url_kwarg = 'tid' pk_url_kwarg = 'tid'
success_url = reverse_lazy('tarifs:home') success_url = reverse_lazy('tarifs:home')
@ -91,9 +91,8 @@ class TariffDeleteView(DeleteView):
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)
@method_decorator(login_decs, name='dispatch')
@method_decorator(permission_required('tariff_app.view_periodicpay'), name='dispatch')
class PeriodicPaysListView(OrderedFilteredList):
class PeriodicPaysListView(LoginAdminMixin, PermissionRequiredMixin, OrderedFilteredList):
permission_required = 'tariff_app.view_periodicpay'
context_object_name = 'pays' context_object_name = 'pays'
model = PeriodicPay model = PeriodicPay
template_name = 'tariff_app/periodic_pays/list.html' template_name = 'tariff_app/periodic_pays/list.html'
@ -129,3 +128,27 @@ def periodic_pay(request, pay_id=0):
'pay_instance': pay_inst, 'pay_instance': pay_inst,
'form': frm 'form': frm
}) })
class ServiceUsers(LoginAdminMixin, OrderedFilteredList):
template_name = 'tariff_app/service_users.html'
model = Abon
def get_queryset(self):
tarif_id = self.kwargs.get('tarif_id')
return Abon.objects.filter(current_tariff__tariff__id=tarif_id).select_related('group')
def get_context_data(self, **kwargs):
if hasattr(self, 'tariff'):
tariff = getattr(self, 'tariff')
else:
tarif_id = self.kwargs.get('tarif_id')
tariff = get_object_or_404(Tariff, pk=tarif_id)
setattr(self, 'tariff', tariff)
self.tariff = tariff
context = {
'tariff': tariff,
'total': self.object_list.count()
}
context.update(kwargs)
return super().get_context_data(**context)
Loading…
Cancel
Save