[0-1]{1})$', views.toggle_port, name='port_toggle')
]
diff --git a/devapp/views.py b/devapp/views.py
index 2124418..1c83d95 100644
--- a/devapp/views.py
+++ b/devapp/views.py
@@ -1,31 +1,50 @@
# -*- coding: utf-8 -*-
from django.contrib.auth.decorators import login_required, permission_required
from django.core.exceptions import PermissionDenied
-from django.shortcuts import render, redirect, get_object_or_404
+from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.contrib import messages
-from django.utils.translation import ugettext as _
+from django.utils.translation import ugettext_lazy as _
from easysnmp import EasySNMPTimeoutError
from .models import Device
from mydefs import pag_mn, res_success, res_error, only_admins, ping, order_helper
from .forms import DeviceForm
+from abonapp.models import AbonGroup
@login_required
@only_admins
-def devices(request):
- devs = Device.objects.all()
+def devices(request, grp):
+ group = get_object_or_404(AbonGroup, pk=grp)
+ devs = Device.objects.filter(user_group=grp)
# фильтр
dr, field = order_helper(request)
if field:
devs = devs.order_by(field)
- print(type(request.GET), request.GET)
- import django.http.request
devs = pag_mn(request, devs)
return render(request, 'devapp/devices.html', {
+ 'devices': devs,
+ 'dir': dr,
+ 'order_by': request.GET.get('order_by'),
+ 'group': group
+ })
+
+
+@login_required
+@only_admins
+def devices_null_group(request):
+ devs = Device.objects.all()
+ # фильтр
+ dr, field = order_helper(request)
+ if field:
+ devs = devs.order_by(field)
+
+ devs = pag_mn(request, devs)
+
+ return render(request, 'devapp/devices_null_group.html', {
'devices': devs,
'dir': dr,
'order_by': request.GET.get('order_by')
@@ -36,8 +55,10 @@ def devices(request):
@permission_required('devapp.delete_device')
def devdel(request, did):
try:
- Device.objects.get(pk=did).delete()
- return res_success(request, 'devapp:devs')
+ dev = Device.objects.get(pk=did)
+ back_url = resolve_url('devapp:devs', grp=dev.user_group.pk if dev.user_group else 0)
+ dev.delete()
+ return res_success(request, back_url)
except Device.DoesNotExist:
return res_error(request, _('Delete failed'))
@@ -63,10 +84,15 @@ def dev(request, devid=0):
else:
frm = DeviceForm(instance=devinst)
- return render(request, 'devapp/dev.html', {
- 'form': frm,
- 'dev': devinst
- })
+ if devinst is None:
+ return render(request, 'devapp/add_dev.html', {
+ 'form': frm
+ })
+ else:
+ return render(request, 'devapp/dev.html', {
+ 'form': frm,
+ 'dev': devinst
+ })
@login_required
@@ -114,4 +140,13 @@ def toggle_port(request, did, portid, status=0):
messages.warning(request, _('Not Set snmp device password'))
else:
messages.error(request, _('Dot was not pinged'))
- return redirect('devapp:view', did=did)
+ return redirect('devapp:view', dev.user_group or 0, did)
+
+
+@login_required
+@only_admins
+def group_list(request):
+ groups = AbonGroup.objects.all()
+ return render(request, 'devapp/group_list.html', {
+ 'groups': groups
+ })
diff --git a/django_messages/locale/ar/LC_MESSAGES/django.mo b/django_messages/locale/ar/LC_MESSAGES/django.mo
deleted file mode 100644
index 5c16012..0000000
Binary files a/django_messages/locale/ar/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/cs/LC_MESSAGES/django.mo b/django_messages/locale/cs/LC_MESSAGES/django.mo
deleted file mode 100644
index deeec2f..0000000
Binary files a/django_messages/locale/cs/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/da/LC_MESSAGES/django.mo b/django_messages/locale/da/LC_MESSAGES/django.mo
deleted file mode 100644
index 591819e..0000000
Binary files a/django_messages/locale/da/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/de/LC_MESSAGES/django.mo b/django_messages/locale/de/LC_MESSAGES/django.mo
deleted file mode 100644
index 1e4e5c8..0000000
Binary files a/django_messages/locale/de/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/el/LC_MESSAGES/django.mo b/django_messages/locale/el/LC_MESSAGES/django.mo
deleted file mode 100644
index cecfd01..0000000
Binary files a/django_messages/locale/el/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/es/LC_MESSAGES/django.mo b/django_messages/locale/es/LC_MESSAGES/django.mo
deleted file mode 100644
index 7805790..0000000
Binary files a/django_messages/locale/es/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/es_AR/LC_MESSAGES/django.mo b/django_messages/locale/es_AR/LC_MESSAGES/django.mo
deleted file mode 100644
index d0d9df8..0000000
Binary files a/django_messages/locale/es_AR/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/fa/LC_MESSAGES/django.mo b/django_messages/locale/fa/LC_MESSAGES/django.mo
deleted file mode 100644
index a61d884..0000000
Binary files a/django_messages/locale/fa/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/fr/LC_MESSAGES/django.mo b/django_messages/locale/fr/LC_MESSAGES/django.mo
deleted file mode 100644
index 2d03c91..0000000
Binary files a/django_messages/locale/fr/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/it/LC_MESSAGES/django.mo b/django_messages/locale/it/LC_MESSAGES/django.mo
deleted file mode 100644
index 451a8aa..0000000
Binary files a/django_messages/locale/it/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/ko/LC_MESSAGES/django.mo b/django_messages/locale/ko/LC_MESSAGES/django.mo
deleted file mode 100644
index 1660a88..0000000
Binary files a/django_messages/locale/ko/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/lt/LC_MESSAGES/django.mo b/django_messages/locale/lt/LC_MESSAGES/django.mo
deleted file mode 100644
index 3760c76..0000000
Binary files a/django_messages/locale/lt/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/nl/LC_MESSAGES/django.mo b/django_messages/locale/nl/LC_MESSAGES/django.mo
deleted file mode 100755
index cc71ed8..0000000
Binary files a/django_messages/locale/nl/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/pl/LC_MESSAGES/django.mo b/django_messages/locale/pl/LC_MESSAGES/django.mo
deleted file mode 100644
index 2279254..0000000
Binary files a/django_messages/locale/pl/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/pt_BR/LC_MESSAGES/django.mo b/django_messages/locale/pt_BR/LC_MESSAGES/django.mo
deleted file mode 100644
index 83e5704..0000000
Binary files a/django_messages/locale/pt_BR/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/ro/LC_MESSAGES/django.mo b/django_messages/locale/ro/LC_MESSAGES/django.mo
deleted file mode 100644
index 7993e9e..0000000
Binary files a/django_messages/locale/ro/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/ru/LC_MESSAGES/django.mo b/django_messages/locale/ru/LC_MESSAGES/django.mo
deleted file mode 100644
index ee62d5d..0000000
Binary files a/django_messages/locale/ru/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/django_messages/locale/zh_CN/LC_MESSAGES/django.mo b/django_messages/locale/zh_CN/LC_MESSAGES/django.mo
deleted file mode 100644
index 455e489..0000000
Binary files a/django_messages/locale/zh_CN/LC_MESSAGES/django.mo and /dev/null differ
diff --git a/taskapp/models.py b/taskapp/models.py
index ba13ba4..774b4c1 100644
--- a/taskapp/models.py
+++ b/taskapp/models.py
@@ -1,5 +1,6 @@
# coding=utf-8
from datetime import timedelta
+import os
from django.db import models
from django.conf import settings
from django.utils import timezone
@@ -96,6 +97,9 @@ class Task(models.Model):
)
self.save(update_fields=['state'])
+ def get_attachment_fname(self):
+ return os.path.basename(self.attachment.name)
+
def task_handler(sender, instance, **kwargs):
group = ''
diff --git a/taskapp/templates/taskapp/tasklist.html b/taskapp/templates/taskapp/tasklist.html
index a081988..686653f 100644
--- a/taskapp/templates/taskapp/tasklist.html
+++ b/taskapp/templates/taskapp/tasklist.html
@@ -36,7 +36,7 @@
| {{ task.get_state_display }} |
{{ task.get_priority_display }} |
{{ task.time_of_create|date:'d N Y H:i:s' }} |
- {% if task.attachment %}{{ task.attachment.name }}{% else %}―{% endif %} |
+ {% if task.attachment %}{{ task.get_attachment_fname|truncatechars:32|truncatechars:32 }}{% else %}―{% endif %} |
diff --git a/taskapp/templates/taskapp/tasklist_active.html b/taskapp/templates/taskapp/tasklist_active.html
index 94162c6..f9926e6 100644
--- a/taskapp/templates/taskapp/tasklist_active.html
+++ b/taskapp/templates/taskapp/tasklist_active.html
@@ -37,7 +37,7 @@
| {{ task.get_state_display }} |
{{ task.get_priority_display }} |
{{ task.time_of_create|date:'d N Y H:i:s' }} |
- {% if task.attachment %}{{ task.attachment.name }}{% else %}―{% endif %} |
+ {% if task.attachment %}{{ task.get_attachment_fname|truncatechars:32 }}{% else %}―{% endif %} |
diff --git a/taskapp/templates/taskapp/tasklist_all.html b/taskapp/templates/taskapp/tasklist_all.html
index fcce8db..87b298d 100644
--- a/taskapp/templates/taskapp/tasklist_all.html
+++ b/taskapp/templates/taskapp/tasklist_all.html
@@ -48,7 +48,7 @@
| {{ task.get_state_display }} |
{{ task.get_priority_display }} |
{{ task.time_of_create|date:'d N Y H:i:s' }} |
- {% if task.attachment %}{{ task.attachment.name }}{% else %}―{% endif %} |
+ {% if task.attachment %}{{ task.get_attachment_fname|truncatechars:32 }}{% else %}―{% endif %} |
{% if perms.taskapp.change_task %}
diff --git a/taskapp/templates/taskapp/tasklist_finish.html b/taskapp/templates/taskapp/tasklist_finish.html
index 5a7dee4..14f12e1 100644
--- a/taskapp/templates/taskapp/tasklist_finish.html
+++ b/taskapp/templates/taskapp/tasklist_finish.html
@@ -37,7 +37,7 @@
| {{ task.get_state_display }} |
{{ task.get_priority_display }} |
{{ task.time_of_create|date:'d N Y H:i:s' }} |
- {% if task.attachment %}{{ task.attachment.name }}{% else %}―{% endif %} |
+ {% if task.attachment %}{{ task.get_attachment_fname|truncatechars:32 }}{% else %}―{% endif %} |
{% if perms.taskapp.change_task %}
diff --git a/taskapp/templates/taskapp/tasklist_own.html b/taskapp/templates/taskapp/tasklist_own.html
index 21a79d2..5cf3ce0 100644
--- a/taskapp/templates/taskapp/tasklist_own.html
+++ b/taskapp/templates/taskapp/tasklist_own.html
@@ -34,7 +34,7 @@
| {{ task.get_state_display }} |
{{ task.get_priority_display }} |
{{ task.time_of_create|date:'d N Y H:i:s' }} |
- {% if task.attachment %}{{ task.attachment.name }}{% else %}―{% endif %} |
+ {% if task.attachment %}{{ task.get_attachment_fname|truncatechars:32 }}{% else %}―{% endif %} |
{% if perms.taskapp.change_task %}
diff --git a/templates/base.html b/templates/base.html
index 5b966b0..2532183 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -70,9 +70,9 @@
ip пул
- {% url 'devapp:devs' as devapp_devs %}
-
-
+ {% url 'devapp:group_list' as devapp_groups %}
+
+
железки
|