From 03d1a187dfaf196327c99227fa094f6a37439078 Mon Sep 17 00:00:00 2001 From: jiangweidong Date: Thu, 19 Oct 2023 11:21:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B7=A5=E5=8D=95=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E8=80=85=E8=AE=BF=E9=97=AE=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=97=A0=E8=AE=A4=E8=AF=81=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=A1=B5=E9=9D=A2=20(#11902)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * perf: 工单直接审批者访问链接无认证跳转到登录页面 * perf: 修改重定向登录地址 * perf: 跳转字段标识更新 --- .../tickets/approve_check_password.html | 7 ----- apps/tickets/views/approve.py | 30 +++++++++---------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/apps/tickets/templates/tickets/approve_check_password.html b/apps/tickets/templates/tickets/approve_check_password.html index 9fd7e0862..fe256bc1c 100644 --- a/apps/tickets/templates/tickets/approve_check_password.html +++ b/apps/tickets/templates/tickets/approve_check_password.html @@ -39,7 +39,6 @@
{% csrf_token %}
- {% if user.is_authenticated %} - {% else %} - - {% trans 'Go Login' %} - - {% endif %}
diff --git a/apps/tickets/views/approve.py b/apps/tickets/views/approve.py index 8dcda595f..2f3e715b4 100644 --- a/apps/tickets/views/approve.py +++ b/apps/tickets/views/approve.py @@ -64,30 +64,28 @@ class TicketDirectApproveView(TemplateView): def get_context_data(self, **kwargs): # 放入工单信息 - token = kwargs.get('token') - content = cache.get(token, {}).get('content', []) - if self.request.user.is_authenticated: - prompt_msg = _('Click the button below to approve or reject') - else: - prompt_msg = _('After successful authentication, this ticket can be approved directly') kwargs.update({ - 'content': content, 'prompt_msg': prompt_msg, - 'login_url': '%s&next=%s' % ( - self.login_url, - reverse('tickets:direct-approve', kwargs={'token': token}) - ), + 'content': kwargs['ticket_info'].get('content', []), + 'prompt_msg': _('Click the button below to approve or reject'), }) return super().get_context_data(**kwargs) def get(self, request, *args, **kwargs): if not request.user.is_authenticated: - return HttpResponse(status=401) - - token = kwargs.get('token') - ticket_info = cache.get(token) + direct_url = reverse('tickets:direct-approve', kwargs={'token': kwargs['token']}) + message_data = { + 'title': _('Ticket approval'), + 'message': _('After successful authentication, this ticket can be approved directly'), + 'redirect_url': f'{self.login_url}&{self.redirect_field_name}={direct_url}', + 'auto_redirect': True, + } + redirect_url = FlashMessageUtil.gen_message_url(message_data) + return redirect(redirect_url) + + ticket_info = cache.get(kwargs['token']) if not ticket_info: return self.redirect_message_response(redirect_url=self.login_url) - return super().get(request, *args, **kwargs) + return super().get(request, ticket_info=ticket_info, *args, **kwargs) def post(self, request, **kwargs): user = request.user