Skip to content

Commit

Permalink
Doc updated #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheox committed Oct 31, 2012
1 parent 219b047 commit 8ccc9b0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
10 changes: 10 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ Logout



Object State Switching
======================
All possible states object (article, photo etc.) can be switched to (with respect
to used workflow), are accessible via "states" resource field.
When creating new object in admin, "states" sent in login response content for particular
resource should be used. These "states" are states object can switch to from initial state.
Object state can be switched simply setting "state" resource field to state codename in POST/PUT/PATCH request.



Generic API for all resources
=============================

Expand Down
Binary file modified doc/pics/perm_workflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 18 additions & 17 deletions doc/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Class diagram

Workflow models
===============
``Workflow`` is made of directed graph, nodes are modelled by ``State`` instances
and edges are modelled by ``Transition`` instances.


**Workflow** model - Workflow instance can be added to any model:

Expand All @@ -41,14 +44,14 @@ Workflow models
wf.set_to_model(CommonArticle)


**State** model - State instance can be added to more workflow instances:
**State** model

::

state = State("Epic out-of-space state")
state.workflow = workflow

**Transition** model - transitions are connections between nodes(states), you can add more transitions to one state ofc.:
**Transition** model - transitions are connections between nodes (states), you can add more transitions to one state ofc.:

::

Expand Down Expand Up @@ -84,20 +87,21 @@ can in state "Corrected" publish an article (has "can_publish" permission):
can_publish = Permission(titile="Can publish", codename="can_publish")
editor_in_chief = Role(title="Editor in chief")

spr = StatePermissionRelation(state=corr_state, permission=can_publish, role=editor_in_chief)
relation = StatePermissionRelation(state=corr_state, permission=can_publish, role=editor_in_chief)



*StateModelRelation* - is mapping a given state to a given model content_type:
*StateObjectRelation* - is mapping a given state to a given model object:

::

from ella_hub.models import State, StateModelRelation, CommonArticle
from ella_hub.models import State, StateObjectRelation, CommonArticle
from django.contrib.contenttypes.models import ContentType

state = State(title="Some state")
ct = ContentType.objects.get_for_model(CommonArticle)
smr = StateModelRelation(state=state, content_type=ct)
article = CommonArticle(title="Awesome article", ...)
relation = StateObjectRelation(state=state, content_type=ct, content_id=article.id)


*WorkflowPermissionRelation* - is mapping a given permission to a given workflow, permissions
Expand All @@ -110,7 +114,7 @@ system independency.

wf = Workflow(title="Epic workflow")
can_publish = Permission(title="Can publish", codename="can_publish")
wpr = WorkflowPermissionRelation(permission=can_publish, workflow=wf)
relation = WorkflowPermissionRelation(permission=can_publish, workflow=wf)



Expand Down Expand Up @@ -158,17 +162,17 @@ Permission models
from django.contrib.auth.models import User, Group

editor = Role(title="Editor")
nixxon = User(username="richy_nixxon")
prr = PrincipalRoleRelation(role=editor)
prr.set_principal(nixxon)
userko = User(username="Userko")
relation = PrincipalRoleRelation(role=editor)
relation.set_principal(userko)


-------------
Ella workflow
-------------


Publishable States
States
==================

* added - Added/Vložen
Expand All @@ -179,9 +183,6 @@ Publishable States
* deleted - Deleted/Smazán


Roles definition
================
* editor in chief
* editor
* photographer
* ...
Testing Ella-workflow implementation
====================================
*TODO*

0 comments on commit 8ccc9b0

Please sign in to comment.