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 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.views.generic.base import TemplateView
from django.shortcuts import redirect
@ -13,6 +13,11 @@ class UserView(LoginRequiredMixin, TemplateView):
context = super().get_context_data(**kwargs)
context.update({
'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

View file

@ -50,7 +50,7 @@
<div class="navbar-nav">
<div class="nav-item text-nowrap">
<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' %}">
<i class="fa-solid fa-arrow-right-from-bracket"></i>
</a>
@ -64,59 +64,59 @@
<div class="position-sticky pt-5">
<ul class="nav flex-column">
<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>
Home
</a>
<hr />
</li>
<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>
My datas
</span>
<ul class="flex-column mb-2 ul_sidebar">
<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
</a>
</li>
<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
</a>
</li>
<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
</a>
</li>
</ul>
</li>
<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>
My Wallet
</span>
<ul class="flex-column mb-2 ul_sidebar">
<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)
</a>
</li>
<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
</a>
</li>
<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
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
Present Credentials
<a class="nav-link {% if path == 'user_credentials_presentation' %}active2{% endif %}" href="{% url 'idhub:user_credentials_presentation' %}">
Credentials Presentation
</a>
</li>
</ul>
@ -145,6 +145,10 @@
</div>
</div>
<h3>
<i class="{{ icon }}"></i>
{{ subtitle }}
</h3>
{% block 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 %}
{% block content %}
<h3>
<i class="bi bi-patch-check"></i>
Identities (DID)
</h3>
<div class="table-responsive">
<table class="table table-striped table-sm">
<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.urls import path, reverse_lazy
from .views import LoginView
from .views_admin import AdminDashboardView
from .views_user import UserDashboardView
from .admin.views import AdminDashboardView
from .user import views as views_user
app_name = 'idhub'
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('logout/', auth_views.LogoutView.as_view(), name='logout'),
path('user/dashboard/', UserDashboardView.as_view(), name='user_dashboard'),
path('admin/dashboard/', AdminDashboardView.as_view(), name='admin_dashboard'),
path('admin/dashboard/', AdminDashboardView.as_view(),
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')