2021-04-29 09:15:46 +00:00
|
|
|
#
|
2023-09-11 10:15:03 +00:00
|
|
|
from django.http import HttpResponse
|
2021-04-29 09:15:46 +00:00
|
|
|
from django.utils.decorators import method_decorator
|
|
|
|
from django.views.decorators.cache import never_cache
|
|
|
|
from django.views.generic.base import TemplateView
|
|
|
|
|
|
|
|
from common.utils import bulk_get, FlashMessageUtil
|
|
|
|
|
|
|
|
|
|
|
|
@method_decorator(never_cache, name='dispatch')
|
|
|
|
class FlashMessageMsgView(TemplateView):
|
|
|
|
template_name = 'flash_message_standalone.html'
|
|
|
|
|
|
|
|
def get(self, request, *args, **kwargs):
|
|
|
|
code = request.GET.get('code')
|
|
|
|
if not code:
|
|
|
|
return HttpResponse('Not found the code')
|
|
|
|
|
|
|
|
message_data = FlashMessageUtil.get_message_by_code(code)
|
|
|
|
if not message_data:
|
|
|
|
return HttpResponse('Message code error')
|
|
|
|
|
2021-10-18 03:25:39 +00:00
|
|
|
items = ('title', 'message', 'error', 'redirect_url', 'confirm_button', 'cancel_url')
|
|
|
|
title, msg, error, redirect_url, confirm_btn, cancel_url = bulk_get(message_data, items)
|
2021-04-29 09:15:46 +00:00
|
|
|
|
|
|
|
interval = message_data.get('interval', 3)
|
|
|
|
auto_redirect = message_data.get('auto_redirect', True)
|
|
|
|
has_cancel = message_data.get('has_cancel', False)
|
|
|
|
context = {
|
|
|
|
'title': title,
|
2021-10-18 03:25:39 +00:00
|
|
|
'message': msg,
|
|
|
|
'error': error,
|
2021-04-29 09:15:46 +00:00
|
|
|
'interval': interval,
|
|
|
|
'redirect_url': redirect_url,
|
|
|
|
'auto_redirect': auto_redirect,
|
2021-10-18 03:25:39 +00:00
|
|
|
'confirm_button': confirm_btn,
|
2021-04-29 09:15:46 +00:00
|
|
|
'has_cancel': has_cancel,
|
|
|
|
'cancel_url': cancel_url,
|
|
|
|
}
|
2021-10-18 03:25:39 +00:00
|
|
|
return self.render_to_response(context)
|