create a new user and edit it
This commit is contained in:
parent
e0cceda122
commit
9ad6be8db6
10
idhub/admin/forms.py
Normal file
10
idhub/admin/forms.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class ProfileForm(forms.ModelForm):
|
||||
MANDATORY_FIELDS = ['first_name', 'last_name', 'email']
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('first_name', 'last_name', 'email')
|
|
@ -2,11 +2,13 @@ import logging
|
|||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.views.generic.edit import UpdateView, CreateView
|
||||
from django.contrib.auth.models import User
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.urls import reverse_lazy
|
||||
from django.contrib import messages
|
||||
from idhub.mixins import AdminView
|
||||
from idhub.admin.forms import ProfileForm
|
||||
|
||||
|
||||
class AdminDashboardView(AdminView, TemplateView):
|
||||
|
@ -16,7 +18,7 @@ class AdminDashboardView(AdminView, TemplateView):
|
|||
icon = 'bi bi-bell'
|
||||
section = "Home"
|
||||
|
||||
class People(AdminView, TemplateView):
|
||||
class People(AdminView):
|
||||
title = _("People Management")
|
||||
section = "People"
|
||||
|
||||
|
@ -41,7 +43,7 @@ class ImportExport(AdminView, TemplateView):
|
|||
section = "ImportExport"
|
||||
|
||||
|
||||
class AdminPeopleListView(People):
|
||||
class AdminPeopleListView(People, TemplateView):
|
||||
template_name = "idhub/admin_people.html"
|
||||
subtitle = _('People list')
|
||||
icon = 'bi bi-person'
|
||||
|
@ -54,7 +56,7 @@ class AdminPeopleListView(People):
|
|||
return context
|
||||
|
||||
|
||||
class AdminPeopleView(People):
|
||||
class AdminPeopleView(People, TemplateView):
|
||||
template_name = "idhub/admin_user.html"
|
||||
subtitle = _('User Profile')
|
||||
icon = 'bi bi-person'
|
||||
|
@ -98,11 +100,21 @@ class AdminPeopleDeleteView(AdminPeopleView):
|
|||
|
||||
return redirect('idhub:admin_people_list')
|
||||
|
||||
class AdminPeopleEditView(AdminPeopleView, UpdateView):
|
||||
template_name = "idhub/admin_user_edit.html"
|
||||
from_class = ProfileForm
|
||||
fields = ('first_name', 'last_name', 'email')
|
||||
success_url = reverse_lazy('idhub:admin_people_list')
|
||||
|
||||
class AdminPeopleRegisterView(People):
|
||||
|
||||
class AdminPeopleRegisterView(People, CreateView):
|
||||
template_name = "idhub/admin_people_register.html"
|
||||
subtitle = _('People Register')
|
||||
icon = 'bi bi-person'
|
||||
model = User
|
||||
from_class = ProfileForm
|
||||
fields = ('first_name', 'last_name', 'email')
|
||||
success_url = reverse_lazy('idhub:admin_people_list')
|
||||
|
||||
|
||||
class AdminRolesView(AccessControl):
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
|
|
|
@ -2,4 +2,31 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% 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,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
32
idhub/templates/idhub/admin_user_edit.html
Normal file
32
idhub/templates/idhub/admin_user_edit.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
{% extends "idhub/base_admin.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% 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,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,4 +2,8 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% endblock %}
|
||||
|
|
|
@ -216,10 +216,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<h3>
|
||||
<i class="{{ icon }}"></i>
|
||||
{{ subtitle }}
|
||||
</h3>
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ urlpatterns = [
|
|||
name='admin_people_list'),
|
||||
path('admin/people/<int:pk>', views_admin.AdminPeopleView.as_view(),
|
||||
name='admin_people'),
|
||||
path('admin/people/<int:pk>/edit', views_admin.AdminPeopleView.as_view(),
|
||||
path('admin/people/<int:pk>/edit', views_admin.AdminPeopleEditView.as_view(),
|
||||
name='admin_people_edit'),
|
||||
path('admin/people/<int:pk>/del', views_admin.AdminPeopleDeleteView.as_view(),
|
||||
name='admin_people_delete'),
|
||||
|
|
Loading…
Reference in a new issue