예제 #1
0
파일: views.py 프로젝트: vdhan/rapidpro
    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
예제 #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
예제 #3
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
예제 #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
예제 #5
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
예제 #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
예제 #7
0
 def validate_name(self, value):
     if not ContactGroup.is_valid_name(value):
         raise serializers.ValidationError(
             "Name contains illegal characters.")
     return value
예제 #8
0
 def validate_name(self, value):
     if not ContactGroup.is_valid_name(value):
         raise serializers.ValidationError("Name contains illegal characters.")
     return value
예제 #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