Fix les ACL sur les catégories
This commit is contained in:
parent
c702bdf519
commit
03e361d976
1 changed files with 19 additions and 6 deletions
|
@ -17,12 +17,16 @@ class ViewCategory(generic.DetailView):
|
|||
template_name = "content/content_list.html"
|
||||
|
||||
|
||||
class CreateCategory(PermissionRequiredMixin, generic.CreateView):
|
||||
class CreateCategory(generic.CreateView):
|
||||
"""Création de catégorie."""
|
||||
model = Category
|
||||
fields = '__all__'
|
||||
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):
|
||||
context = super(generic.CreateView, self).get_context_data(**kwargs)
|
||||
|
@ -30,20 +34,29 @@ class CreateCategory(PermissionRequiredMixin, generic.CreateView):
|
|||
return context
|
||||
|
||||
|
||||
class DeleteCategory(PermissionRequiredMixin, generic.DeleteView):
|
||||
class DeleteCategory(generic.DeleteView):
|
||||
"""Suppression de catégorie"""
|
||||
model = Category
|
||||
success_url = reverse_lazy('settings:index')
|
||||
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."""
|
||||
model = Category
|
||||
fields = '__all__'
|
||||
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):
|
||||
context = super(generic.UpdateView, self).get_context_data(**kwargs)
|
||||
context['title'] = "Édition de " + self.object.name
|
||||
|
|
Loading…
Reference in a new issue