my skeleton

This commit is contained in:
Cayo Puigdefabregas 2023-09-29 18:06:17 +02:00
parent 05cad79560
commit 1f31234716
5 changed files with 70 additions and 5 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
env/

View File

@ -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)

View File

@ -1 +1,3 @@
django django==4.2.5
django-bootstrap4==23.2
django-extensions==3.2.3

View File

@ -37,6 +37,9 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'django_extensions',
'bootstrap4',
'idhub',
] ]
MIDDLEWARE = [ MIDDLEWARE = [

View File

@ -15,8 +15,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('django-admin/', admin.site.urls),
path('', include('idhub.urls')),
] ]