|
|
@ -64,30 +64,28 @@ class TicketDirectApproveView(TemplateView):
|
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
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({
|
|
|
|
kwargs.update({
|
|
|
|
'content': content, 'prompt_msg': prompt_msg,
|
|
|
|
'content': kwargs['ticket_info'].get('content', []),
|
|
|
|
'login_url': '%s&next=%s' % (
|
|
|
|
'prompt_msg': _('Click the button below to approve or reject'),
|
|
|
|
self.login_url,
|
|
|
|
|
|
|
|
reverse('tickets:direct-approve', kwargs={'token': token})
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return super().get_context_data(**kwargs)
|
|
|
|
return super().get_context_data(**kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
if not request.user.is_authenticated:
|
|
|
|
if not request.user.is_authenticated:
|
|
|
|
return HttpResponse(status=401)
|
|
|
|
direct_url = reverse('tickets:direct-approve', kwargs={'token': kwargs['token']})
|
|
|
|
|
|
|
|
message_data = {
|
|
|
|
token = kwargs.get('token')
|
|
|
|
'title': _('Ticket approval'),
|
|
|
|
ticket_info = cache.get(token)
|
|
|
|
'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:
|
|
|
|
if not ticket_info:
|
|
|
|
return self.redirect_message_response(redirect_url=self.login_url)
|
|
|
|
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):
|
|
|
|
def post(self, request, **kwargs):
|
|
|
|
user = request.user
|
|
|
|
user = request.user
|
|
|
|