1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00
webvirtcloud/admin/tests/edits.py
catborise ab77b198f2 fix(admin): a user or group form opened before another change does not undo it
The user and group edit forms send back every field they show. A form
opened before another administrator blocked the user, took away a group
or a permission, or changed a group's members, put those back when it
was saved for another change. The forms now send a fingerprint of what
they showed, and a user or group changed meanwhile is shown again as it
is now, with nothing saved. The user's password and last login are no
change of the form.
2026-11-13 14:29:50 +03:00

15 lines
436 B
Python

"""What an edit form sends back as the state it showed (admin.views.form_seen)."""
from accounts.models import UserAttributes
from logs.audit import snapshot
from admin.views import form_seen, group_snapshot
def user_seen(user):
attributes, _created = UserAttributes.objects.get_or_create(user=user)
return form_seen(snapshot(user), snapshot(attributes))
def group_seen(group):
return form_seen(group_snapshot(group))