mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(accounts): owners given before one owner was the rule keep editable rights
With "Multiple Owner for VM" turned off after a VM was given two owners, changing either owner's rights (Delete the VM, say) was refused: the form's one-owner check counted the other owner. The check now applies to a new owner only, as its message says. The user and group forms showed the permissions by the English names the database keeps (Can clone instances, ...), in every language; they are named in the user's language now.
This commit is contained in:
parent
dde7672375
commit
35a5bbdb62
10 changed files with 151 additions and 100 deletions
|
|
@ -21,10 +21,9 @@ class UserInstanceForm(ModelForm):
|
|||
|
||||
def clean_instance(self):
|
||||
instance = self.cleaned_data["instance"]
|
||||
if app_settings.ALLOW_INSTANCE_MULTIPLE_OWNER == "False":
|
||||
# the ownership being edited is not another owner
|
||||
exists = UserInstance.objects.filter(instance=instance).exclude(pk=self.instance.pk)
|
||||
if exists:
|
||||
# a new owner only: rights of one the VM has may still be changed after the setting is turned off
|
||||
if app_settings.ALLOW_INSTANCE_MULTIPLE_OWNER == "False" and self.instance.pk is None:
|
||||
if UserInstance.objects.filter(instance=instance).exists():
|
||||
raise ValidationError(_("Instance owned by another user"))
|
||||
|
||||
return instance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue