From 68198df0a0d7d34b96f3fc5be08fd87846ef89e3 Mon Sep 17 00:00:00 2001 From: bashmak Date: Fri, 17 Mar 2017 16:24:31 +0300 Subject: [PATCH] =?UTF-8?q?FIXBUG:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BA=D0=BE=D0=B3=D0=B4=D0=B0=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B1=D1=8B=D0=BB=D0=BE=20=D0=B0=D0=B1=D0=BE=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B0=20=D1=81=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=BC=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD=D0=BE?= =?UTF-8?q?=D0=BC=20=D1=82=D0=BE=20=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0?= =?UTF-8?q?=D1=89=D0=B0=D0=BB=D1=81=D1=8F=20error404,=20=D1=82=D0=B5=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D1=8C=20=D0=B3=D0=BE=D0=B2=D1=80=D0=B8=D1=82=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=BE=D0=B1=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82=D0=B2?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B0=D0=B1=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- taskapp/locale/ru/LC_MESSAGES/django.po | 3 +++ taskapp/views.py | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/taskapp/locale/ru/LC_MESSAGES/django.po b/taskapp/locale/ru/LC_MESSAGES/django.po index c7b213c..b0ce0b0 100644 --- a/taskapp/locale/ru/LC_MESSAGES/django.po +++ b/taskapp/locale/ru/LC_MESSAGES/django.po @@ -360,3 +360,6 @@ msgstr "Назначенные мной задачи" msgid "All my tasks" msgstr "Все мои задачи" + +msgid "User '%s' does not exist" +msgstr "Абонент с логином '%s' не найден" diff --git a/taskapp/views.py b/taskapp/views.py index 89316ba..5b5bcd7 100644 --- a/taskapp/views.py +++ b/taskapp/views.py @@ -101,7 +101,7 @@ def view(request, task_id): @only_admins def task_add_edit(request, task_id=0): task_id = safe_int(task_id) - uid = request.GET.get('uid') + uid = request.GET.get('uid', 0) selected_abon = None frm = TaskFrm() @@ -119,11 +119,8 @@ def task_add_edit(request, task_id=0): frm = TaskFrm(instance=tsk) selected_abon = tsk.abon - if uid: - selected_abon = get_object_or_404(Abon, username=str(uid)) - - if request.method == 'POST': - try: + try: + if request.method == 'POST': tsk.author = request.user frm = TaskFrm(request.POST, request.FILES, instance=tsk) @@ -150,8 +147,12 @@ def task_add_edit(request, task_id=0): messages.error(request, _('You must select the subscriber')) else: messages.error(request, _('Error in the form fields')) - except TelegramBot.DoesNotExist: - messages.error(request, _('Employee has not yet signed up for notifications')) + elif uid: + selected_abon = Abon.objects.get(username=str(uid)) + except TelegramBot.DoesNotExist: + messages.error(request, _('Employee has not yet signed up for notifications')) + except Abon.DoesNotExist: + messages.warning(request, _("User '%s' does not exist") % str(uid)) return render(request, 'taskapp/add_edit_task.html', { 'form': frm,