I am starting an app that has a complex permission structure that will inevitably be managed by the users themselves. I have the following permissions in the model:
class Meta:
permissions = (
('can_view', 'View project'),
('manage_view', 'Can assign View project'),
('can_edit', 'Edit project'),
('manage_edit', 'Can assign Edit project'),
('can_delete', 'Delete project'),
('manage_delete', 'Can assign Delete project'),
('creator', 'Full access to model features.'),
)
These will be managed at the object level with Django-guardian and I am using custom mixins to deal with all of the various combinations and features.
The 'creator' permission is assigned to the initial creator of an object, and they can assign the other permissions to Users via an e-mail based invite system.
My question surrounds the options are for assigning the creator permission on creation of the object.
Some approaches I have thought of so far:
Assign in view after save
newObject.save()
assign('creator', User, newObject)
Generally, I prefer to get these types of events out of my views though.
Override save()
The problem with this method is I have to give the save access to the User object, which means also overriding the init to set self.request = request.
post_save signal
I know I could take advantage of this signal, but compared to the previous two I haven't attempted an implementation of this yet.
Hopefully this provides enough insight into where I am at with things.
I would love to know what the best of these methods would be, or, if they are all bad ideas what an alternative implementation might be.
Thanks,
JD