Example #1
0
def _get_cached_rule(domain, rule_id):
    rules = AutomaticUpdateRule.by_domain_cached(domain, AutomaticUpdateRule.WORKFLOW_SCHEDULING)
    rules = list(filter(lambda rule: rule.pk == rule_id, rules))

    if len(rules) != 1:
        return None

    return rules[0]
Example #2
0
def _get_cached_rule(domain, rule_id):
    rules = AutomaticUpdateRule.by_domain_cached(domain, AutomaticUpdateRule.WORKFLOW_SCHEDULING)
    rules = [rule for rule in rules if rule.pk == rule_id]

    if len(rules) != 1:
        return None

    return rules[0]
Example #3
0
 def _get_rules(self, domain, case_type):
     domain_rules = self.rules_by_domain.get(domain)
     if not domain_rules or domain_rules.expired():
         rules = AutomaticUpdateRule.by_domain_cached(domain, AutomaticUpdateRule.WORKFLOW_SCHEDULING)
         domain_rules = CaseRules(
             datetime.utcnow(), AutomaticUpdateRule.organize_rules_by_case_type(rules)
         )
         self.rules_by_domain[domain] = domain_rules
     return domain_rules.by_case_type.get(case_type, [])
Example #4
0
def _sync_case_for_messaging(domain, case_id):
    try:
        case = CaseAccessors(domain).get_case(case_id)
        sms_tasks.clear_case_caches(case)
    except CaseNotFound:
        case = None

    if case is None or case.is_deleted:
        sms_tasks.delete_phone_numbers_for_owners([case_id])
        delete_schedule_instances_for_cases(domain, [case_id])
        return

    if use_phone_entries():
        sms_tasks._sync_case_phone_number(case)

    rules = AutomaticUpdateRule.by_domain_cached(case.domain, AutomaticUpdateRule.WORKFLOW_SCHEDULING)
    rules_by_case_type = AutomaticUpdateRule.organize_rules_by_case_type(rules)
    for rule in rules_by_case_type.get(case.type, []):
        rule.run_rule(case, utcnow())
Example #5
0
 def _get_rules(self, domain):
     return AutomaticUpdateRule.by_domain_cached(
         domain, AutomaticUpdateRule.WORKFLOW_DEDUPLICATE)