<commit_before>"""Order management. Includes state machine."""



<commit_msg>First implementation of state machine: to be replaced by django-workflows<commit_after>"""Order management. Includes state machine."""

from django.db import models
from django.utils.translation import ugettext, ugettext_lazy as _

from gasistafelice.base.models import Person, Role
from gasistafelice.supplier.models import Supplier, SupplierStock
from gasistafelice.gas.const import STATES_LIST

class State(models.Model):

    name = models.CharField(max_length=128) 
    value = models.IntegerField() 
    description = models.TextField(blank=True)

    action_set = models.ManyToManyField(Action, through="StateActionMap")

    def __unicode__(self):
        return self.name

class Action(models.Model):
    
    name = models.CharField(max_length=128) 
    value = models.IntegerField() 
    description = models.TextField(blank=True)

    states_set = models.ManyToManyField(State, through="StateActionMap")

    def __unicode__(self):
        return self.name

class StateActionMap(models.Model):

    from_state = models.ForeignKey(State)
    input_action = models.ForeignKey(Action)
    to_state = models.ForeignKey(State)
     
class Workflow(models.Model):
    
    name = models.CharField(max_length=128) 
    description = models.TextField(blank=True)

    def __unicode__(self):
        return self.name

class WorkflowStep(models.Model):

    workflow = models.ForeignKey(Workflow)
    
    
    auto = models.BooleanField(default=False)

    


{'fraction_non_alphanumeric': 0.09285714285714286, 'fraction_numerical': 0.005844155844155844, 'mean_word_length': 4.102649006622516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5282361', 'n_tokens_mistral': 467, 'n_tokens_neox': 438, 'n_words': 97}