[Mpuls-commits] r1483 - wasko/branches/2.0/waskaweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 11 08:12:19 CET 2010
Author: torsten
Date: 2010-02-11 08:12:17 +0100 (Thu, 11 Feb 2010)
New Revision: 1483
Modified:
wasko/branches/2.0/waskaweb/lib/validators.py
Log:
* waskaweb/lib/validators.py (DateCheck), (TimeCheck),
(CreateAppointmentForm), (StringTooLong): Deleted imported from
mpulsweb now.
Modified: wasko/branches/2.0/waskaweb/lib/validators.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/validators.py 2010-02-11 07:07:51 UTC (rev 1482)
+++ wasko/branches/2.0/waskaweb/lib/validators.py 2010-02-11 07:12:17 UTC (rev 1483)
@@ -33,7 +33,8 @@
from mpulsweb.lib.validators import BaseFormValidator, NewPasswordForm, \
ValidatorStateObject, EditUserGroupForm, NewUserGroupForm, EditSettingsForm, \
-NewUserForm, EditUserForm
+NewUserForm, EditUserForm, DateCheck, TimeCheck, CreateAppointmentForm, \
+StringTooLong
class MyDateConverter(formencode.validators.FancyValidator):
@@ -130,27 +131,6 @@
case_id = formencode.validators.Int()
standin = formencode.ForEach(formencode.validators.Int())
-class DateCheck(formencode.validators.FancyValidator):
-
- valid_date = re.compile(r'^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}$')
-
- messages = {
- 'invalid_format': u'Bitte geben Sie das Datum im Format "TT.MM.JJJJ" an.',
- 'invalid_date': u'Bitte geben Sie ein gültiges Datum an.'
- }
-
- def _to_python(self, value, state):
- return value.strip()
-
- def validate_python(self, value, state):
- if not self.valid_date.match(value):
- raise formencode.Invalid(self.message("invalid_format", state), value, state)
- try:
- token = value.split('.')
- testdate = datetime.datetime(int(token[2]), int(token[1]), int(token[0]))
- except:
- raise formencode.Invalid(self.message("invalid_date", state), value, state)
-
class KeineAngabe(formencode.validators.FancyValidator):
messages = {
@@ -164,50 +144,6 @@
if value == '-1':
raise formencode.Invalid(self.message("invalid", state), value, state)
-class TimeCheck(formencode.validators.FancyValidator):
-
- valid_date = re.compile(r'^[0-9]{1,2}:[0-9]{1,2}$')
-
- messages = {
- 'invalid_format': u'Bitte geben Sie die Zeit im Format "HH:MM" an.',
- 'invalid_time': u'Bitte geben Sie eine gültige Zeit an.'
- }
-
- def _to_python(self, value, state):
- return value.strip()
-
- def validate_python(self, value, state):
- if not self.valid_date.match(value):
- raise formencode.Invalid(self.message("invalid_format", state), value, state)
- try:
- token = value.split(':')
- testtime = datetime.time(int(token[0]), int(token[1]))
- except:
- raise formencode.Invalid(self.message("invalid_time", state), value, state)
-
-class StringTooLong(formencode.validators.FancyValidator):
-
- messages = {
- 'invalid_length': u'Bitte geben Sie einen Text mit maximal %(max)i Zeichen an.',
- }
-
- def __init__(self, max=80):
- self.maxlength = max
-
- def _to_python(self, value, state):
- return value.strip()
-
- def validate_python(self, value, state):
- if not value is None and len(value) > self.maxlength:
- raise formencode.Invalid(self.message("invalid_length", state, max=self.maxlength), value, state)
-
-class CreateAppointmentForm(BaseFormValidator):
- start_date = formencode.All(formencode.validators.String(not_empty=True), DateCheck())
- start_time = formencode.All(formencode.validators.String(not_empty=True), TimeCheck())
- end_date = DateCheck()
- end_time = TimeCheck()
- title = formencode.All(formencode.validators.String(not_empty=True), StringTooLong(128))
-
class CreateLogbookForm(BaseFormValidator):
date = DateCheck(not_empty=True)
time = TimeCheck(not_empty=True)
More information about the Mpuls-commits
mailing list