1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +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:
catborise 2026-11-13 14:27:32 +03:00
parent dde7672375
commit 35a5bbdb62
10 changed files with 151 additions and 100 deletions

View file

@ -17,6 +17,15 @@ from instances.models import Instance
from .models import Permission
# each permission's name in the user's language: the database keeps the English one
PERMISSION_NAMES = {
"change_password": _("Can change password"),
"clone_instances": _("Can clone instances"),
"passwordless_console": _("Can access console without password"),
"snapshot_instances": _("Can snapshot instances"),
"view_instances": _("Can view instances"),
}
# what each permission lets a user do, shown beside its switch
PERMISSION_HELP = {
"change_password": _("Change their own password on their profile page"),
@ -28,8 +37,13 @@ PERMISSION_HELP = {
def permission_rows(field):
"""Each permission's checkbox of a bound field with what it lets a user do."""
return [(box, PERMISSION_HELP.get(box.data["value"].instance.codename, "")) for box in field]
"""Each permission's checkbox of a bound field with its name and what it lets a user do."""
rows = []
for box in field:
permission = box.data["value"].instance
rows.append((box, PERMISSION_NAMES.get(permission.codename, permission.name),
PERMISSION_HELP.get(permission.codename, "")))
return rows
class GroupForm(forms.ModelForm):