add form for editing profile
This commit is contained in:
parent
6cef5e4eb2
commit
c17e0341ee
|
@ -1,39 +1,40 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
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.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from idhub.mixins import AdminView
|
from idhub.mixins import AdminView
|
||||||
|
|
||||||
|
|
||||||
class AdminDashboardView(AdminView):
|
class AdminDashboardView(AdminView, TemplateView):
|
||||||
template_name = "idhub/admin_dashboard.html"
|
template_name = "idhub/admin_dashboard.html"
|
||||||
title = _('Dashboard')
|
title = _('Dashboard')
|
||||||
subtitle = _('Success')
|
subtitle = _('Success')
|
||||||
icon = 'bi bi-bell'
|
icon = 'bi bi-bell'
|
||||||
section = "Home"
|
section = "Home"
|
||||||
|
|
||||||
class People(AdminView):
|
class People(AdminView, TemplateView):
|
||||||
title = _("People Management")
|
title = _("People Management")
|
||||||
section = "People"
|
section = "People"
|
||||||
|
|
||||||
|
|
||||||
class AccessControl(AdminView):
|
class AccessControl(AdminView, TemplateView):
|
||||||
title = _("Access Control Management")
|
title = _("Access Control Management")
|
||||||
section = "AccessControl"
|
section = "AccessControl"
|
||||||
|
|
||||||
|
|
||||||
class Credentials(AdminView):
|
class Credentials(AdminView, TemplateView):
|
||||||
title = _("Credentials Management")
|
title = _("Credentials Management")
|
||||||
section = "Credentials"
|
section = "Credentials"
|
||||||
|
|
||||||
|
|
||||||
class Schemes(AdminView):
|
class Schemes(AdminView, TemplateView):
|
||||||
title = _("Schemes Management")
|
title = _("Schemes Management")
|
||||||
section = "Schemes"
|
section = "Schemes"
|
||||||
|
|
||||||
|
|
||||||
class ImportExport(AdminView):
|
class ImportExport(AdminView, TemplateView):
|
||||||
title = _("Massive Data Management")
|
title = _("Massive Data Management")
|
||||||
section = "ImportExport"
|
section = "ImportExport"
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,10 @@ 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, resolve
|
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.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
|
|
||||||
|
|
||||||
class UserView(LoginRequiredMixin, TemplateView):
|
class UserView(LoginRequiredMixin):
|
||||||
login_url = "/login/"
|
login_url = "/login/"
|
||||||
wallet = False
|
wallet = False
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,27 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% load django_bootstrap5 %}
|
||||||
|
<form role="form" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% if form.errors %}
|
||||||
|
<div class="alert alert-danger alert-icon alert-icon-border alert-dismissible" role="alert">
|
||||||
|
<div class="icon"><span class="mdi mdi-close-circle-o"></span></div>
|
||||||
|
<div class="message">
|
||||||
|
<button class="close" type="button" data-dismiss="alert" aria-label="Close">
|
||||||
|
<span class="mdi mdi-close" aria-hidden="true"></span>
|
||||||
|
</button>
|
||||||
|
{% for field, error in form.errors.items %}
|
||||||
|
{{ error }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% bootstrap_form form %}
|
||||||
|
<div class="form-actions-no-box">
|
||||||
|
<a class="btn btn-secondary" href="{% url 'idhub:user_profile' %}">{% translate "Cancel" %}</a>
|
||||||
|
<input class="btn btn-success" type="submit" name="submit" value="{% translate 'Save' %}" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -2,10 +2,9 @@ from django import forms
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
class ProfileForm(form.ModelForm):
|
class ProfileForm(forms.ModelForm):
|
||||||
MANDATORY_FIELDS = ['first_name', 'last_name', 'email']
|
MANDATORY_FIELDS = ['first_name', 'last_name', 'email']
|
||||||
OPTIONAL_FIELDS = []
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ('forst_name', 'last_name', 'email')
|
fields = ('first_name', 'last_name', 'email')
|
|
@ -1,8 +1,11 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.views.generic.edit import UpdateView
|
||||||
|
from django.views.generic.base import TemplateView
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
from idhub.user.forms import ProfileForm
|
||||||
from idhub.mixins import UserView
|
from idhub.mixins import UserView
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,12 +14,12 @@ class MyProfile(UserView):
|
||||||
section = "MyProfile"
|
section = "MyProfile"
|
||||||
|
|
||||||
|
|
||||||
class MyWallet(UserView):
|
class MyWallet(UserView, TemplateView):
|
||||||
title = _("My Wallet")
|
title = _("My Wallet")
|
||||||
section = "MyWallet"
|
section = "MyWallet"
|
||||||
|
|
||||||
|
|
||||||
class UserDashboardView(UserView):
|
class UserDashboardView(UserView, TemplateView):
|
||||||
template_name = "idhub/user_dashboard.html"
|
template_name = "idhub/user_dashboard.html"
|
||||||
title = _('Dashboard')
|
title = _('Dashboard')
|
||||||
subtitle = _('Success')
|
subtitle = _('Success')
|
||||||
|
@ -24,19 +27,25 @@ class UserDashboardView(UserView):
|
||||||
section = "Home"
|
section = "Home"
|
||||||
|
|
||||||
|
|
||||||
class UserProfileView(MyProfile):
|
class UserProfileView(MyProfile, UpdateView):
|
||||||
template_name = "idhub/user_profile.html"
|
template_name = "idhub/user_profile.html"
|
||||||
subtitle = _('My personal Data')
|
subtitle = _('My personal Data')
|
||||||
icon = 'bi bi-person'
|
icon = 'bi bi-person'
|
||||||
|
from_class = ProfileForm
|
||||||
|
fields = ('first_name', 'last_name', 'email')
|
||||||
|
success_url = reverse_lazy('idhub:user_profile')
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
return self.request.user
|
||||||
|
|
||||||
|
|
||||||
class UserRolesView(MyProfile):
|
class UserRolesView(MyProfile, TemplateView):
|
||||||
template_name = "idhub/user_roles.html"
|
template_name = "idhub/user_roles.html"
|
||||||
subtitle = _('My roles')
|
subtitle = _('My roles')
|
||||||
icon = 'fa-brands fa-critical-role'
|
icon = 'fa-brands fa-critical-role'
|
||||||
|
|
||||||
|
|
||||||
class UserGDPRView(MyProfile):
|
class UserGDPRView(MyProfile, TemplateView):
|
||||||
template_name = "idhub/user_gdpr.html"
|
template_name = "idhub/user_gdpr.html"
|
||||||
subtitle = _('GDPR info')
|
subtitle = _('GDPR info')
|
||||||
icon = 'bi bi-file-earmark-medical'
|
icon = 'bi bi-file-earmark-medical'
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
django==4.2.5
|
django==4.2.5
|
||||||
django-bootstrap4==23.2
|
django-bootstrap5==23.3
|
||||||
django-extensions==3.2.3
|
django-extensions==3.2.3
|
||||||
|
|
|
@ -38,7 +38,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'bootstrap4',
|
'django_bootstrap5',
|
||||||
'idhub'
|
'idhub'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue