From f637233659d8192cd79ad20a8a2bbdc2299d20cd Mon Sep 17 00:00:00 2001 From: Dmitry Novikov Date: Tue, 23 Jan 2018 12:19:44 +0300 Subject: [PATCH] Fix translations. Fix raising error dialog when session is expired --- abonapp/locale/ru/LC_MESSAGES/django.po | 23 +++------------- msg_app/views.py | 22 ++++++++------- static/js/my.js | 13 +++++---- tariff_app/locale/ru/LC_MESSAGES/django.po | 31 ++++++++++++++++++++++ taskapp/views.py | 22 ++++++++------- 5 files changed, 68 insertions(+), 43 deletions(-) diff --git a/abonapp/locale/ru/LC_MESSAGES/django.po b/abonapp/locale/ru/LC_MESSAGES/django.po index d2fbdc2..da0f109 100644 --- a/abonapp/locale/ru/LC_MESSAGES/django.po +++ b/abonapp/locale/ru/LC_MESSAGES/django.po @@ -1056,11 +1056,11 @@ msgstr "Периодический платёж успешно удалён" #~ msgid "Buy" #~ msgstr "Купить" -#~ msgid "Not confirmed" -#~ msgstr "Действие не подтверждено" +msgid "Not confirmed" +msgstr "Действие не подтверждено" -#~ msgid "Services" -#~ msgstr "Услуги" +msgid "Services" +msgstr "Услуги" msgid "Payments" msgstr "Финансы" @@ -1077,21 +1077,6 @@ msgstr "Инфо." msgid "Dialing" msgstr "Звонки" -msgid "No have ip" -msgstr "Нет ip адреса" - -#, python-format -msgid "Graph of use by %(wantdate_d)s" -msgstr "График использования за %(wantdate_d)s" - -msgid "Show graph by date" -msgstr "Показать график по дате" - -#: views.py:757 -#, python-format -msgid "%(user_name)s already pinned to this port on this device" -msgstr "%(user_name)s уже привязан к этому порту на этом устройстве" - msgid "Export" msgstr "Экспорт" diff --git a/msg_app/views.py b/msg_app/views.py index 3d14e7f..431dddb 100644 --- a/msg_app/views.py +++ b/msg_app/views.py @@ -75,15 +75,19 @@ def remove_msg(request, conv_id, msg_id): return redirect('msg_app:to_conversation', conversation_id) -@login_required def check_news(request): - msg = MessageQueue.objects.pop(user=request.user, tag='msgapp') - if msg is not None: - r = { - 'exist': True, - 'content': msg, - 'title': "%s" % _('Message') - } + if request.user.is_authenticated: + msg = MessageQueue.objects.pop(user=request.user, tag='msgapp') + if msg is None: + r = {'auth': True, 'exist': False} + else: + r = { + 'auth': True, + 'exist': True, + 'content': msg, + 'title': "%s" % _('Message') + } else: - r = {'exist': False} + r = {'auth': False} return HttpResponse(dumps(r)) + diff --git a/static/js/my.js b/static/js/my.js index e1c82ff..c065dd9 100644 --- a/static/js/my.js +++ b/static/js/my.js @@ -202,10 +202,13 @@ $(document).ajaxError(function (ev, jqXHR, ajaxSettings, thrownError) { var perm = Notification.permission.toLowerCase(); if(perm == "granted" && settings.news_url){ $.getJSON(settings.news_url, function(r){ - if(r.exist){ - notifShow(r.title, r.content); - /*console.log('News from '+settings.news_url+'. '+r.content);*/ - }/*else console.log('No news from '+settings.news_url);*/ + if(r.auth){ + if(r.exist){ + notifShow(r.title, r.content); + } + }else{ + window.location.href = '/'; + } }); } } @@ -295,7 +298,7 @@ $(document).ready(function () { $('.btn_ajloader').ajloader({'dst_block': '#id_block_devices'}); - $(document).notifys({news_url: '/tasks/check_news', check_interval: 10}); + $(document).notifys({news_url: '/tasks/check_news', check_interval: 50}); $(document).notifys({news_url: '/msg/check_news', check_interval: 55}); }); diff --git a/tariff_app/locale/ru/LC_MESSAGES/django.po b/tariff_app/locale/ru/LC_MESSAGES/django.po index 3dd5f81..3f3b442 100644 --- a/tariff_app/locale/ru/LC_MESSAGES/django.po +++ b/tariff_app/locale/ru/LC_MESSAGES/django.po @@ -101,3 +101,34 @@ msgid "" msgstr "" "После того как вы удалите тарифный план то абоненты, подписанные на него, сразу потеряют услугу по этому тарифу. " "Так что сначала убедитесь что уже никто не пользуется тарифом, и только после этого удалите его." + +msgid "Services" +msgstr "Тарифы" + +msgid "Periodic pays" +msgstr "Периодические платежи" + +msgid "Periodic pay name" +msgstr "Название" + +msgid "When pay created" +msgstr "Когда создан" + +msgid "Script type for calculations" +msgstr "Алгоритм расчёта" + +msgid "Total amount" +msgstr "Стоимость" + +msgid "Pay details" +msgstr "Подробности платежа" + +msgid "Default periodic pay" +msgstr "Логика по умолчанию" + +msgid "Custom periodic pay" +msgstr "Пробная логика" + +msgid "Add new periodic pay" +msgstr "Добавить периодический платёж" + diff --git a/taskapp/views.py b/taskapp/views.py index 139f4f8..f579978 100644 --- a/taskapp/views.py +++ b/taskapp/views.py @@ -211,16 +211,18 @@ def remind(request, task_id): return redirect('taskapp:home') -@login_required -@only_admins def check_news(request): - msg = MessageQueue.objects.pop(user=request.user, tag='taskap') - if msg is not None: - r = { - 'exist': True, - 'content': msg, - 'title': _('Task') - } + if request.user.is_authenticated and request.user.is_admin: + msg = MessageQueue.objects.pop(user=request.user, tag='taskap') + if msg is not None: + r = { + 'auth': True, + 'exist': True, + 'content': msg, + 'title': _('Task') + } + else: + r = {'auth': True, 'exist': False} else: - r = {'exist': False} + r = {'auth': False} return HttpResponse(dumps(r))