mirror of
https://github.com/ae-utbm/sith.git
synced 2026-10-30 22:29:32 +00:00
fix: permission check on SithFile move
This commit is contained in:
1 parent
f5a5782bac
commit
59cdebbf4f
1 file changed
+8
-5
+8
-5
@@ -21,7 +21,7 @@ from wsgiref.util import FileWrapper
|
|||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied, ValidationError
|
||||||
from django.db.models import Exists, OuterRef
|
from django.db.models import Exists, OuterRef
|
||||||
from django.forms.models import modelform_factory
|
from django.forms.models import modelform_factory
|
||||||
from django.http import Http404, HttpRequest, HttpResponse
|
from django.http import Http404, HttpRequest, HttpResponse
|
||||||
@@ -233,6 +233,12 @@ class FileEditPropForm(forms.ModelForm):
|
|||||||
|
|
||||||
recursive = forms.BooleanField(label=_("Apply rights recursively"), required=False)
|
recursive = forms.BooleanField(label=_("Apply rights recursively"), required=False)
|
||||||
|
|
||||||
|
def clean_parent(self):
|
||||||
|
parent = self.cleaned_data["parent"]
|
||||||
|
if not self.instance.owner.can_edit(parent):
|
||||||
|
raise ValidationError(_("You cannot move this file there"))
|
||||||
|
return parent
|
||||||
|
|
||||||
|
|
||||||
class FileEditPropView(CanEditPropMixin, UpdateView):
|
class FileEditPropView(CanEditPropMixin, UpdateView):
|
||||||
model = SithFile
|
model = SithFile
|
||||||
@@ -253,10 +259,7 @@ class FileEditPropView(CanEditPropMixin, UpdateView):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse(
|
return reverse("core:file_detail", kwargs={"file_id": self.object.id})
|
||||||
"core:file_detail",
|
|
||||||
kwargs={"file_id": self.object.id},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FileView(CanViewMixin, DetailView, FormMixin):
|
class FileView(CanViewMixin, DetailView, FormMixin):
|
||||||
|
|||||||
Reference in new issue
Block a user