Commit 57e9bcf1 by benjaoming

Fix #221 - not correctly inheriting some permissions, save() called on URLPath…

Fix #221 - not correctly inheriting some permissions, save() called on URLPath object instead of Article object!
parent 489f2c56
...@@ -340,6 +340,7 @@ class PermissionsForm(PluginSettingsFormMixin, forms.ModelForm): ...@@ -340,6 +340,7 @@ class PermissionsForm(PluginSettingsFormMixin, forms.ModelForm):
if permissions.can_assign(article, request.user): if permissions.can_assign(article, request.user):
self.can_assign = True self.can_assign = True
self.can_change_groups = True
self.fields['group'].queryset = models.Group.objects.all() self.fields['group'].queryset = models.Group.objects.all()
elif permissions.can_assign_owner(article, request.user): elif permissions.can_assign_owner(article, request.user):
self.fields['group'].queryset = models.Group.objects.filter(user=request.user) self.fields['group'].queryset = models.Group.objects.filter(user=request.user)
...@@ -382,7 +383,14 @@ class PermissionsForm(PluginSettingsFormMixin, forms.ModelForm): ...@@ -382,7 +383,14 @@ class PermissionsForm(PluginSettingsFormMixin, forms.ModelForm):
def save(self, commit=True): def save(self, commit=True):
article = super(PermissionsForm, self).save(commit=False) article = super(PermissionsForm, self).save(commit=False)
# Alter the owner according to the form field owner_username
# TODO: Why not rename this field to 'owner' so this happens automatically?
article.owner = self.cleaned_data['owner_username'] article.owner = self.cleaned_data['owner_username']
# Revert any changes to group permissions if the
# current user is not allowed (see __init__)
# TODO: Write clean methods for this instead!
if not self.can_change_groups: if not self.can_change_groups:
article.group = self.article.group article.group = self.article.group
article.group_read = self.article.group_read article.group_read = self.article.group_read
......
...@@ -90,7 +90,7 @@ class Article(models.Model): ...@@ -90,7 +90,7 @@ class Article(models.Model):
descendant.article.group_write = self.group_write descendant.article.group_write = self.group_write
descendant.article.other_read = self.other_read descendant.article.other_read = self.other_read
descendant.article.other_write = self.other_write descendant.article.other_write = self.other_write
descendant.save() descendant.article.save()
def set_group_recursive(self): def set_group_recursive(self):
for descendant in self.descendant_objects(): for descendant in self.descendant_objects():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment