2018-12-09 20:07:18 +00:00
|
|
|
"""passbook core utils view"""
|
2019-03-11 10:25:59 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
2018-12-09 20:07:18 +00:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from django.views.generic import TemplateView
|
|
|
|
|
|
|
|
|
|
|
|
class LoadingView(TemplateView):
|
|
|
|
"""View showing a loading template, and forwarding to real view using html forwarding."""
|
|
|
|
|
|
|
|
template_name = 'login/loading.html'
|
|
|
|
title = _('Loading')
|
|
|
|
target_url = None
|
|
|
|
|
|
|
|
def get_url(self):
|
|
|
|
"""Return URL template will redirect to"""
|
|
|
|
return self.target_url
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
kwargs['is_login'] = True
|
|
|
|
kwargs['title'] = self.title
|
|
|
|
kwargs['target_url'] = self.get_url()
|
|
|
|
return super().get_context_data(**kwargs)
|
2018-12-11 14:29:58 +00:00
|
|
|
|
2019-03-11 10:25:59 +00:00
|
|
|
class PermissionDeniedView(LoginRequiredMixin, TemplateView):
|
2018-12-11 14:29:58 +00:00
|
|
|
"""Generic Permission denied view"""
|
|
|
|
|
|
|
|
template_name = 'login/denied.html'
|
|
|
|
title = _('Permission denied.')
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
kwargs['is_login'] = True
|
|
|
|
kwargs['title'] = self.title
|
|
|
|
return super().get_context_data(**kwargs)
|