entities/wfobjs.py
branchtls-sprint
changeset 1154 9b23a6836c32
parent 0 b97547f5f1fa
child 1572 469787f6ea2b
equal deleted inserted replaced
1153:6a7636b32a97 1154:9b23a6836c32
     1 """workflow definition and history related entities
     1 """workflow definition and history related entities
     2 
     2 
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 """
     6 """
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
     8 
     8 
     9 from cubicweb.entities import AnyEntity, fetch_config
     9 from cubicweb.entities import AnyEntity, fetch_config
    10 
    10 
    11 
    11  
    12 class Transition(AnyEntity):
    12 class Transition(AnyEntity):
    13     """customized class for Transition entities
    13     """customized class for Transition entities
    14 
    14 
    15     provides a specific may_be_passed method to check if the relation may be
    15     provides a specific may_be_passed method to check if the relation may be
    16     passed by the logged user
    16     passed by the logged user
    17     """
    17     """
    18     id = 'Transition'
    18     id = 'Transition'
    19     fetch_attrs, fetch_order = fetch_config(['name'])
    19     fetch_attrs, fetch_order = fetch_config(['name'])
    20     __rtags__ = {('destination_state',  '*', 'subject'):  'create',
       
    21                  ('allowed_transition', '*', 'object') :  'create',
       
    22                   }
       
    23                  
    20                  
    24     def may_be_passed(self, eid, stateeid):
    21     def may_be_passed(self, eid, stateeid):
    25         """return true if the logged user may pass this transition
    22         """return true if the logged user may pass this transition
    26 
    23 
    27         `eid` is the eid of the object on which we may pass the transition
    24         `eid` is the eid of the object on which we may pass the transition
    64     passed by the current user for the given entity
    61     passed by the current user for the given entity
    65     """
    62     """
    66     id = 'State'
    63     id = 'State'
    67     fetch_attrs, fetch_order = fetch_config(['name'])
    64     fetch_attrs, fetch_order = fetch_config(['name'])
    68     rest_attr = 'eid'
    65     rest_attr = 'eid'
    69     
    66         
    70     __rtags__ = {'destination_state' : 'create',
       
    71                  'allowed_transition' : 'create'
       
    72                  }
       
    73     
       
    74     def transitions(self, entity, desteid=None):
    67     def transitions(self, entity, desteid=None):
    75         rql = ('Any T,N,DS where S allowed_transition T, S eid %(x)s, '
    68         rql = ('Any T,N,DS where S allowed_transition T, S eid %(x)s, '
    76                'T name N, T destination_state DS, '
    69                'T name N, T destination_state DS, '
    77                'T transition_of ET, ET name %(et)s')
    70                'T transition_of ET, ET name %(et)s')
    78         if desteid is not None:
    71         if desteid is not None: