Fix les ACL sur les catégories

This commit is contained in:
klafyvel 2018-03-12 10:18:58 +01:00 committed by root
parent c702bdf519
commit 03e361d976

View file

@ -17,12 +17,16 @@ class ViewCategory(generic.DetailView):
template_name = "content/content_list.html" template_name = "content/content_list.html"
class CreateCategory(PermissionRequiredMixin, generic.CreateView): class CreateCategory(generic.CreateView):
"""Création de catégorie.""" """Création de catégorie."""
model = Category model = Category
fields = '__all__' fields = '__all__'
template_name = "edit.html" template_name = "edit.html"
permission_required = 'content.add_category'
@classmethod
def as_view(self, *args, **kwargs):
view = super().as_view(*args, **kwargs)
return staff_member_required(view)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(generic.CreateView, self).get_context_data(**kwargs) context = super(generic.CreateView, self).get_context_data(**kwargs)
@ -30,20 +34,29 @@ class CreateCategory(PermissionRequiredMixin, generic.CreateView):
return context return context
class DeleteCategory(PermissionRequiredMixin, generic.DeleteView): class DeleteCategory(generic.DeleteView):
"""Suppression de catégorie""" """Suppression de catégorie"""
model = Category model = Category
success_url = reverse_lazy('settings:index') success_url = reverse_lazy('settings:index')
template_name = "confirm_delete.html" template_name = "confirm_delete.html"
permission_required = 'content.delete_category'
@classmethod
def as_view(self, *args, **kwargs):
view = super().as_view(*args, **kwargs)
return staff_member_required(view)
class EditCategory(PermissionRequiredMixin, generic.UpdateView): class EditCategory(generic.UpdateView):
"""Édition de catégorie.""" """Édition de catégorie."""
model = Category model = Category
fields = '__all__' fields = '__all__'
template_name = "edit.html" template_name = "edit.html"
permission_required = 'content.change_category'
@classmethod
def as_view(self, *args, **kwargs):
view = super().as_view(*args, **kwargs)
return staff_member_required(view)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(generic.UpdateView, self).get_context_data(**kwargs) context = super(generic.UpdateView, self).get_context_data(**kwargs)
context['title'] = "Édition de " + self.object.name context['title'] = "Édition de " + self.object.name