mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Fix Page locking
This commit is contained in:
@ -37,6 +37,12 @@ class CanCreateMixin(View):
|
||||
This view is made to protect any child view that would create an object, and thus, that can not be protected by any
|
||||
of the following mixin
|
||||
"""
|
||||
def dispatch(self, request, *arg, **kwargs):
|
||||
res = super(CanCreateMixin, self).dispatch(request, *arg, **kwargs)
|
||||
if not request.user.is_authenticated():
|
||||
raise PermissionDenied
|
||||
return res
|
||||
|
||||
def form_valid(self, form):
|
||||
obj = form.instance
|
||||
if can_edit_prop(obj, self.request.user):
|
||||
|
@ -9,7 +9,7 @@ from django.forms import CheckboxSelectMultiple
|
||||
|
||||
from core.models import Page, PageRev, LockError
|
||||
from core.views.forms import PagePropForm
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin
|
||||
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin
|
||||
|
||||
class PageListView(CanViewMixin, ListView):
|
||||
model = Page
|
||||
@ -59,7 +59,7 @@ class PageRevView(CanViewMixin, DetailView):
|
||||
context['new_page'] = self.kwargs['page_name']
|
||||
return context
|
||||
|
||||
class PageCreateView(CanEditPropMixin, CreateView):
|
||||
class PageCreateView(CanCreateMixin, CreateView):
|
||||
model = Page
|
||||
form_class = modelform_factory(Page,
|
||||
fields = ['parent', 'name', 'owner_group', 'edit_groups', 'view_groups', ],
|
||||
|
Reference in New Issue
Block a user