forked from DGNum/gestioCOF
Add missing perms to view/edit kfet config
This commit is contained in:
parent
2cfce1c921
commit
414b0eb433
4 changed files with 30 additions and 7 deletions
18
kfet/migrations/0057_add_perms_config.py
Normal file
18
kfet/migrations/0057_add_perms_config.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('kfet', '0056_change_account_meta'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='account',
|
||||
options={'permissions': (('is_team', 'Is part of the team'), ('manage_perms', 'Gérer les permissions K-Fêt'), ('manage_addcosts', 'Gérer les majorations'), ('edit_balance_account', "Modifier la balance d'un compte"), ('change_account_password', "Modifier le mot de passe d'une personne de l'équipe"), ('special_add_account', 'Créer un compte avec une balance initiale'), ('can_force_close', 'Fermer manuellement la K-Fêt'), ('see_config', 'Voir la configuration K-Fêt'), ('change_config', 'Modifier la configuration K-Fêt'))},
|
||||
),
|
||||
]
|
|
@ -75,6 +75,8 @@ class Account(models.Model):
|
|||
('special_add_account',
|
||||
"Créer un compte avec une balance initiale"),
|
||||
('can_force_close', "Fermer manuellement la K-Fêt"),
|
||||
('see_config', "Voir la configuration K-Fêt"),
|
||||
('change_config', "Modifier la configuration K-Fêt"),
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -188,13 +188,9 @@ urlpatterns = [
|
|||
# Settings urls
|
||||
# -----
|
||||
|
||||
url(r'^settings/$',
|
||||
permission_required('kfet.change_settings')
|
||||
(views.SettingsList.as_view()),
|
||||
url(r'^settings/$', views.config_list,
|
||||
name='kfet.settings'),
|
||||
url(r'^settings/edit$',
|
||||
permission_required('kfet.change_settings')
|
||||
(views.SettingsUpdate.as_view()),
|
||||
url(r'^settings/edit$', views.config_update,
|
||||
name='kfet.settings.update'),
|
||||
|
||||
|
||||
|
|
|
@ -1452,6 +1452,9 @@ class SettingsList(TemplateView):
|
|||
template_name = 'kfet/settings.html'
|
||||
|
||||
|
||||
config_list = permission_required('kfet.see_config')(SettingsList.as_view())
|
||||
|
||||
|
||||
class SettingsUpdate(SuccessMessageMixin, FormView):
|
||||
form_class = KFetConfigForm
|
||||
template_name = 'kfet/settings_update.html'
|
||||
|
@ -1460,13 +1463,17 @@ class SettingsUpdate(SuccessMessageMixin, FormView):
|
|||
|
||||
def form_valid(self, form):
|
||||
# Checking permission
|
||||
if not self.request.user.has_perm('kfet.change_settings'):
|
||||
if not self.request.user.has_perm('kfet.change_config'):
|
||||
form.add_error(None, 'Permission refusée')
|
||||
return self.form_invalid(form)
|
||||
form.save()
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
config_update = (
|
||||
permission_required('kfet.change_config')(SettingsUpdate.as_view())
|
||||
)
|
||||
|
||||
|
||||
# -----
|
||||
# Transfer views
|
||||
|
|
Loading…
Reference in a new issue