mirror of
https://github.com/chibicitiberiu/ytsm.git
synced 2024-02-24 05:43:31 +00:00
Show error message if not allowed to access admin page.
This commit is contained in:
parent
8eca3dc7a9
commit
05ecb6a493
@ -4,8 +4,16 @@
|
||||
{% block body %}
|
||||
|
||||
<div class="container">
|
||||
|
||||
<h1>Admin settings</h1>
|
||||
|
||||
{% if not request.user.is_authenticated or not request.user.is_superuser %}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
You must be an administrator to access this page!
|
||||
</div>
|
||||
{% else %}
|
||||
{% crispy form %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% endblock body %}
|
@ -24,12 +24,6 @@ class AdminSettingsView(LoginRequiredMixin, FormView):
|
||||
template_name = 'YtManagerApp/settings_admin.html'
|
||||
success_url = reverse_lazy('home')
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated or not request.user.is_superuser:
|
||||
return HttpResponseForbidden()
|
||||
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated or not request.user.is_superuser:
|
||||
return HttpResponseForbidden()
|
||||
|
Loading…
Reference in New Issue
Block a user