def test_triggering_multiple_time(self): class TestModelForTriggeringMultipleTime(models.Model): pass field = StateField() class_field_rl_cp = deepcopy(class_field_rl) field.contribute_to_class(TestModelForTriggeringMultipleTime, 'status') class_field_rl_cp.update({ _get_cls_identifier(TestModelForTriggeringMultipleTime): 'status' }) self.assertDictEqual(class_field_rl_cp, class_field_rl) field.contribute_to_class(TestModelForTriggeringMultipleTime, 'status') self.assertDictEqual(class_field_rl_cp, class_field_rl) try: field.contribute_to_class(TestModelForTriggeringMultipleTime, 'status2') self.assertFalse( True, "River exception with error code %d, must have been raised") except RiverException as re: self.assertEqual(ErrorCode.MULTIPLE_STATE_FIELDS, re.code) else: self.assertFalse( True, "River exception with error code %d, must have been raised")
class Dossier(TimedModel): code = models.CharField(max_length=20, blank=False, verbose_name="Code du dossier") categorie_dossier = models.ForeignKey("FolderCategory", on_delete=models.PROTECT, related_name="dossiers", verbose_name="Catégorie de dossier") state = StateField(editable=False) @property def out_since(self): return timesince( self.mouvements.filter( sens='out').latest('creation_time').creation_time) @property def out_since(self): return timesince( self.mouvements.filter( sens='out').latest('creation_time').creation_time) def __str__(self): return "{} / {}".format(self.categorie_dossier, self.code) class Meta: verbose_name = "Dossier" verbose_name_plural = "Dossiers" permissions = [ ("can_manipulate_folders", "Can manipulate folders"), ]
class Shipping(models.Model): product = models.CharField(max_length=50, null=True, blank=True) customer = models.CharField(max_length=50, null=True, blank=True) shipping_status = StateField() def __str__(self): return self.product
class Grant(models.Model): group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) user = models.ForeignKey(User, on_delete=models.CASCADE) role = models.ForeignKey(Role, on_delete=models.CASCADE, null=True, blank=True) status = StateField(on_delete=models.CASCADE) not_valid_before = models.DateTimeField(default=timezone.now) not_valid_after = models.DateTimeField(blank=True, null=True) class Meta: unique_together = [["group", "user"], ["role", "user"]] constraints = [ models.CheckConstraint(check=Q(group__isnull=False) | Q(role__isnull=False), name='not_both_null'), models.CheckConstraint(check=Q(group__isnull=True) | Q(role__isnull=True), name='either_null') ] def __str__(self): if self.group: return "g " + self.group.name + ", " + self.user.username else: return "r " + self.role.name + ", " + self.user.username
class AdmissionYearMaster(models.Model): admission_year = models.CharField("admission year",max_length=20) academic_year = models.CharField("academic year",max_length=20) created_by = models.ForeignKey(User,on_delete=models.CASCADE) created_on = models.DateTimeField() updated_by = models.ForeignKey(User,on_delete=models.CASCADE,related_name='scheme_master_admission_set') updated_on = models.DateTimeField( null=True, blank=True) status=StateField(editable=False)
class Ticket(models.Model): ticket_num = models.CharField('Ticket Number', max_length=10, default=uuid.uuid4, editable=False) description = models.TextField() status = StateField(editable=False) def __str__(self): return "{}".format(self.ticket_num)
class ReceivedAdviceNote(models.Model): batch_no = models.CharField(max_length=25, unique=True) prepared_on = models.DateField(blank=True, null=True) status = StateField(editable=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) created_by = models.ForeignKey(User, on_delete=models.CASCADE, editable=False) class Meta: ordering = ('batch_no',)
class somework(models.Model): title = models.CharField(max_length=100, verbose_name="题目") content = models.TextField(verbose_name="汇报") state = StateField(verbose_name="提交状态") objects = WorkflowObjectManager() def __unicode__(self): return self.title def __str__(self): return self.title
class MyModel(models.Model): testflow = models.CharField(max_length=50, default="6666", verbose_name="测试") state = StateField(verbose_name="状态", related_name="states") objects = WorkflowObjectManager() def __unicode__(self): return self.testflow def __str__(self): return self.testflow
class Task(MPTTModel): subject = models.CharField('Subject', max_length=200) description = models.TextField('Description', max_length=1000, blank=True) status = StateField(editable=False, verbose_name='Status') parent = TreeForeignKey('self', null=True, blank=True, related_name='children') supervisor = models.ForeignKey(UserProfile, related_name='tasks_by_supervisor') agent = models.ForeignKey(UserProfile, related_name='taks_by_agent') class MPTTMeta: level_attr = 'mptt_level'
class ReceivedNote(Material): # prepared_by = None # approved_by = None batch_no = models.CharField(max_length=25, unique=True) date_prepared = models.DateField(blank=True, null=True) stock_received = models.PositiveIntegerField(blank=True) approved = models.BooleanField(default=False) remarks = models.CharField(max_length=50, blank=True) status = StateField(editable=False) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) class Meta: ordering = ('batch_no',)
class Product(models.Model): name = models.CharField(max_length=100) batch_no = models.CharField(max_length=25, unique=True) batch_size = models.PositiveIntegerField('Batch Size (kg)', blank=True) manufacture_date = models.DateField(blank=True) created = models.DateTimeField(auto_now_add=True) updated = models.DateTimeField(auto_now=True) status = StateField(editable=False) class Meta: ordering = ('batch_no', 'name') verbose_name_plural = 'Products' def __str__(self): return self.name
class Issue(models.Model): title = models.CharField(max_length=50) detail = models.TextField(max_length=200, null=True, blank=True) reporter = models.ForeignKey(User, related_name="reported_issues", null=True, blank=True, on_delete=SET_NULL) assignee = models.ForeignKey(User, related_name="assigned_issues", null=True, blank=True, on_delete=SET_NULL) issue_status = StateField() def __str__(self): return self.title
class Flow(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) stage= StateField(editable=False) completed=models.BooleanField(default=False) restricted=models.BooleanField(default=True) flow_type=models.ForeignKey(WorkflowType, on_delete=models.PROTECT, blank=True, null=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) parent_flow = models.ForeignKey('self', blank=True, null=True, on_delete=models.CASCADE) flow_name=models.CharField(max_length=50,default="",null=True, blank=True) def __str__(self): return str(self.flow_name) class Meta: app_label="workflowengine" ordering=['created_at'] def putFlowOnTrack(self, user): destination_state=self.flow_type.start_stage.id self.river.stage.approve(as_user=user, next_state=destination_state, god_mod=True)
class TicketRequest(models.Model): title = models.CharField(max_length=200) description = models.TextField(default="") author = models.ForeignKey('auth.User') published_date = models.DateTimeField(blank=True, null=True) application = models.ForeignKey(Application) type = models.ForeignKey(TypeRequest) status = StateField(editable=False) #type = ChainedForeignKey( #TypeRequest, #chained_field="application", #chained_model_field="application", #show_all=False, #auto_choose=True, #sort=True,) #location = models.ForeignKey(Location, on_delete=models.CASCADE) def __unicode__(self): return self.title
class Ticket(models.Model): no = models.CharField("Ticket Number", max_length=50, default=uuid.uuid4, null=False, blank=False, editable=False, unique=True) subject = models.CharField("Nombre", max_length=100, null=False, blank=False) description = models.TextField("Registro", max_length=500, null=True, blank=True) log = models.CharField("Tags", max_length=500, null=True, blank=True, editable=True) inicio = models.DateTimeField(default=timezone.now, editable=False) ultimo = models.DateTimeField(default=timezone.now, editable=False) #archivo = models.FileField( storage=OverwriteStorage()) archivo = models.FileField() archivo_new = models.FileField() status = StateField(editable=False) def natural_key(self): return self.no readonly_fields = ["archivo"]
class Ticket(models.Model): no = models.CharField("Ticket Number", max_length=50, default=uuid.uuid4, null=False, blank=False, editable=False, unique=True) subject = models.CharField("Subject", max_length=100, null=False, blank=False) description = models.TextField("Description", max_length=500, null=True, blank=True) status = StateField(editable=False) def natural_key(self): return self.no
class Document(models.Model): no = models.CharField("Ticket Number", max_length=50, default=uuid.uuid4, null=False, blank=False, editable=False, unique=True) title = models.CharField("Title", max_length=500) owner = models.ForeignKey(DmsUser, on_delete=models.DO_NOTHING) file = models.FileField(upload_to='docss') department = models.ForeignKey(Department, on_delete=models.DO_NOTHING) reviewed_by = models.ForeignKey(DmsUser, on_delete=models.DO_NOTHING, related_name='reviewed_by', verbose_name='Reviewed by') approved_by = models.ForeignKey(DmsUser, on_delete=models.DO_NOTHING, related_name='approve_by', verbose_name='Approved by', null=True, blank=True) date = models.DateTimeField(auto_now_add=True) status = StateField(editable=True) def natural_key(self): return self.no def filename(self): return os.path.basename(self.file.name) def file_download(self): url = "<a href='/download/" + str(self.no) + "'>" return mark_safe( url + "<i class='nav-icon fa fa-download text-success'></i></a>") def file_name(self): return os.path.basename(self.file.url)
class ModelWithTwoStateFields(models.Model): status1 = StateField() status2 = StateField()
class TestModelSlowCase2(models.Model): status = StateField()
class EmpRegistration(models.Model): # etoolactivation = models.OneToOneField( # eToolActivation, # on_delete=models.CASCADE, # related_name="eTool", # editable=False, # null=True, # blank=True) emp_id = models.IntegerField('Employee ID', null=False, blank=False, editable=True) emp_name = models.CharField("Name", max_length=20, null=False, blank=False) emp_desig = models.CharField("Designation", max_length=10, null=False, blank=False) country = models.CharField("Country", max_length=30, null=False, blank=False) branch = models.CharField("Branch", max_length=30, null=False, blank=False) office_location = models.CharField("Office Location", max_length=30, null=False, blank=False) contact_no = models.CharField("Contact No", max_length=15, null=False, blank=False) skill_set = models.CharField("Skill Set", max_length=50, null=False, blank=False) exp_yrs = models.IntegerField('Experience (Years)', null=False, blank=False, editable=True) supervisor = models.ForeignKey(Role, on_delete=models.CASCADE, null=True, blank=True, limit_choices_to=Q(primary_role='PL') | Q(primary_role='AM') | Q(secondary_role='PL')) status_change_comments_history = models.CharField("Status Change Comments History", max_length=1000, null=True, blank=True) status_change_history = models.CharField("Status Change History", max_length=200, null=True, blank=True) status_change_date = models.DateField("Status Change Date", null=True, blank=True, editable=True) add_status_change_comments = models.CharField("Add Status Change Comments", max_length=200, null=True, blank=True) approver_comments_history = models.CharField("Record Approver Comments History", max_length=200, null=True, blank=True) add_approver_comments = models.CharField("Add Comments for Record Approver", max_length=1000, null=True, blank=True) account_manager = models.CharField("Account Manager", max_length=20, null=True, blank=True, editable=False) onboard_date = models.DateField("Onboard Date", null=True, blank=True, editable=True) cswon = models.CharField("CSWON", max_length=20, null=True, blank=True) created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, blank=True, null=True, related_name='create_by', editable=False) updated_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, blank=True, null=True, related_name='update_by', editable=False) created_date = models.DateTimeField("Date Created", auto_now_add=True, editable=False) modified_date = models.DateTimeField("Last Modified Date", auto_now=True, editable=False) status = StateField(editable=False) objects = WorkflowObjectManager() class Meta: verbose_name = "Employee Registration" verbose_name_plural = "Employee Registrations" def __str__(self): return self.emp_name
class TestModel(models.Model): test_field = models.CharField(max_length=50, null=True, blank=True) my_field = StateField() objects = models.Manager()
class BasicTestModel(models.Model): workflow = models.ForeignKey(Workflow, on_delete=models.PROTECT) test_field = models.CharField(max_length=50, null=True, blank=True) my_field = StateField()
class ModelWithTwoStateFields(models.Model): workflow = models.ForeignKey(Workflow, on_delete=models.PROTECT) status1 = StateField() status2 = StateField()
class ModelWithStringPrimaryKey(models.Model): workflow = models.ForeignKey(Workflow, on_delete=models.PROTECT) custom_pk = models.CharField(max_length=200, primary_key=True, default=uuid4()) status = StateField()
class adhocTask(models.Model): task_subject = models.CharField("Task Subject", max_length=100, null=False, blank=False) task_description = models.TextField("Task Description", max_length=500, null=False, blank=False) assigned_to = models.ForeignKey( Role, on_delete=models.DO_NOTHING, null=False, blank=False, limit_choices_to=Q(primary_role='PL') | Q(primary_role='ETSPOC') | Q(secondary_role='PL') | Q(secondary_role='ETSPOC')) resolution_description_history = models.CharField( "Resolution Description History", max_length=600, null=True, blank=True) add_resolution_description = models.CharField("Add Resolution Description", max_length=200, null=True, blank=True) complete_restart_reason_history = models.CharField( "Complete/Restart Comments History", max_length=600, null=True, blank=True) add_complete_restart_reason = models.CharField( "Add Complete/Restart Comments", max_length=200, null=True, blank=True) created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, blank=True, null=True, related_name='adhoctask_create_by', editable=False) updated_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, blank=True, null=True, related_name='adhoctask_update_by', editable=False) account_manager = models.CharField("Account Manager", max_length=20, null=True, blank=True, editable=False) created_date = models.DateTimeField("Date Created", auto_now_add=True, editable=False) last_modified_date = models.DateTimeField("Last Modified Date", auto_now=True, editable=False) status = StateField(editable=False) objects = WorkflowObjectManager() def __str__(self): return "%s" % (self.task_subject)
class ModelForSlowCase2(models.Model): status = StateField()
class TestModel(models.Model): test_field = models.CharField(max_length=50, null=True, blank=True) my_field = StateField(related_query_name='test_model')
class BasicTestModel(models.Model): test_field = models.CharField(max_length=50, null=True, blank=True) my_field = StateField()
class SOWRegistration(models.Model): project_name = models.CharField("Project Name", max_length=50, null=False, blank=False, editable=True) amendment_no = models.PositiveSmallIntegerField("Amendment Number", null=False, blank=False, default=0) sow_value = models.DecimalField("SOW Value", max_digits=10, decimal_places=2, null=False, blank=False, editable=True) sow_start_date = models.DateField("SOW Start Date", null=False, blank=False, editable=True) sow_end_date = models.DateField("SOW End Date", null=False, blank=False, editable=True) amendment_value = models.DecimalField("Amendment Value", max_digits=10, decimal_places=2, null=True, blank=True, editable=True) amendment_start_date = models.DateField("Amendment Start Date", null=True, blank=True, editable=True) amendment_end_date = models.DateField("Amendment End Date", null=True, blank=True, editable=True) sow_type = models.CharField("Type", max_length=10, null=False, blank=False, editable=True) owner = models.ForeignKey(Role, on_delete=models.DO_NOTHING, null=True, blank=True, limit_choices_to=Q(primary_role='AM')) remarks = models.TextField("Remarks", max_length=200, null=True, blank=True, editable=True) compliance_team_approval_date = models.DateField( "Compliance Team Approval Date", null=True, blank=True, editable=True) tcs_contract_id = models.CharField("TCS Contract ID", max_length=50, null=True, blank=True, editable=True) legal_approval_date = models.DateField("Legal Approval Date", null=True, blank=True, editable=True) pob_approval = models.BooleanField("POB Approval", default=False) pob_remarks = models.CharField("POB Remarks", max_length=200, null=True, blank=True, editable=True) crt_upd_won_sow = models.BooleanField("Create/Update WONs for SOW ID", default=False) account_manager = models.CharField("Account Manager", max_length=20, null=True, blank=True, editable=False) created_date = models.DateTimeField("Date Created", auto_now_add=True, editable=False) modified_date = models.DateTimeField("Last Modified Date", auto_now=True, editable=False) created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, blank=True, null=True, related_name='sowreg_create_by', editable=False) updated_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, blank=True, null=True, related_name='sowreg_update_by', editable=False) status = StateField(editable=False) objects = WorkflowObjectManager() def __str__(self): return "%s" % (self.project_name) @transaction.atomic def save(self, *args, **kwargs): if not self.amendment_start_date and self.amendment_no == 0: self.amendment_start_date = self.sow_start_date if not self.amendment_end_date and self.amendment_no == 0: self.amendment_end_date = self.sow_end_date super(SOWRegistration, self).save(*args, **kwargs)