Browse Source

Prevent to pin subscriber to busy port on device

devel
bashmak 8 years ago
parent
commit
fb2d8ee739
  1. 8
      abonapp/locale/ru/LC_MESSAGES/django.po
  2. 2
      abonapp/templates/abonapp/editAbon.html
  3. 16
      abonapp/views.py
  4. 4
      clientsideapp/views.py
  5. 2
      devapp/dev_types.py
  6. 2
      devapp/models.py
  7. 2
      devapp/views.py
  8. 2
      dialing_app/models.py
  9. 2
      dialing_app/views.py
  10. 2
      djing/formfields.py
  11. 2
      mapapp/models.py
  12. 2
      mapapp/views.py
  13. 2
      msg_app/forms.py
  14. 2
      msg_app/models.py
  15. 2
      msg_app/views.py
  16. 2
      templates/message_block.html

8
abonapp/locale/ru/LC_MESSAGES/django.po

@ -427,10 +427,6 @@ msgstr "Добавить муфту"
msgid "Device port"
msgstr "Порт устройства"
#: templates/abonapp/editAbon.html:182
msgid "Ports does not exist"
msgstr "Порты не найдены"
#: templates/abonapp/editAbon.html:190
msgid "Is dynamic network settings"
msgstr "Динамические настройки по dhcp"
@ -992,3 +988,7 @@ msgstr "Звонки"
msgid "No have ip"
msgstr "Нет ip адреса"
#: views.py:757
#, python-format
msgid "<a href='%(user_url)s'>%(user_name)s</a> already pinned to this port on this device"
msgstr "<a href='%(user_url)s'>%(user_name)s</a> уже привязан к этому порту на этом устройстве"

2
abonapp/templates/abonapp/editAbon.html

@ -148,8 +148,6 @@
{% else %}
<option value="{{ port.pk }}">{{ port.num }}: {{ port.descr }}</option>
{% endif %}
{% empty %}
<option value="0">{% trans 'Ports does not exist' %}</option>
{% endfor %}
</select>
</div>

16
abonapp/views.py

@ -9,7 +9,7 @@ from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from statistics.models import StatCache
from tariff_app.models import Tariff
@ -745,11 +745,23 @@ def save_user_dev_port(request, gid, uid):
user_port = mydefs.safe_int(request.POST.get('user_port'))
is_dynamic_ip = request.POST.get('is_dynamic_ip')
try:
abon = models.Abon.objects.get(pk=uid)
if user_port == 0:
port = None
else:
port = DevPort.objects.get(pk=user_port)
abon = models.Abon.objects.get(pk=uid)
if abon.device is not None:
try:
other_abon = models.Abon.objects.get(device=abon.device, dev_port=port)
user_url = resolve_url('abonapp:abon_home', other_abon.group.id, other_abon.id)
messages.error(request, _("<a href='%(user_url)s'>%(user_name)s</a> already pinned to this port on this device") % {
'user_url': user_url,
'user_name': other_abon.get_full_name()
})
return redirect('abonapp:abon_home', gid, uid)
except models.Abon.DoesNotExist:
pass
abon.dev_port = port
if abon.is_dynamic_ip != is_dynamic_ip:
abon.is_dynamic_ip = is_dynamic_ip

4
clientsideapp/views.py

@ -4,9 +4,9 @@ from django.contrib.gis.shortcuts import render_to_text
from django.shortcuts import render, get_object_or_404, redirect
from django.contrib import messages
from django.db.transaction import atomic
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from abonapp.models import AbonLog, AbonTariff, InvoiceForPayment, Abon
from abonapp.models import AbonLog, InvoiceForPayment, Abon
from tariff_app.models import Tariff
from mydefs import pag_mn, LogicError
from agent import NasFailedResult, NasNetworkError

2
devapp/dev_types.py

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from mydefs import RuTimedelta, safe_int
from datetime import timedelta
from easysnmp import EasySNMPTimeoutError

2
devapp/models.py

@ -7,7 +7,7 @@ from mydefs import MyGenericIPAddressField, MyChoicesAdapter, ip2int
from . import dev_types
from subprocess import run
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from json.decoder import JSONDecodeError

2
devapp/views.py

@ -7,7 +7,7 @@ from django.db.models import Q, Count
from django.http import HttpResponse
from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from easysnmp import EasySNMPTimeoutError, EasySNMPError
from json import dumps

2
dialing_app/models.py

@ -1,6 +1,6 @@
from django.db import models
from datetime import datetime
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.conf import settings

2
dialing_app/views.py

@ -4,7 +4,7 @@ from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.contrib.gis.shortcuts import render_to_text
from django.shortcuts import render, redirect
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from guardian.decorators import permission_required_or_403 as permission_required
from django.db.models import Q

2
djing/formfields.py

@ -3,7 +3,7 @@ from django.forms.widgets import TextInput
from django.core.validators import RegexValidator, _lazy_re_compile
from django.forms.fields import EMPTY_VALUES
from django.forms.utils import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from netaddr import EUI, AddrFormatError
from . import MAC_ADDR_REGEX

2
mapapp/models.py

@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from devapp.models import Device

2
mapapp/views.py

@ -4,7 +4,7 @@ from django.contrib.gis.shortcuts import render_to_text
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden
from django.shortcuts import render, redirect, get_object_or_404, resolve_url
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.db.models import Count
from .models import Dot
from .forms import DotForm

2
msg_app/forms.py

@ -1,5 +1,5 @@
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from .models import Conversation, Message, MessageError
from accounts_app.models import UserProfile

2
msg_app/models.py

@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from accounts_app.models import UserProfile
from chatbot.telebot import send_notify
from chatbot.models import ChatException

2
msg_app/views.py

@ -3,7 +3,7 @@ from django.contrib.auth.decorators import login_required
from django.contrib.gis.shortcuts import render_to_text
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib import messages
from django.shortcuts import render, redirect, get_object_or_404
from chatbot.models import MessageQueue

2
templates/message_block.html

@ -16,7 +16,7 @@
{% endif %}
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
{{ message }}
{{ message|safe }}
</div>
{% endfor %}
{% endif %}
Loading…
Cancel
Save