add form for editing profile
This commit is contained in:
parent
6cef5e4eb2
commit
c17e0341ee
|
@ -1,39 +1,40 @@
|
|||
import logging
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.urls import reverse_lazy
|
||||
from django.contrib import messages
|
||||
from idhub.mixins import AdminView
|
||||
|
||||
|
||||
class AdminDashboardView(AdminView):
|
||||
class AdminDashboardView(AdminView, TemplateView):
|
||||
template_name = "idhub/admin_dashboard.html"
|
||||
title = _('Dashboard')
|
||||
subtitle = _('Success')
|
||||
icon = 'bi bi-bell'
|
||||
section = "Home"
|
||||
|
||||
class People(AdminView):
|
||||
class People(AdminView, TemplateView):
|
||||
title = _("People Management")
|
||||
section = "People"
|
||||
|
||||
|
||||
class AccessControl(AdminView):
|
||||
class AccessControl(AdminView, TemplateView):
|
||||
title = _("Access Control Management")
|
||||
section = "AccessControl"
|
||||
|
||||
|
||||
class Credentials(AdminView):
|
||||
class Credentials(AdminView, TemplateView):
|
||||
title = _("Credentials Management")
|
||||
section = "Credentials"
|
||||
|
||||
|
||||
class Schemes(AdminView):
|
||||
class Schemes(AdminView, TemplateView):
|
||||
title = _("Schemes Management")
|
||||
section = "Schemes"
|
||||
|
||||
|
||||
class ImportExport(AdminView):
|
||||
class ImportExport(AdminView, TemplateView):
|
||||
title = _("Massive Data Management")
|
||||
section = "ImportExport"
|
||||
|
||||
|
|
|
@ -2,11 +2,10 @@ from django.contrib.auth.mixins import LoginRequiredMixin
|
|||
from django.contrib.auth import views as auth_views
|
||||
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
|
||||
|
||||
|
||||
class UserView(LoginRequiredMixin, TemplateView):
|
||||
class UserView(LoginRequiredMixin):
|
||||
login_url = "/login/"
|
||||
wallet = False
|
||||
|
||||
|
|
|
@ -2,4 +2,27 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% 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 %}
|
||||
|
|
|
@ -2,10 +2,9 @@ from django import forms
|
|||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class ProfileForm(form.ModelForm):
|
||||
class ProfileForm(forms.ModelForm):
|
||||
MANDATORY_FIELDS = ['first_name', 'last_name', 'email']
|
||||
OPTIONAL_FIELDS = []
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('forst_name', 'last_name', 'email')
|
||||
fields = ('first_name', 'last_name', 'email')
|
|
@ -1,8 +1,11 @@
|
|||
import logging
|
||||
|
||||
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.contrib import messages
|
||||
from idhub.user.forms import ProfileForm
|
||||
from idhub.mixins import UserView
|
||||
|
||||
|
||||
|
@ -11,12 +14,12 @@ class MyProfile(UserView):
|
|||
section = "MyProfile"
|
||||
|
||||
|
||||
class MyWallet(UserView):
|
||||
class MyWallet(UserView, TemplateView):
|
||||
title = _("My Wallet")
|
||||
section = "MyWallet"
|
||||
|
||||
|
||||
class UserDashboardView(UserView):
|
||||
class UserDashboardView(UserView, TemplateView):
|
||||
template_name = "idhub/user_dashboard.html"
|
||||
title = _('Dashboard')
|
||||
subtitle = _('Success')
|
||||
|
@ -24,19 +27,25 @@ class UserDashboardView(UserView):
|
|||
section = "Home"
|
||||
|
||||
|
||||
class UserProfileView(MyProfile):
|
||||
class UserProfileView(MyProfile, UpdateView):
|
||||
template_name = "idhub/user_profile.html"
|
||||
subtitle = _('My personal Data')
|
||||
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"
|
||||
subtitle = _('My roles')
|
||||
icon = 'fa-brands fa-critical-role'
|
||||
|
||||
|
||||
class UserGDPRView(MyProfile):
|
||||
class UserGDPRView(MyProfile, TemplateView):
|
||||
template_name = "idhub/user_gdpr.html"
|
||||
subtitle = _('GDPR info')
|
||||
icon = 'bi bi-file-earmark-medical'
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
django==4.2.5
|
||||
django-bootstrap4==23.2
|
||||
django-bootstrap5==23.3
|
||||
django-extensions==3.2.3
|
||||
|
|
|
@ -38,7 +38,7 @@ INSTALLED_APPS = [
|
|||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'django_extensions',
|
||||
'bootstrap4',
|
||||
'django_bootstrap5',
|
||||
'idhub'
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue