mirror of
https://github.com/ae-utbm/sith.git
synced 2025-02-21 06:57:11 +00:00
Allow some customisation in core/edit.jinja
This commit is contained in:
parent
05d4a09f8c
commit
6bf02cecd9
@ -1,19 +1,40 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
|
||||
{# if the template context has the `object_name` variable,
|
||||
then this one will be used in the page title,
|
||||
instead of the result of `str(object)` #}
|
||||
{% if object and not object_name %}
|
||||
{% set object_name=object %}
|
||||
{% endif %}
|
||||
|
||||
{% block title %}
|
||||
{% if object %}
|
||||
{% trans obj=object %}Edit {{ obj }}{% endtrans %}
|
||||
{% if object_name %}
|
||||
{% trans name=object_name %}Edit {{ name }}{% endtrans %}
|
||||
{% else %}
|
||||
{% trans %}Save{% endtrans %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if object %}
|
||||
<h2>{% trans obj=object %}Edit {{ obj }}{% endtrans %}</h2>
|
||||
{% if object_name %}
|
||||
<h2>{% trans name=object_name %}Edit {{ name }}{% endtrans %}</h2>
|
||||
{% else %}
|
||||
<h2>{% trans %}Save{% endtrans %}</h2>
|
||||
{% endif %}
|
||||
{% if messages %}
|
||||
<div x-data="{show_alert: true}" class="alert alert-green" x-show="show_alert" x-transition>
|
||||
<span class="alert-main">
|
||||
{% for message in messages %}
|
||||
{% if message.level_tag == "success" %}
|
||||
{{ message }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</span>
|
||||
<span class="clickable" @click="show_alert = false">
|
||||
<i class="fa fa-close"></i>
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p() }}
|
||||
|
@ -18,6 +18,7 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse_lazy
|
||||
@ -136,7 +137,9 @@ class GroupDeleteView(CanEditMixin, DeleteView):
|
||||
success_url = reverse_lazy("core:group_list")
|
||||
|
||||
|
||||
class PermissionGroupsUpdateView(PermissionRequiredMixin, UpdateView):
|
||||
class PermissionGroupsUpdateView(
|
||||
PermissionRequiredMixin, SuccessMessageMixin, UpdateView
|
||||
):
|
||||
"""Manage the groups that have a specific permission.
|
||||
|
||||
Notes:
|
||||
@ -151,9 +154,8 @@ class PermissionGroupsUpdateView(PermissionRequiredMixin, UpdateView):
|
||||
|
||||
Example:
|
||||
```python
|
||||
class AddSubscriptionGroupsView(PermissionGroupsUpdateView):
|
||||
class SubscriptionPermissionView(PermissionGroupsUpdateView):
|
||||
permission = "subscription.add_subscription"
|
||||
success_url = reverse_lazy("foo:bar")
|
||||
```
|
||||
"""
|
||||
|
||||
@ -161,6 +163,7 @@ class PermissionGroupsUpdateView(PermissionRequiredMixin, UpdateView):
|
||||
template_name = "core/edit.jinja"
|
||||
form_class = PermissionGroupsForm
|
||||
permission = None
|
||||
success_message = _("Groups have been successfully updated.")
|
||||
|
||||
def get_object(self, *args, **kwargs):
|
||||
if not self.permission:
|
||||
|
@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-02-12 15:32+0100\n"
|
||||
"POT-Creation-Date: 2025-02-12 15:55+0100\n"
|
||||
"PO-Revision-Date: 2016-07-18\n"
|
||||
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||
@ -2383,11 +2383,10 @@ msgstr "Confirmation"
|
||||
msgid "Cancel"
|
||||
msgstr "Annuler"
|
||||
|
||||
#: core/templates/core/edit.jinja core/templates/core/file_edit.jinja
|
||||
#: counter/templates/counter/cash_register_summary.jinja
|
||||
#: core/templates/core/edit.jinja
|
||||
#, python-format
|
||||
msgid "Edit %(obj)s"
|
||||
msgstr "Éditer %(obj)s"
|
||||
msgid "Edit %(name)s"
|
||||
msgstr "Éditer %(name)s"
|
||||
|
||||
#: core/templates/core/file.jinja core/templates/core/file_list.jinja
|
||||
msgid "File list"
|
||||
@ -2457,6 +2456,12 @@ msgstr "octets"
|
||||
msgid "Download"
|
||||
msgstr "Télécharger"
|
||||
|
||||
#: core/templates/core/file_edit.jinja
|
||||
#: counter/templates/counter/cash_register_summary.jinja
|
||||
#, python-format
|
||||
msgid "Edit %(obj)s"
|
||||
msgstr "Éditer %(obj)s"
|
||||
|
||||
#: core/templates/core/file_list.jinja
|
||||
msgid "There is no file in this website."
|
||||
msgstr "Il n'y a pas de fichier sur ce site web."
|
||||
@ -3359,6 +3364,10 @@ msgstr "Utilisateurs à ajouter au groupe"
|
||||
msgid "Users to remove from group"
|
||||
msgstr "Utilisateurs à retirer du groupe"
|
||||
|
||||
#: core/views/group.py
|
||||
msgid "Groups have been successfully updated."
|
||||
msgstr "Les groupes ont été mis à jour avec succès."
|
||||
|
||||
#: core/views/user.py
|
||||
msgid "We couldn't verify that this email actually exists"
|
||||
msgstr "Nous n'avons pas réussi à vérifier que cette adresse mail existe."
|
||||
@ -5680,6 +5689,10 @@ msgstr "Cotisations par type"
|
||||
msgid "Existing member"
|
||||
msgstr "Membre existant"
|
||||
|
||||
#: subscription/views.py
|
||||
msgid "the groups that can create subscriptions"
|
||||
msgstr "les groupes pouvant créer des cotisations"
|
||||
|
||||
#: trombi/models.py
|
||||
msgid "subscription deadline"
|
||||
msgstr "fin des inscriptions"
|
||||
|
@ -18,6 +18,7 @@ from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils.timezone import localdate
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import CreateView, DetailView, TemplateView
|
||||
from django.views.generic.edit import FormView
|
||||
|
||||
@ -82,6 +83,7 @@ class SubscriptionPermissionView(PermissionGroupsUpdateView):
|
||||
"""Manage the groups that have access to the subscription creation page."""
|
||||
|
||||
permission = "subscription.add_subscription"
|
||||
extra_context = {"object_name": _("the groups that can create subscriptions")}
|
||||
|
||||
|
||||
class SubscriptionsStatsView(FormView):
|
||||
|
Loading…
x
Reference in New Issue
Block a user