Browse Source

Add button to view subscribers on device port

devel
bashmak 8 years ago
parent
commit
7528f1818a
  1. 9
      devapp/locale/ru/LC_MESSAGES/django.po
  2. 11
      devapp/templates/devapp/manage_ports/list.html
  3. 12
      devapp/templates/devapp/manage_ports/modal_show_subscriber_on_port.html
  4. 7
      devapp/urls.py
  5. 19
      devapp/views.py
  6. 17
      djing/urls.py
  7. 2
      static/js/my.js
  8. 38
      templates/404.html

9
devapp/locale/ru/LC_MESSAGES/django.po

@ -502,3 +502,12 @@ msgstr "Не доступно"
msgid "Down" msgid "Down"
msgstr "Не в сети" msgstr "Не в сети"
msgid "Subscriber on port"
msgstr "Абонент на порту"
msgid "Show subscriber on port"
msgstr "Показать абонента на порту"
msgid "Subscribers on port does not exist"
msgstr "Абоненты на порту не найдены"

11
devapp/templates/devapp/manage_ports/list.html

@ -8,10 +8,10 @@
<table class="table table-striped table-bordered"> <table class="table table-striped table-bordered">
<thead> <thead>
<tr> <tr>
<th width="50">{% trans 'Number' %}</th>
<th>{% trans 'Description' %}</th>
<th>{% trans 'Count of subscribers' %}</th>
<th width="100">#</th>
<th class="col-sm-1">{% trans 'Number' %}</th>
<th class="col-sm-5">{% trans 'Description' %}</th>
<th class="col-sm-5">{% trans 'Count of subscribers' %}</th>
<th class="col-sm-1">#</th>
</tr> </tr>
</thead> </thead>
@ -28,6 +28,9 @@
<td>{{ port.num_abons }}</td> <td>{{ port.num_abons }}</td>
{% endif %} {% endif %}
<td class="btn-group btn-group-sm"> <td class="btn-group btn-group-sm">
<a href="{% url 'devapp:show_subscriber_on_port' dev.user_group.id dev.id port.id %}" class="btn btn-default btn-modal" title="{% trans 'Show subscriber on port' %}" data-toggle="tooltip">
<span class="glyphicon glyphicon-eye-open"></span>
</a>
{% if can_del_port %} {% if can_del_port %}
<a href="{% url 'devapp:del_port' gid did port.pk %}" class="btn btn-danger btn-modal" title="{% trans 'Delete' %}"> <a href="{% url 'devapp:del_port' gid did port.pk %}" class="btn btn-danger btn-modal" title="{% trans 'Delete' %}">
<span class="glyphicon glyphicon-remove-circle"></span> <span class="glyphicon glyphicon-remove-circle"></span>

12
devapp/templates/devapp/manage_ports/modal_show_subscriber_on_port.html

@ -0,0 +1,12 @@
{% load i18n %}
<div class="modal-header primary">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"><span class="glyphicon glyphicon-exclamation-sign"></span>{% trans 'Subscriber on port' %}</h4>
</div>
<div class="modal-body">
<a href="{% url 'abonapp:abon_home' object.group.pk object.pk %}">
{{ object.get_full_name }}
</a>
</div>

7
devapp/urls.py

@ -1,10 +1,8 @@
from django.conf.urls import url from django.conf.urls import url
from . import views from . import views
app_name = 'devapp' app_name = 'devapp'
urlpatterns = [ urlpatterns = [
url(r'^$', views.group_list, name='group_list'), url(r'^$', views.group_list, name='group_list'),
url(r'^devices_without_groups$', views.devices_null_group, name='devices_null_group'), url(r'^devices_without_groups$', views.devices_null_group, name='devices_null_group'),
@ -16,7 +14,10 @@ urlpatterns = [
url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/add$', views.add_single_port, name='add_port'), url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/add$', views.add_single_port, name='add_port'),
url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/edit$', views.dev, name='edit'), url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/edit$', views.dev, name='edit'),
url(r'^(\d+)/(?P<device_id>\d+)/ports$', views.manage_ports, name='manage_ports'), url(r'^(\d+)/(?P<device_id>\d+)/ports$', views.manage_ports, name='manage_ports'),
url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/ports/(?P<port_id>\d+)/fix_port_conflict$', views.fix_port_conflict, name='fix_port_conflict'),
url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/ports/(?P<port_id>\d+)/fix_port_conflict$', views.fix_port_conflict,
name='fix_port_conflict'),
url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/ports/(?P<port_id>\d+)/show_subscriber_on_port$',
views.ShowSubscriberOnPort.as_view(), name='show_subscriber_on_port'),
url(r'^(\d+)/(?P<device_id>\d+)/ports_add', views.add_ports, name='add_ports'), url(r'^(\d+)/(?P<device_id>\d+)/ports_add', views.add_ports, name='add_ports'),
url(r'^(\d+)/(?P<device_id>\d+)/(?P<portid>\d+)_(?P<status>[0-1]{1})$', views.toggle_port, name='port_toggle'), url(r'^(\d+)/(?P<device_id>\d+)/(?P<portid>\d+)_(?P<status>[0-1]{1})$', views.toggle_port, name='port_toggle'),
url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/(?P<portid>\d+)/del$', views.delete_single_port, name='del_port'), url(r'^(?P<group_id>\d+)/(?P<device_id>\d+)/(?P<portid>\d+)/del$', views.delete_single_port, name='del_port'),

19
devapp/views.py

@ -5,13 +5,13 @@ from django.contrib.gis.shortcuts import render_to_text
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.db import IntegrityError from django.db import IntegrityError
from django.db.models import Q, Count from django.db.models import Q, Count
from django.http import HttpResponse, JsonResponse
from django.http import HttpResponse, JsonResponse, Http404
from django.shortcuts import render, redirect, get_object_or_404, resolve_url from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.contrib import messages from django.contrib import messages
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.translation import gettext_lazy as _, gettext from django.utils.translation import gettext_lazy as _, gettext
from easysnmp import EasySNMPTimeoutError, EasySNMPError from easysnmp import EasySNMPTimeoutError, EasySNMPError
from django.views.generic import ListView
from django.views.generic import ListView, DetailView
from mydefs import pag_mn, res_success, res_error, only_admins, ping, order_helper, ip_addr_regex from mydefs import pag_mn, res_success, res_error, only_admins, ping, order_helper, ip_addr_regex
from abonapp.models import AbonGroup, Abon from abonapp.models import AbonGroup, Abon
@ -187,6 +187,21 @@ def manage_ports(request, device_id):
}) })
@method_decorator([login_required, only_admins], name='dispatch')
class ShowSubscriberOnPort(DetailView):
template_name = 'devapp/manage_ports/modal_show_subscriber_on_port.html'
http_method_names = ['get']
def get_object(self, queryset=None):
dev_id = self.kwargs.get('device_id')
port_id = self.kwargs.get('port_id')
try:
obj = Abon.objects.get(device_id=dev_id, dev_port_id=port_id)
except Abon.DoesNotExist:
raise Http404(gettext('Subscribers on port does not exist'))
return obj
@login_required @login_required
@permission_required('devapp.add_port') @permission_required('devapp.add_port')
def add_ports(request, device_id): def add_ports(request, device_id):

17
djing/urls.py

@ -1,10 +1,9 @@
from django.conf.urls import url, include from django.conf.urls import url, include
from django.conf import settings
# from django.conf import settings
from django.contrib import admin from django.contrib import admin
from .views import home from .views import home
urlpatterns = [ urlpatterns = [
url(r'^$', home), url(r'^$', home),
url(r'^accounts/', include('accounts_app.urls', namespace='acc_app')), url(r'^accounts/', include('accounts_app.urls', namespace='acc_app')),
@ -22,11 +21,11 @@ urlpatterns = [
] ]
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
#from django.contrib import admin
# if settings.DEBUG:
# from django.conf.urls.static import static
# from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# from django.contrib import admin
#urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
#urlpatterns += staticfiles_urlpatterns()
#urlpatterns += [url(r'^admin/', admin.site.urls)]
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
# urlpatterns += staticfiles_urlpatterns()
# urlpatterns += [url(r'^admin/', admin.site.urls)]

2
static/js/my.js

@ -19,7 +19,7 @@ function showSuccess(errContent) {show_Modal('Успешно', errContent, 'succ
function showPrimary(errContent) {show_Modal('Внимание!', errContent, 'primary');} function showPrimary(errContent) {show_Modal('Внимание!', errContent, 'primary');}
$(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) { $(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) {
showErr(jqXHR.status + ': ' + jqXHR.statusText);
showErr(jqXHR.status + ': ' + jqXHR.responseText);
}); });

38
templates/404.html

@ -1,10 +1,18 @@
{% if request.is_ajax %}
{% if exception %}
{{ exception }}
{% else %}
<h4>Страница не найдена</h4>
<p>Такого пути '{{ request_path }}' нет на сервере</p>
{% endif %}
{% else %}
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head lang="ru"> <head lang="ru">
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Страница не найдена</title> <title>Страница не найдена</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="shortcut icon" href="/static/img/favicon_m.ico"> <link rel="shortcut icon" href="/static/img/favicon_m.ico">
<!-- Core CSS - Include with every page --> <!-- Core CSS - Include with every page -->
<link rel="stylesheet" href="/static/css/bootstrap.min.css"> <link rel="stylesheet" href="/static/css/bootstrap.min.css">
@ -20,29 +28,35 @@
border-top-style: none; border-top-style: none;
border-bottom-style: none; border-bottom-style: none;
} }
</style> </style>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head> </head>
<body> <body>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div align="center"><h1>404 - Страница не найдена</h1></div>
<div align="center">
<p>Такого пути '{{ request.path }}' нет на сервере</p>
<a href="/accounts/">На главную</a>
</div>
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div align="center"><h1>404 - Страница не найдена</h1></div>
<div align="center">
{% if exception %}
{{ exception }}
{% else %}
<p>Такого пути '{{ request_path }}' нет на сервере</p>
{% endif %}
<a href="/accounts/">На главную</a>
</div> </div>
</div> </div>
</div> </div>
</div>
</body> </body>
</html> </html>
{% endif %}
Loading…
Cancel
Save