Actions and States
States
All State.STATEFUL_MODELS have a state field that takes one of values in State.STATES. Currently those values are
- State.STATES['UNPUBLISHED']
- State.STATES['PUBLISHED']
- State.STATES['DELETED']
State Mixins:
- delete(undo=True) - defaults to calling undoable_delete; otherwise, if current user is a superuser, calls item's delete
- undoable_delete - create delete action and change item's state (if item is not already deleted)
- undo_delete - delete delete action and change item's state (if item is deleted)
- publish - create publish action and change item's state (if item is unpublished)
- unpublish - delete publish action and change item's state (if item is published)
State objects manager (limit returned items based on state):
- get_query_set - used in Model.objects.all(), and is thus the 'normal' behavior. Is used by select_related...hmmm??
- raw - gets everything
- with_state(state) - get items with a particular state
Actions
All Action.ACTION_MODELS have pre_save signals mixed in so that object creation, and one day modification, result in the creation of created and modified actions, respectively. The State mixin directly calls the methods for creating published and deleted actions.
An action records the current user, time and ip of an event, and links to the new or altered object. The object in turn has cached properties mixed in for retrieving the [created_]action, published_action and deleted_action. We don't currently create or access modified_actions.
Every object should have one action. No object should have more than one published_action or deleted_action.
Note the use of action to refer specifically to the create action.