Beispiel #1
0
    def clean_name(self):
        data = self.cleaned_data['name'].strip()

        if not ContactGroup.is_valid_name(data):
            raise forms.ValidationError("Group name must not be blank or begin with + or -")

        return data
Beispiel #2
0
    def clean_name(self):
        data = self.cleaned_data['name'].strip()

        if not ContactGroup.is_valid_name(data):
            raise forms.ValidationError("Group name must not be blank or begin with + or -")

        return data
    def validate_groups(self, value):
        if value is not None:
            self.group_objs = []
            for name in value:
                if not ContactGroup.is_valid_name(name):
                    raise serializers.ValidationError(_("Invalid group name: '%s'") % name)
                self.group_objs.append(ContactGroup.get_or_create(self.org, self.user, name))

        return value
Beispiel #4
0
    def validate_groups(self, value):
        if value is not None:
            self.group_objs = []
            for name in value:
                if not ContactGroup.is_valid_name(name):
                    raise serializers.ValidationError(_("Invalid group name: '%s'") % name)
                self.group_objs.append(ContactGroup.get_or_create(self.org, self.user, name))

        return value
def cleanse_group_names(action):
    from temba.contacts.models import ContactGroup
    if action['type'] == 'add_group' or action['type'] == 'del_group':
        if 'group' in action and 'groups' not in action:
            action['groups'] = [action['group']]
        for group in action['groups']:
            if isinstance(group, dict):
                if 'name' not in group:
                    group['name'] = 'Unknown'
                if not ContactGroup.is_valid_name(group['name']):
                    group['name'] = '%s %s' % ('Contacts', group['name'])
    return action
Beispiel #6
0
def cleanse_group_names(action):
    from temba.contacts.models import ContactGroup

    if action["type"] == "add_group" or action["type"] == "del_group":
        if "group" in action and "groups" not in action:
            action["groups"] = [action["group"]]
        for group in action["groups"]:
            if isinstance(group, dict):
                if "name" not in group:
                    group["name"] = "Unknown"
                if not ContactGroup.is_valid_name(group["name"]):
                    group["name"] = "%s %s" % ("Contacts", group["name"])
    return action
Beispiel #7
0
 def validate_name(self, value):
     if not ContactGroup.is_valid_name(value):
         raise serializers.ValidationError(
             "Name contains illegal characters.")
     return value
Beispiel #8
0
 def validate_name(self, value):
     if not ContactGroup.is_valid_name(value):
         raise serializers.ValidationError("Name contains illegal characters.")
     return value
Beispiel #9
0
 def validate_name(self, value):
     if not ContactGroup.is_valid_name(value):
         raise serializers.ValidationError("Name contains illegal characters or is longer than %d characters"
                                           % ContactGroup.MAX_NAME_LEN)
     return value