[#8376] remove some unnecessary validations
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 54082ce..507ea41 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -255,9 +255,7 @@
label='Gender',
options=[ew.Option(py_value=v, label=v, selected=False)
for v in ['Male', 'Female', 'Unknown', 'Other']],
- validator=formencode.All(
- V.OneOfValidator(['Male', 'Female', 'Unknown', 'Other']),
- V.UnicodeString(not_empty=True))),
+ validator=V.OneOfValidator(['Male', 'Female', 'Unknown', 'Other'])),
ew.SingleSelectField(
name='country',
label='Country of residence',
@@ -450,7 +448,7 @@
ew.SingleSelectField(
name='socialnetwork',
label='Social network',
- validator=V.UnicodeString(not_empty=True),
+ validator=V.OneOfValidator(socialnetworks),
options=[ew.Option(py_value=name, label=name)
for name in socialnetworks]),
ew.TextField(
@@ -499,14 +497,10 @@
class fields(ew_core.NameList):
startdate = ew.TextField(
label='Start date',
- validator=formencode.All(
- V.DateValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.DateValidator())
enddate = ew.TextField(
label='End date',
- validator=formencode.All(
- V.DateValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.DateValidator())
@ew_core.core.validator
def to_python(self, kw, state):
@@ -558,19 +552,13 @@
label='Weekday',
options=[ew.Option(py_value=wd, label=wd)
for wd in weekdays],
- validator=formencode.All(
- V.OneOfValidator(weekdays),
- V.UnicodeString(not_empty=True)))
+ validator=V.OneOfValidator(weekdays))
starttime = ew.TextField(
label='Start time',
- validator=formencode.All(
- V.TimeValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.TimeValidator())
endtime = ew.TextField(
label='End time',
- validator=formencode.All(
- V.TimeValidator(),
- V.UnicodeString(not_empty=True)))
+ validator=V.TimeValidator())
@ew_core.core.validator
def to_python(self, kw, state):
@@ -700,9 +688,7 @@
ew.Option(py_value="low", label="Low level"),
ew.Option(py_value="medium", label="Medium level"),
ew.Option(py_value="high", label="Advanced level")],
- validator=formencode.All(
- V.OneOfValidator(['low', 'medium', 'high']),
- V.UnicodeString(not_empty=True)))
+ validator=V.OneOfValidator(['low', 'medium', 'high']))
comment = ew.TextArea(
label="Additional comments",
validator=V.UnicodeString(not_empty=False),
@@ -730,9 +716,7 @@
self.fields['selected_category'].options = [
ew.Option(py_value=el.trove_cat_id, label=el.fullname) for el in categories
]
- self.fields['selected_category'].validator = formencode.All(
- V.OneOfValidator(categories),
- V.UnicodeString(not_empty=True))
+ self.fields['selected_category'].validator = V.OneOfValidator(categories)
return super(ForgeForm, self).display(**kw)
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index c7dd677..0fa9a09 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -1333,10 +1333,8 @@
_session_id=self.app.cookies['_session_id'],
))
user = M.User.query.get(username='test-admin')
- timeslot1dict = dict(
- week_day=weekday, start_time=starttime, end_time=endtime)
- assert len(
- user.availability) == 1 and timeslot1dict in user.get_availability_timeslots()
+ timeslot1dict = dict(week_day=weekday, start_time=starttime, end_time=endtime)
+ assert len(user.availability) == 1 and timeslot1dict in user.get_availability_timeslots()
weekday2 = 'Tuesday'
starttime2 = time(14, 0, 0)
@@ -1351,8 +1349,7 @@
_session_id=self.app.cookies['_session_id'],
))
user = M.User.query.get(username='test-admin')
- timeslot2dict = dict(week_day=weekday2,
- start_time=starttime2, end_time=endtime2)
+ timeslot2dict = dict(week_day=weekday2, start_time=starttime2, end_time=endtime2)
assert len(user.availability) == 2
assert_in(timeslot1dict, user.get_availability_timeslots())
assert_in(timeslot2dict, user.get_availability_timeslots())
@@ -1378,8 +1375,7 @@
))
assert 'Invalid period:' in str(r)
user = M.User.query.get(username='test-admin')
- timeslot2dict = dict(week_day=weekday2,
- start_time=starttime2, end_time=endtime2)
+ timeslot2dict = dict(week_day=weekday2, start_time=starttime2, end_time=endtime2)
assert len(user.availability) == 1 and timeslot2dict in user.get_availability_timeslots()
@td.with_user_project('test-admin')