added institution edit view help text and icons
This commit is contained in:
parent
65d5b48a2e
commit
fc73e9b319
|
@ -1,32 +1,49 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load i18n django_bootstrap5 %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ subtitle }}</h3>
|
||||
<div class="ms-3 mt-4">
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<h3>{{ subtitle }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% 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">
|
||||
{% for field, error in form.errors.items %}
|
||||
{{ error }}<br />
|
||||
{% endfor %}
|
||||
<button class="btn-close" type="button" data-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% bootstrap_form form %}
|
||||
<div class="form-actions-no-box">
|
||||
<a class="btn btn-grey" href="{% url 'admin:panel' %}">{% translate "Cancel" %}</a>
|
||||
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
|
||||
</div>
|
||||
<form role="form" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
|
||||
</form>
|
||||
{% if form.errors %}
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<strong>{% translate "Please fix the following errors:" %}</strong>
|
||||
<ul>
|
||||
{% for field, errors in form.errors.items %}
|
||||
<li>{{ field|title }}: {{ errors|join:", " }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{% bootstrap_field form.name addon_before='<i class="bi bi-building"></i>' %}
|
||||
{% bootstrap_field form.location addon_before='<i class="bi bi-geo-alt-fill"></i>' %}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{% bootstrap_field form.responsable_person addon_before='<i class="bi bi-person-fill"></i>' %}
|
||||
{% bootstrap_field form.supervisor_person addon_before='<i class="bi bi-person-check-fill"></i>' %}
|
||||
{% bootstrap_field form.logo addon_before='<i class="bi bi-image-fill"></i>' %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions mt-5 ms-2">
|
||||
<a class="btn btn-secondary" href="{% url 'admin:panel' %}">
|
||||
{% translate "Cancel" %}
|
||||
</a>
|
||||
<button type="submit" class="btn btn-green-admin ms-3">
|
||||
<i class="bi bi-floppy me-2"></i>{% translate "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -127,6 +127,16 @@ class InstitutionView(AdminView, UpdateView):
|
|||
"supervisor_person"
|
||||
)
|
||||
|
||||
def get_form(self, form_class=None):
|
||||
form = super().get_form(form_class)
|
||||
form.fields["name"].help_text = _("Full name of the institution.")
|
||||
form.fields["logo"].help_text = _("URL to the institution's logo.")
|
||||
form.fields["location"].help_text = _("The address or city of the institution.")
|
||||
form.fields["responsable_person"].help_text = _("Name of the institution's responsable person.")
|
||||
form.fields["supervisor_person"].help_text = _("The supervisor's full name.")
|
||||
|
||||
return form
|
||||
|
||||
def get_form_kwargs(self):
|
||||
self.object = self.request.user.institution
|
||||
kwargs = super().get_form_kwargs()
|
||||
|
|
Loading…
Reference in a new issue