Skip to content

Commit

Permalink
dont allow spaces, etc in team/dept/etc names
Browse files Browse the repository at this point in the history
  • Loading branch information
rloomans committed Dec 19, 2016
1 parent dd9a2ea commit 6162395
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions teamtemp/responses/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CreateSurveyForm(forms.Form):

def clean_dept_names(self):
dept_names = self.cleaned_data['dept_names']
matches = re.findall(r'[^A-Za-z0-9\'-,]', dept_names)
matches = re.findall(r'[^A-Za-z0-9,_-]', dept_names)
if matches:
error = '"{dept_names}" contains invalid characters ' \
'{matches}'.format(dept_names=escape(dept_names), matches=list({str(x) for x in matches}))
Expand All @@ -43,7 +43,7 @@ def clean_dept_names(self):

def clean_region_names(self):
region_names = self.cleaned_data['region_names']
matches = re.findall(r'[^A-Za-z0-9\'-,]', region_names)
matches = re.findall(r'[^A-Za-z0-9,_-]', region_names)
if matches:
error = '"{region_names}" contains invalid characters ' \
'{matches}'.format(regions_names=escape(region_names), matches=list({str(x) for x in matches}))
Expand All @@ -52,7 +52,7 @@ def clean_region_names(self):

def clean_site_names(self):
site_names = self.cleaned_data['site_names']
matches = re.findall(r'[^A-Za-z0-9\'-,]', site_names)
matches = re.findall(r'[^A-Za-z0-9,_-]', site_names)
if matches:
error = '"{site_names}" contains invalid characters ' \
'{matches}'.format(site_names=escape(site_names), matches=list({str(x) for x in matches}))
Expand Down Expand Up @@ -84,7 +84,7 @@ def __init__(self, *args, **kwargs):
def clean_filter_dept_names(self):
filter_dept_names = self.cleaned_data['filter_dept_names']
for dept_name in filter_dept_names:
matches = re.findall(r'[^A-Za-z0-9 \'-]', dept_name)
matches = re.findall(r'[^A-Za-z0-9_-]', dept_name)
if matches:
error = '"{dept_name}" contains invalid characters ' \
'{matches}'.format(dept_name=escape(dept_name), matches=list({str(x) for x in matches}))
Expand All @@ -94,7 +94,7 @@ def clean_filter_dept_names(self):
def clean_filter_site_names(self):
filter_site_names = self.cleaned_data['filter_site_names']
for site_name in filter_site_names:
matches = re.findall(r'[^A-Za-z0-9 \'-]', site_name)
matches = re.findall(r'[^A-Za-z0-9_-]', site_name)
if matches:
error = '"{site_name}" contains invalid characters ' \
'{matches}'.format(site_name=escape(site_name), matches=list({str(x) for x in matches}))
Expand All @@ -104,7 +104,7 @@ def clean_filter_site_names(self):
def clean_filter_region_names(self):
filter_region_names = self.cleaned_data['filter_region_names']
for region_name in filter_region_names:
matches = re.findall(r'[^A-Za-z0-9 \'-]', region_name)
matches = re.findall(r'[^A-Za-z0-9_-]', region_name)
if matches:
error = '"{region_name}" contains invalid characters ' \
'{matches}'.format(region_name=escape(region_name), matches=list({str(x) for x in matches}))
Expand Down Expand Up @@ -143,7 +143,7 @@ def clean_team_name(self):

def clean_dept_name(self):
dept_name = self.cleaned_data['dept_name']
matches = re.findall(r'[^A-Za-z0-9 \'-]', dept_name)
matches = re.findall(r'[^A-Za-z0-9_-]', dept_name)
if matches:
error = '"{dept_name}" contains invalid characters ' \
'{matches}'.format(dept_name=escape(dept_name), matches=list({str(x) for x in matches}))
Expand All @@ -152,7 +152,7 @@ def clean_dept_name(self):

def clean_site_name(self):
site_name = self.cleaned_data['site_name']
matches = re.findall(r'[^A-Za-z0-9 \'-]', site_name)
matches = re.findall(r'[^A-Za-z0-9_-]', site_name)
if matches:
error = '"{site_name}" contains invalid characters ' \
'{matches}'.format(site_name=escape(site_name), matches=list({str(x) for x in matches}))
Expand All @@ -161,7 +161,7 @@ def clean_site_name(self):

def clean_region_name(self):
region_name = self.cleaned_data['region_name']
matches = re.findall(r'[^A-Za-z0-9 \'-]', region_name)
matches = re.findall(r'[^A-Za-z0-9_-]', region_name)
if matches:
error = '"{region_name}" contains invalid characters ' \
'{matches}'.format(region_name=escape(region_name), matches=list({str(x) for x in matches}))
Expand Down Expand Up @@ -193,7 +193,7 @@ def clean_score(self):

def clean_word(self):
word = self.cleaned_data['word']
matches = re.findall(r'[^A-Za-z0-9 \'-]', word)
matches = re.findall(r'[^A-Za-z0-9-]', word)
if matches:
error = '"{word}" contains invalid characters ' \
'{matches}'.format(word=escape(word), matches=list({str(x) for x in matches}))
Expand Down Expand Up @@ -241,7 +241,7 @@ def clean_survey_type(self):

def clean_dept_names(self):
dept_names = self.cleaned_data['dept_names']
matches = re.findall(r'[^A-Za-z0-9\'-,]', dept_names)
matches = re.findall(r'[^A-Za-z0-9,_-]', dept_names)
if matches:
error = '"{dept_names}" contains invalid characters ' \
'{matches}'.format(dept_names=escape(dept_names), matches=list({str(x) for x in matches}))
Expand All @@ -250,7 +250,7 @@ def clean_dept_names(self):

def clean_region_names(self):
region_names = self.cleaned_data['region_names']
matches = re.findall(r'[^A-Za-z0-9\'-,]', region_names)
matches = re.findall(r'[^A-Za-z0-9,_-]', region_names)
if matches:
error = '"{region_names}" contains invalid characters ' \
'{matches}'.format(regions_names=escape(region_names), matches=list({str(x) for x in matches}))
Expand All @@ -259,7 +259,7 @@ def clean_region_names(self):

def clean_site_names(self):
site_names = self.cleaned_data['site_names']
matches = re.findall(r'[^A-Za-z0-9\'-,]', site_names)
matches = re.findall(r'[^A-Za-z0-9,_-]', site_names)
if matches:
error = '"{site_names}" contains invalid characters ' \
'{matches}'.format(site_names=escape(site_names), matches=list({str(x) for x in matches}))
Expand All @@ -268,7 +268,7 @@ def clean_site_names(self):

def clean_default_tz(self):
default_tz = self.cleaned_data['default_tz']
matches = re.findall(r'[^A-Za-z0-9\'-/,]', default_tz)
matches = re.findall(r'[^A-Za-z0-9-/]', default_tz)
if matches:
error = '"{default_tz}" contains invalid characters ' \
'{matches}'.format(default_tz=escape(default_tz), matches=list({str(x) for x in matches}))
Expand Down

0 comments on commit 6162395

Please sign in to comment.