class OrderStates_Enumerate(Enumerate): @classmethod def get_options(cls): options = [] for name, value in states.items(): options.append({ 'name': name, 'value': value, 'color': states_color[name] }) return options # Workflow definition order_workflow = Workflow() add_state = order_workflow.add_state add_trans = order_workflow.add_trans # States states = { '': MSG(u'Unknow'), 'open': MSG(u'Waiting payment'), 'partial_payment': MSG(u'Partial payment'), 'payment_ok': MSG(u'Payment validated'), 'preparation': MSG(u'Order in preparation'), 'out_stock': MSG(u'A product is out of stock'), 'delivery': MSG(u'Package sent'), 'payment_error': MSG(u'Payment error'), 'cancel': MSG(u'Canceled'), 'closed': MSG(u'Closed')
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # Import from the Standard Library from unittest import TestCase, main # Import from itools from itools.workflow import Workflow, WorkflowAware # Definition of the workflow # Create the workflow object workflow = Workflow() # Specify the workflow states workflow.add_state('private', description='A private document only can be reached by' ' authorized users.') workflow.add_state('pending', description='A pending document awaits review from' ' authorized users to be published.') workflow.add_state('public', description='A public document can be reached by even' ' anonymous users.') # Specify the workflow transitions workflow.add_trans('request', 'private',