Bases: reversion.admin.VersionAdmin
Base werewolf admin model.
Here we replace the choices based on the user permissions.
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"))
>>> )