Bases: reversion.admin.VersionAdmin
Base werewolf admin model.
Property list werewolf_protected_fields: | |
---|---|
List of fields to protect in form of the following tuple (field_name, required_permission). |
Here we replace the choices based on the user permissions.
Removes protected fields from the list_editiable field list.
Hiding fields that non-authorised users should not have access to. It’s done based on the werewolf_protected_fields of your ModelAdmin. But if happen to override that method for your own needs, make sure the it also reflects the django-werewolf concepts.
Hiding fields that non-authorised users should not have access to. It’s done based on the werewolf_protected_fields of your ModelAdmin. But if happen to override that method for your own needs, make sure the it also reflects the django-werewolf concepts.
Make sure users with no rights to edit an object with status, don’t even see it.
Status change trigger. Executes appropriate registered trigger if applicable.
Parameters: |
|
---|
Gets an admin edit URL for the object given.
Parameters: |
|
---|---|
Return str: |
Gets an admin edit URL for the object given.
Parameters: |
|
---|---|
Return str: |
Gets the permission key from choice_key given.
Parameters: |
|
---|---|
Return str: |
Gets/extends permissions for the base model based on the STATUS_CHOICES defined.
Parameters: | permissions (list|tuple) – Permissions you want to have in your model. Those permissions would be extended by werewolf permissions. |
---|---|
Return list: |
Gets available status choices for the user given.
Parameters: |
|
---|---|
Return list: | List of choices in a same form as werewolf.defaults.STATUS_CHOICES but then limited to actual choices that user has permissions to. |
Extends model permissions with werewolf permissions.
Example : |
---|
>>> from werewolf.models import WerewolfBaseModel
>>> from werewolf.utils import extend_werewolf_permissions
>>> class NewsItem(WerewolfBaseModel):
>>> # Some fields here
>>>
>>> class Meta:
>>> verbose_name = _("News item")
>>> verbose_name_plural = _("News items")
>>>
>>> permissions = extend_werewolf_permissions(
>>> ('can_change_author', _("Can change author")),
>>> ('can_change_editor', _("Can change editor")),
>>> ('can_change_chief_editor', _("Can change chief editor"))
>>> )