From 1f312347163ce6e7f8a11c0ca91058c65c48d74a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 29 Sep 2023 18:06:17 +0200 Subject: [PATCH] my skeleton --- .gitignore | 2 ++ idhub/views.py | 61 ++++++++++++++++++++++++++++++++++-- requirements.txt | 4 ++- trustchain_idhub/settings.py | 3 ++ trustchain_idhub/urls.py | 5 +-- 5 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58f0d03 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +env/ diff --git a/idhub/views.py b/idhub/views.py index 91ea44a..40da092 100644 --- a/idhub/views.py +++ b/idhub/views.py @@ -1,3 +1,60 @@ -from django.shortcuts import render +import logging +import datetime +import json -# Create your views here. +from django.conf import settings +from django.contrib import messages +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 +from django.contrib.auth.models import User + +from .forms import LoginForm + + +logger = logging.getLogger(__name__) + + + +class UserDashboardView(TemplateView): + template_name = "idhub/user_dashboard.html" + extra_context = { + 'title': _('Dashboard'), + } + + +class LoginView(FormView): + template_name = 'auth/login.html' + form_class = LoginForm + success_url = reverse_lazy('dashboard') + extra_context = { + 'title': _('Login'), + } + + def form_valid(self, form): + return self.success_url + + +class LogoutView(RedirectView): + """ + Log out the user. + """ + permanent = False + pattern_name = 'login' + + def get_redirect_url(self, *args, **kwargs): + """ + Logs out the user. + """ + return super().get_redirect_url(*args, **kwargs) + + def post(self, request, *args, **kwargs): + """Logout may be done via POST.""" + return self.get(request, *args, **kwargs) diff --git a/requirements.txt b/requirements.txt index d3e4ba5..eeefcda 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ -django +django==4.2.5 +django-bootstrap4==23.2 +django-extensions==3.2.3 diff --git a/trustchain_idhub/settings.py b/trustchain_idhub/settings.py index 232dde7..5b589ea 100644 --- a/trustchain_idhub/settings.py +++ b/trustchain_idhub/settings.py @@ -37,6 +37,9 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'django_extensions', + 'bootstrap4', + 'idhub', ] MIDDLEWARE = [ diff --git a/trustchain_idhub/urls.py b/trustchain_idhub/urls.py index f30184d..ac8a859 100644 --- a/trustchain_idhub/urls.py +++ b/trustchain_idhub/urls.py @@ -15,8 +15,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import path, include urlpatterns = [ - path('admin/', admin.site.urls), + path('django-admin/', admin.site.urls), + path('', include('idhub.urls')), ]