Exemple #1
0
    def create_label(self, org, uuid, name, description, keywords=(), **kwargs):
        label = Label.objects.create(org=org, uuid=uuid, name=name, description=description, **kwargs)

        if keywords:
            rule = Rule.create(org, [ContainsTest(keywords, Quantifier.ANY)], [LabelAction(label)])
            label.rule = rule
            label.save(update_fields=('rule',))

        return label
Exemple #2
0
    def create_label(self, org, uuid, name, description, keywords=(), **kwargs):
        label = Label.objects.create(org=org, uuid=uuid, name=name, description=description, **kwargs)

        if keywords:
            rule = Rule.create(org, [ContainsTest(keywords, Quantifier.ANY)], [LabelAction(label)])
            label.rule = rule
            label.save(update_fields=('rule',))

        return label
Exemple #3
0
    def update_tests(self, tests):
        from casepro.rules.models import Rule, LabelAction

        if tests:
            if self.rule:
                self.rule.tests = json_encode(tests)
                self.rule.save(update_fields=('tests', ))
            else:
                self.rule = Rule.create(self.org, tests, [LabelAction(self)])
                self.save(update_fields=('rule', ))
        else:
            if self.rule:
                rule = self.rule
                self.rule = None
                self.save(update_fields=('rule', ))

                rule.delete()
Exemple #4
0
    def update_tests(self, tests):
        from casepro.rules.models import Rule, LabelAction

        if tests:
            if self.rule:
                self.rule.tests = json_encode(tests)
                self.rule.save(update_fields=('tests',))
            else:
                self.rule = Rule.create(self.org, tests, [LabelAction(self)])
                self.save(update_fields=('rule',))
        else:
            if self.rule:
                rule = self.rule
                self.rule = None
                self.save(update_fields=('rule',))

                rule.delete()
Exemple #5
0
 def create_rule(self, org, tests, actions):
     return Rule.create(org, tests, actions)
Exemple #6
0
 def create_rule(self, org, tests, actions):
     return Rule.create(org, tests, actions)