2023-09-29 16:06:17 +00:00
|
|
|
import logging
|
|
|
|
import datetime
|
|
|
|
import json
|
2023-09-26 07:15:28 +00:00
|
|
|
|
2023-09-29 16:06:17 +00:00
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib import messages
|
2023-10-02 15:49:33 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
2023-09-29 16:06:17 +00:00
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
|
|
|
from django.http import HttpResponse, HttpResponseNotFound, HttpResponseRedirect
|
|
|
|
from django.urls import reverse_lazy
|
|
|
|
from django.utils.html import format_html
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from django.views import View
|
|
|
|
from django.views.generic.base import RedirectView, TemplateView
|
|
|
|
from django.views.generic.detail import DetailView
|
|
|
|
from django.views.generic.edit import DeleteView, FormView
|
|
|
|
from django.views.generic.list import ListView
|
2023-10-09 08:49:56 +00:00
|
|
|
from django.contrib.auth import views as auth_views
|
2023-09-29 16:06:17 +00:00
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
from .forms import LoginForm
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-09 08:49:56 +00:00
|
|
|
class UserDashboardView(LoginRequiredMixin, TemplateView):
|
2023-09-29 16:06:17 +00:00
|
|
|
template_name = "idhub/user_dashboard.html"
|
2023-10-02 15:49:33 +00:00
|
|
|
title = _('Dashboard')
|
2023-10-09 08:49:56 +00:00
|
|
|
login_url = "/login/"
|
2023-10-02 15:49:33 +00:00
|
|
|
|
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super().get_context_data(**kwargs)
|
|
|
|
context.update({
|
|
|
|
'title': self.title,
|
|
|
|
})
|
|
|
|
return context
|
|
|
|
|
2023-09-29 16:06:17 +00:00
|
|
|
|
2023-10-05 10:14:33 +00:00
|
|
|
class AdminDashboardView(UserDashboardView):
|
|
|
|
template_name = "idhub/admin_dashboard.html"
|
|
|
|
|
2023-09-29 16:06:17 +00:00
|
|
|
|
2023-10-09 08:49:56 +00:00
|
|
|
class LoginView(auth_views.LoginView):
|
2023-09-29 16:06:17 +00:00
|
|
|
template_name = 'auth/login.html'
|
|
|
|
extra_context = {
|
|
|
|
'title': _('Login'),
|
2023-10-09 08:49:56 +00:00
|
|
|
'success_url': reverse_lazy('idhub:user_dashboard'),
|
2023-09-29 16:06:17 +00:00
|
|
|
}
|
|
|
|
|
2023-10-09 08:49:56 +00:00
|
|
|
def get(self, request):
|
|
|
|
if request.GET.get('next'):
|
|
|
|
self.extra_context['success_url'] = request.GET.get('next')
|
|
|
|
return super().get(request)
|