From 791b21ee5196e4a5dd0e9a6fab0b6b50a3249c1e Mon Sep 17 00:00:00 2001 From: bashmak Date: Sun, 18 Mar 2018 00:26:35 +0300 Subject: [PATCH] Fix some bugs --- abonapp/locale/ru/LC_MESSAGES/django.po | 3 ++ abonapp/models.py | 8 ++-- abonapp/templates/abonapp/log.html | 7 +++- abonapp/views.py | 2 +- clientsideapp/locale/ru/LC_MESSAGES/django.po | 32 ++++++-------- .../templates/clientsideapp/debt_buy.html | 10 +++-- .../clientsideapp/modal_service_buy.html | 5 ++- clientsideapp/views.py | 12 +++--- devapp/models.py | 3 +- devapp/templates/devapp/devices.html | 2 +- djing/auth_backends.py | 42 +++++++++++++++++++ djing/settings.py | 5 ++- msg_app/models.py | 6 ++- taskapp/context_proc.py | 5 ++- taskapp/handle.py | 2 +- taskapp/locale/ru/LC_MESSAGES/django.po | 2 +- 16 files changed, 100 insertions(+), 46 deletions(-) create mode 100644 djing/auth_backends.py diff --git a/abonapp/locale/ru/LC_MESSAGES/django.po b/abonapp/locale/ru/LC_MESSAGES/django.po index 27b7a3f..5bb4ba3 100644 --- a/abonapp/locale/ru/LC_MESSAGES/django.po +++ b/abonapp/locale/ru/LC_MESSAGES/django.po @@ -1138,3 +1138,6 @@ msgstr "Абоненты" msgid "Successfully saved" msgstr "Успешно сохранено" + +msgid "This user can not buy admin services" +msgstr "Этот пользователь не может назначать административные услуги" diff --git a/abonapp/models.py b/abonapp/models.py index 462f45e..7caf11b 100644 --- a/abonapp/models.py +++ b/abonapp/models.py @@ -202,8 +202,11 @@ class Abon(BaseAccount): amount = round(tariff.amount, 2) - if not author.is_staff and tariff.is_admin: - raise LogicError(_('User that is no staff can not buy admin services')) + if tariff.is_admin: + if author is not None and not author.is_staff: + raise LogicError(_('User that is no staff can not buy admin services')) + else: + raise LogicError(_('This user can not buy admin services')) if self.current_tariff is not None: if self.current_tariff.tariff == tariff: @@ -347,7 +350,6 @@ class AllTimePayLogManager(models.Manager): r = cur.fetchone() if r is None: break summ, dat = r - print(summ, dat) yield {'summ': summ, 'pay_date': datetime.strptime(dat, '%Y-%m-%d')} diff --git a/abonapp/templates/abonapp/log.html b/abonapp/templates/abonapp/log.html index e8ef0e9..d180fc9 100644 --- a/abonapp/templates/abonapp/log.html +++ b/abonapp/templates/abonapp/log.html @@ -39,7 +39,12 @@ {{ l.comment }} {{ l.date|date:"D d E Y H:i:s" }} - {{ l.author.username }} + + {% if l.author %} + {{ l.author.username }} + {% else %} + --- + {% endif %} {% empty %} diff --git a/abonapp/views.py b/abonapp/views.py index 4f5a258..32e99bb 100644 --- a/abonapp/views.py +++ b/abonapp/views.py @@ -402,8 +402,8 @@ def unsubscribe_service(request, gid, uid, abon_tariff_id): try: abon = get_object_or_404(models.Abon, pk=uid) abon_tariff = get_object_or_404(models.AbonTariff, pk=int(abon_tariff_id)) - abon_tariff.delete() abon.sync_with_nas(created=False) + abon_tariff.delete() messages.success(request, _('User has been detached from service')) except NasFailedResult as e: messages.error(request, e) diff --git a/clientsideapp/locale/ru/LC_MESSAGES/django.po b/clientsideapp/locale/ru/LC_MESSAGES/django.po index 79077a7..23cef2a 100644 --- a/clientsideapp/locale/ru/LC_MESSAGES/django.po +++ b/clientsideapp/locale/ru/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-08 14:24+0300\n" +"POT-Creation-Date: 2018-03-18 00:15+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Dmitry Novikov nerosketch@gmail.com\n" "Language: ru\n" @@ -32,31 +32,25 @@ msgid "Are you sure you want to spend a payment?" msgstr "Вы уверены что хотите провести платёж?" #: templates/clientsideapp/debt_buy.html:21 -#, fuzzy, python-format -#| msgid "" -#| "From your account, they withdraw funds in %(amount)s rub.
\n" -#| "As a result, you will remain on your account %(ballance_after)s rubles. " -#| "
\n" -#| "The administrator can immediately see that you shut down the debt." +#, python-format msgid "" -"From your account, they withdraw funds in %(amount)s rub.
\n" -"As a result, you will remain on your account %(ballance_after)s rubles.
\n" -"The administrator can immediately see that you shut down the debt." +"From your account, they withdraw funds in %(amount)s rub.
As a " +"result, you will remain on your account %(ballance_after)s rubles.
The " +"administrator can immediately see that you shut down the debt." msgstr "" -"С вашего счёта снимутся средства в размере %(amount)s руб.
\n" -"В результате у вас на счету останется %(ballance_after)s руб.
\n" -"Администратор сразу сможет видеть что у вас закрыта задолженность." +"С вашего счёта снимутся средства в размере %(amount)s руб.
В " +"результате у вас на счету останется %(ballance_after)s руб.
Администратор сразу сможет видеть что у вас закрыта задолженность." -#: templates/clientsideapp/debt_buy.html:24 +#: templates/clientsideapp/debt_buy.html:26 msgid "Description of payment" msgstr "Описание платежа" -#: templates/clientsideapp/debt_buy.html:32 +#: templates/clientsideapp/debt_buy.html:34 msgid "Confirm" msgstr "Подтвердить" -#: templates/clientsideapp/debt_buy.html:35 +#: templates/clientsideapp/debt_buy.html:37 msgid "Cancel" msgstr "Отменить" @@ -107,7 +101,7 @@ msgstr "У вас нет проведённых платежей" #: templates/clientsideapp/services.html:25 msgid "currency" -msgstr "" +msgstr "руб." #: views.py:51 #, python-format @@ -127,7 +121,7 @@ msgstr "Вы не уверены что хотите оплатить долг?" msgid "Your account have not enough money" msgstr "Недостаточно средств на счету" -#: views.py:90 +#: views.py:89 #, python-format msgid "%(username)s paid the debt %(amount).2f" msgstr "%(username)s заплатил долг в размере %(amount).2f" diff --git a/clientsideapp/templates/clientsideapp/debt_buy.html b/clientsideapp/templates/clientsideapp/debt_buy.html index 510fbe8..dc14472 100644 --- a/clientsideapp/templates/clientsideapp/debt_buy.html +++ b/clientsideapp/templates/clientsideapp/debt_buy.html @@ -18,9 +18,11 @@ {% trans 'Are you sure you want to spend a payment?' %} -

{% blocktrans %}From your account, they withdraw funds in {{ amount }} rub.
-As a result, you will remain on your account {{ ballance_after }} rubles.
-The administrator can immediately see that you shut down the debt.{% endblocktrans %}

+

{% blocktrans trimmed %} + From your account, they withdraw funds in {{ amount }} rub.
+ As a result, you will remain on your account {{ ballance_after }} rubles.
+ The administrator can immediately see that you shut down the debt. + {% endblocktrans %}

{% trans 'Description of payment' %}

@@ -38,4 +40,4 @@ The administrator can immediately see that you shut down the debt.{% endblocktra
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/clientsideapp/templates/clientsideapp/modal_service_buy.html b/clientsideapp/templates/clientsideapp/modal_service_buy.html index 93d6d7d..0077603 100644 --- a/clientsideapp/templates/clientsideapp/modal_service_buy.html +++ b/clientsideapp/templates/clientsideapp/modal_service_buy.html @@ -12,9 +12,10 @@

{{ service.descr }}

- +Cost: {{ amount }} rubles.{% endblocktrans %} #}

-->

Стоимость {{ service.amount }} руб.