Exemple #1
0
 def initial_rule_form(self):
     return AddAutomaticCaseUpdateRuleForm(
         domain=self.domain,
         initial={
             'action': AddAutomaticCaseUpdateRuleForm.ACTION_CLOSE,
             'property_value_type': AutomaticUpdateAction.EXACT,
         })
Exemple #2
0
 def rule_form(self):
     if self.request.method == 'POST':
         return AddAutomaticCaseUpdateRuleForm(
             self.request.POST,
             domain=self.domain,
             # Pass the original case_type so that we can always continue to
             # properly display and edit rules based off of deleted case types
             initial={'case_type': self.rule.case_type})
     else:
         return self.initial_rule_form
Exemple #3
0
    def initial_rule_form(self):
        conditions = []
        for criterion in self.rule.automaticupdaterulecriteria_set.order_by(
                'property_name'):
            conditions.append({
                'property_name': criterion.property_name,
                'property_match_type': criterion.match_type,
                'property_value': criterion.property_value,
            })

        close_case = False
        update_case = False
        update_property_name = None
        update_property_value = None
        property_value_type = AutomaticUpdateAction.EXACT
        for action in self.rule.automaticupdateaction_set.all():
            if action.action == AutomaticUpdateAction.ACTION_UPDATE:
                update_case = True
                update_property_name = action.property_name
                update_property_value = action.property_value
                property_value_type = action.property_value_type
            elif action.action == AutomaticUpdateAction.ACTION_CLOSE:
                close_case = True

        if close_case and update_case:
            initial_action = AddAutomaticCaseUpdateRuleForm.ACTION_UPDATE_AND_CLOSE
        elif update_case and not close_case:
            initial_action = AddAutomaticCaseUpdateRuleForm.ACTION_UPDATE
        else:
            initial_action = AddAutomaticCaseUpdateRuleForm.ACTION_CLOSE

        initial = {
            'name':
            self.rule.name,
            'case_type':
            self.rule.case_type,
            'server_modified_boundary':
            self.rule.server_modified_boundary,
            'conditions':
            json.dumps(conditions),
            'action':
            initial_action,
            'update_property_name':
            update_property_name,
            'update_property_value':
            update_property_value,
            'property_value_type':
            property_value_type,
            'filter_on_server_modified':
            json.dumps(self.rule.filter_on_server_modified),
        }
        return AddAutomaticCaseUpdateRuleForm(domain=self.domain,
                                              initial=initial)
Exemple #4
0
    def initial_rule_form(self):
        conditions = []
        for criterion in self.rule.automaticupdaterulecriteria_set.order_by(
                'property_name'):
            conditions.append({
                'property_name': criterion.property_name,
                'property_match_type': criterion.match_type,
                'property_value': criterion.property_value,
            })

        update_case = False
        update_property_name = None
        update_property_value = None
        for action in self.rule.automaticupdateaction_set.all():
            if action.action == AutomaticUpdateAction.ACTION_UPDATE:
                update_case = True
                update_property_name = action.property_name
                update_property_value = action.property_value
                break

        initial = {
            'name':
            self.rule.name,
            'case_type':
            self.rule.case_type,
            'server_modified_boundary':
            self.rule.server_modified_boundary,
            'conditions':
            json.dumps(conditions),
            'action':
            (AddAutomaticCaseUpdateRuleForm.ACTION_UPDATE_AND_CLOSE
             if update_case else AddAutomaticCaseUpdateRuleForm.ACTION_CLOSE),
            'update_property_name':
            update_property_name,
            'update_property_value':
            update_property_value,
        }
        return AddAutomaticCaseUpdateRuleForm(domain=self.domain,
                                              initial=initial)
Exemple #5
0
 def rule_form(self):
     if self.request.method == 'POST':
         return AddAutomaticCaseUpdateRuleForm(self.request.POST, domain=self.domain)
     else:
         return self.initial_rule_form
Exemple #6
0
 def initial_rule_form(self):
     return AddAutomaticCaseUpdateRuleForm(
         domain=self.domain,
         initial={
             'action': AddAutomaticCaseUpdateRuleForm.ACTION_CLOSE,
         })