creating user sections base

This commit is contained in:
Cayo Puigdefabregas 2023-10-09 13:43:34 +02:00
parent 7253ed80a7
commit f96f8db957
14 changed files with 83 additions and 66 deletions

View File

@ -1,20 +0,0 @@
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import authenticate
class LoginForm(AuthenticationForm):
def clean(self):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')
if not (username and password):
raise self.get_invalid_login_error()
user = authenticate(username=username, password=password)
if user is None:
raise self.get_invalid_login_error()
return self.cleaned_data

View File

@ -1,6 +1,6 @@
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth import views as auth_views from django.contrib.auth import views as auth_views
from django.urls import reverse_lazy from django.urls import reverse_lazy, resolve
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from django.shortcuts import redirect from django.shortcuts import redirect
@ -13,6 +13,11 @@ class UserView(LoginRequiredMixin, TemplateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context.update({ context.update({
'title': self.title, 'title': self.title,
'subtitle': self.subtitle,
'icon': self.icon,
'section': self.section,
'path': resolve(self.request.path).url_name,
'user': self.request.user
}) })
return context return context

View File

@ -50,7 +50,7 @@
<div class="navbar-nav"> <div class="navbar-nav">
<div class="nav-item text-nowrap"> <div class="nav-item text-nowrap">
<i id="user-avatar" class="bi bi-person-circle"></i> <i id="user-avatar" class="bi bi-person-circle"></i>
<a class="navbar-sub-brand px-3" href="#">Lorena</a> <a class="navbar-sub-brand px-3" href="#">{{ user.username }}</a>
<a class="logout" href="{% url 'idhub:logout' %}"> <a class="logout" href="{% url 'idhub:logout' %}">
<i class="fa-solid fa-arrow-right-from-bracket"></i> <i class="fa-solid fa-arrow-right-from-bracket"></i>
</a> </a>
@ -64,59 +64,59 @@
<div class="position-sticky pt-5"> <div class="position-sticky pt-5">
<ul class="nav flex-column"> <ul class="nav flex-column">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link fw-bold" aria-current="page" href="#"> <a class="nav-link {% if section == 'Home' %}active {% endif %}fw-bold" aria-current="page" href="{% url 'idhub:user_dashboard' %}">
<i class="bi bi-house-door icon_sidebar"></i> <i class="bi bi-house-door icon_sidebar"></i>
Home Home
</a> </a>
<hr /> <hr />
</li> </li>
<li class="nav-item"> <li class="nav-item">
<span class="nav-link fw-bold" href="#"> <span class="nav-link {% if section == 'MyProfile' %}active {% endif %}fw-bold">
<i class="fa-regular fa-user icon_sidebar"></i> <i class="fa-regular fa-user icon_sidebar"></i>
My datas My datas
</span> </span>
<ul class="flex-column mb-2 ul_sidebar"> <ul class="flex-column mb-2 ul_sidebar">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#"> <a class="nav-link {% if path == 'user_profile' %}active2{% endif %}" href="{% url 'idhub:user_profile' %}">
My personal data My personal data
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#"> <a class="nav-link {% if path == 'user_roles' %}active2{% endif %}" href="{% url 'idhub:user_roles' %}">
My roles My roles
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#"> <a class="nav-link {% if path == 'user_gdpr' %}active2{% endif %}" href="{% url 'idhub:user_gdpr' %}">
GDPR info GDPR info
</a> </a>
</li> </li>
</ul> </ul>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<span class="nav-link active fw-bold" href="#"> <span class="nav-link {% if section == 'MyWallet' %}active {% endif %}fw-bold" href="#">
<i class="bi bi-patch-check icon_sidebar"></i> <i class="bi bi-patch-check icon_sidebar"></i>
My Wallet My Wallet
</span> </span>
<ul class="flex-column mb-2 ul_sidebar"> <ul class="flex-column mb-2 ul_sidebar">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active2" href="#"> <a class="nav-link {% if path == 'user_identities' %}active2{% endif %}" href="{% url 'idhub:user_identities' %}">
Identities (DID) Identities (DID)
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#"> <a class="nav-link {% if path == 'user_credentials' %}active2{% endif %}" href="{% url 'idhub:user_credentials' %}">
Credentials Credentials
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#"> <a class="nav-link {% if path == 'user_credentials_required' %}active2{% endif %}" href="{% url 'idhub:user_credentials_required' %}">
Credentials required Credentials required
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#"> <a class="nav-link {% if path == 'user_credentials_presentation' %}active2{% endif %}" href="{% url 'idhub:user_credentials_presentation' %}">
Present Credentials Credentials Presentation
</a> </a>
</li> </li>
</ul> </ul>
@ -145,6 +145,10 @@
</div> </div>
</div> </div>
<h3>
<i class="{{ icon }}"></i>
{{ subtitle }}
</h3>
{% block content %} {% block content %}
{% endblock content %} {% endblock content %}

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -2,10 +2,6 @@
{% load i18n %} {% load i18n %}
{% block content %} {% block content %}
<h3>
<i class="bi bi-patch-check"></i>
Identities (DID)
</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sm"> <table class="table table-striped table-sm">
<thead> <thead>

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,5 @@
{% extends "idhub/base.html" %}
{% load i18n %}
{% block content %}
{% endblock %}

View File

@ -18,16 +18,37 @@ from django.contrib.auth import views as auth_views
from django.views.generic import RedirectView from django.views.generic import RedirectView
from django.urls import path, reverse_lazy from django.urls import path, reverse_lazy
from .views import LoginView from .views import LoginView
from .views_admin import AdminDashboardView from .admin.views import AdminDashboardView
from .views_user import UserDashboardView from .user import views as views_user
app_name = 'idhub' app_name = 'idhub'
urlpatterns = [ urlpatterns = [
path("", RedirectView.as_view(url=reverse_lazy('idhub:login'), permanent=False)), path("", RedirectView.as_view(url=reverse_lazy('idhub:login'),
permanent=False)),
path('login/', LoginView.as_view(), name='login'), path('login/', LoginView.as_view(), name='login'),
path('logout/', auth_views.LogoutView.as_view(), name='logout'), path('logout/', auth_views.LogoutView.as_view(), name='logout'),
path('user/dashboard/', UserDashboardView.as_view(), name='user_dashboard'), path('admin/dashboard/', AdminDashboardView.as_view(),
path('admin/dashboard/', AdminDashboardView.as_view(), name='admin_dashboard'), name='admin_dashboard'),
# User
path('user/dashboard/', views_user.UserDashboardView.as_view(),
name='user_dashboard'),
path('user/profile/', views_user.UserProfileView.as_view(),
name='user_profile'),
path('user/roles/', views_user.UserRolesView.as_view(),
name='user_roles'),
path('user/gdpr/', views_user.UserGDPRView.as_view(),
name='user_gdpr'),
path('user/identities/', views_user.UserIdentitiesView.as_view(),
name='user_identities'),
path('user/credentials/', views_user.UserCredentialsView.as_view(),
name='user_credentials'),
path('user/credentials_required/',
views_user.UserCredentialsRequiredView.as_view(),
name='user_credentials_required'),
path('user/credentials_presentation/',
views_user.UserCredentialsPresentationView.as_view(),
name='user_credentials_presentation'),
] ]

View File

@ -1,12 +0,0 @@
import logging
from django.utils.translation import gettext_lazy as _
from django.urls import reverse_lazy
from django.contrib import messages
from .mixins import AdminView
class AdminDashboardView(AdminView):
template_name = "idhub/admin_dashboard.html"
title = _('Dashboard')

View File

@ -1,12 +0,0 @@
import logging
from django.utils.translation import gettext_lazy as _
from django.urls import reverse_lazy
from django.contrib import messages
from .mixins import UserView
class UserDashboardView(UserView):
template_name = "idhub/user_dashboard.html"
title = _('Dashboard')