--- a/app/soc/logic/cleaning.py Fri Mar 20 21:16:15 2009 +0000
+++ b/app/soc/logic/cleaning.py Fri Mar 20 21:27:14 2009 +0000
@@ -280,10 +280,12 @@
def clean_ascii_only(field_name):
"""Clean method for cleaning a field that may only contain ASCII-characters.
"""
+
@check_field_is_empty(field_name)
def wrapper(self):
"""Decorator wrapper method.
"""
+
value = self.cleaned_data.get(field_name)
try:
@@ -297,6 +299,24 @@
return wrapper
+def clean_numeric_only(field_name):
+ """Clean method for cleaning a field that may only contain numerical values.
+ """
+
+ @check_field_is_empty(field_name)
+ def wrapper(self):
+ """Decorator wrapped method.
+ """
+
+ value = self.cleaned_data.get(field_name)
+
+ if not value.isdigit():
+ raise forms.ValidationError("Only numerical characters are allowed")
+
+ return value
+ return wrapper
+
+
def clean_feed_url(self):
"""Clean method for cleaning feed url.
"""