Commits

Andriy Kornatskyy  committed f55da10

Added account type to public demo registration as example for radio widget; Updated validation messages

  • Participants
  • Parent commits 052ff51

Comments (0)

Files changed (6)

File demos/public/content/templates/membership/signup.html

                 ${account.email.error()}
                 </p>
                 <p>
+                ${account.account_type.label('Account Type:')}
+                ${account.account_type.radio(choices=(('1', 'User'), ('2', 'Business')))}
+                ${account.account_type.error()}
+                </p>
+                <p>
                 ${registration.date_of_birth.label('Date of birth (YYYY/MM/DD):')}
                 ${registration.date_of_birth.textbox(autocomplete='off')}
                 ${registration.date_of_birth.error()}

File demos/public/i18n/en/LC_MESSAGES/validation.po

 msgstr "%H:%M"
 
 #. fallback time input formats: 16:34:52. Use | to separate multiple values.
-#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:20
-#: src/wheezy/validation/format.py:21
+#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:21
 msgid "%H:%M:%S"
 msgstr "%H:%M:%S"
 
 #. default datetime input format: 2008/5/18 16:34
-#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:22
-#: src/wheezy/validation/format.py:23
+#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:23
 msgid "%Y/%m/%d %H:%M"
 msgstr "%Y/%m/%d %H:%M"
 
 #. fallback datetime input formats: 2008/5/18 16:34:52. Use | to separate.
-#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:23
-#: src/wheezy/validation/format.py:26 src/wheezy/validation/format.py:27
+#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:26
+#: src/wheezy/validation/format.py:27
 msgid ""
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:81 src/wheezy/validation/model.py:82
-#: src/wheezy/validation/model.py:91 src/wheezy/validation/model.py:103
-#: src/wheezy/validation/model.py:107
+#: src/wheezy/validation/model.py:109
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:108 src/wheezy/validation/model.py:112
+#: src/wheezy/validation/model.py:112
+msgid "Input was not in a correct format."
+msgstr "Input was not in a correct format."
+
+#: src/wheezy/validation/model.py:113 src/wheezy/validation/model.py:117
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/rules.py:17 src/wheezy/validation/rules.py:20
+#: src/wheezy/validation/rules.py:25
 msgid "Required field cannot be left blank."
 msgstr "Required field cannot be left blank."
 
-#: src/wheezy/validation/rules.py:87 src/wheezy/validation/rules.py:90
+#: src/wheezy/validation/rules.py:95 src/wheezy/validation/rules.py:98
 #, python-format
 msgid "Required to be a minimum of %(min)d characters in length."
 msgstr "Required to be a minimum of %(min)d characters in length."
 
-#: src/wheezy/validation/rules.py:92 src/wheezy/validation/rules.py:95
+#: src/wheezy/validation/rules.py:100 src/wheezy/validation/rules.py:103
 #, python-format
 msgid "The length must fall within the range %(min)d - %(max)d characters."
 msgstr "The length must fall within the range %(min)d - %(max)d characters."
 
-#: src/wheezy/validation/rules.py:99 src/wheezy/validation/rules.py:102
+#: src/wheezy/validation/rules.py:107 src/wheezy/validation/rules.py:110
 #, python-format
 msgid "Exceeds maximum length of %(max)d."
 msgstr "Exceeds maximum length of %(max)d."
 
-#: src/wheezy/validation/rules.py:224 src/wheezy/validation/rules.py:227
+#: src/wheezy/validation/rules.py:232 src/wheezy/validation/rules.py:235
 #, python-format
 msgid "The value failed equality comparison with \"%(comparand)s\"."
 msgstr "The value failed equality comparison with \"%(comparand)s\"."
 
-#: src/wheezy/validation/rules.py:290
+#: src/wheezy/validation/rules.py:298
 msgid "Required to match validation pattern."
 msgstr "Required to match validation pattern."
 
-#: src/wheezy/validation/rules.py:322
+#: src/wheezy/validation/rules.py:330
 msgid ""
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "hyphens."
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "hyphens."
 
-#: src/wheezy/validation/rules.py:354
+#: src/wheezy/validation/rules.py:362
 msgid "Required to be a valid email address."
 msgstr "Required to be a valid email address."
 
-#: src/wheezy/validation/rules.py:402
+#: src/wheezy/validation/rules.py:410
 #, python-format
 msgid "Required to be greater or equal to %(min)s."
 msgstr "Required to be greater or equal to %(min)s."
 
-#: src/wheezy/validation/rules.py:406
+#: src/wheezy/validation/rules.py:414
 #, python-format
 msgid "The value must fall within the range %(min)s - %(max)s"
 msgstr "The value must fall within the range %(min)s - %(max)s"
 
-#: src/wheezy/validation/rules.py:413
+#: src/wheezy/validation/rules.py:421
 #, python-format
 msgid "Exceeds maximum allowed value of %(max)s."
 msgstr "Exceeds maximum allowed value of %(max)s."

File demos/public/i18n/ru/LC_MESSAGES/validation.po

 msgid "The value '%s' is not in one of supported formats."
 msgstr "Значение '%s' не соответсвует ни одному из поддеживаемых форматов."
 
+#: src/wheezy/validation/model.py:112
+msgid "Input was not in a correct format."
+msgstr "Ввод не в правильном формате."
+
 #: src/wheezy/validation/rules.py:12
 msgid "Required field cannot be left blank."
 msgstr "Обязательное поле не может быть пустым."

File demos/public/i18n/validation.po

 msgstr "%H:%M"
 
 #. fallback time input formats: 16:34:52. Use | to separate multiple values.
-#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:20
-#: src/wheezy/validation/format.py:21
+#: src/wheezy/validation/format.py:18 src/wheezy/validation/format.py:21
 msgid "%H:%M:%S"
 msgstr "%H:%M:%S"
 
 #. default datetime input format: 2008/5/18 16:34
-#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:22
-#: src/wheezy/validation/format.py:23
+#: src/wheezy/validation/format.py:20 src/wheezy/validation/format.py:23
 msgid "%Y/%m/%d %H:%M"
 msgstr "%Y/%m/%d %H:%M"
 
 #. fallback datetime input formats: 2008/5/18 16:34:52. Use | to separate.
-#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:23
-#: src/wheezy/validation/format.py:26 src/wheezy/validation/format.py:27
+#: src/wheezy/validation/format.py:22 src/wheezy/validation/format.py:26
+#: src/wheezy/validation/format.py:27
 msgid ""
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 "%Y/%m/%d %H:%M:%S|%m/%d/%Y %H:%M|%m/%d/%Y %H:%M:%S|%Y-%m-%d %H:%M|%Y-%m-%d "
 "%H:%M:%S|%m/%d/%y %H:%M|%m/%d/%y %H:%M:%S"
 
-#: src/wheezy/validation/model.py:81 src/wheezy/validation/model.py:82
-#: src/wheezy/validation/model.py:91 src/wheezy/validation/model.py:103
-#: src/wheezy/validation/model.py:107
+#: src/wheezy/validation/model.py:109
 #, python-format
 msgid "The value '%s' is invalid."
 msgstr "The value '%s' is invalid."
 
-#: src/wheezy/validation/model.py:108 src/wheezy/validation/model.py:112
+#: src/wheezy/validation/model.py:112
+msgid "Input was not in a correct format."
+msgstr "Input was not in a correct format."
+
+#: src/wheezy/validation/model.py:113 src/wheezy/validation/model.py:117
 #, python-format
 msgid "The value '%s' is not in one of supported formats."
 msgstr "The value '%s' is not in one of supported formats."
 
-#: src/wheezy/validation/rules.py:17 src/wheezy/validation/rules.py:20
+#: src/wheezy/validation/rules.py:25
 msgid "Required field cannot be left blank."
 msgstr "Required field cannot be left blank."
 
-#: src/wheezy/validation/rules.py:87 src/wheezy/validation/rules.py:90
+#: src/wheezy/validation/rules.py:95 src/wheezy/validation/rules.py:98
 #, python-format
 msgid "Required to be a minimum of %(min)d characters in length."
 msgstr "Required to be a minimum of %(min)d characters in length."
 
-#: src/wheezy/validation/rules.py:92 src/wheezy/validation/rules.py:95
+#: src/wheezy/validation/rules.py:100 src/wheezy/validation/rules.py:103
 #, python-format
 msgid "The length must fall within the range %(min)d - %(max)d characters."
 msgstr "The length must fall within the range %(min)d - %(max)d characters."
 
-#: src/wheezy/validation/rules.py:99 src/wheezy/validation/rules.py:102
+#: src/wheezy/validation/rules.py:107 src/wheezy/validation/rules.py:110
 #, python-format
 msgid "Exceeds maximum length of %(max)d."
 msgstr "Exceeds maximum length of %(max)d."
 
-#: src/wheezy/validation/rules.py:224 src/wheezy/validation/rules.py:227
+#: src/wheezy/validation/rules.py:232 src/wheezy/validation/rules.py:235
 #, python-format
 msgid "The value failed equality comparison with \"%(comparand)s\"."
 msgstr "The value failed equality comparison with \"%(comparand)s\"."
 
-#: src/wheezy/validation/rules.py:290
+#: src/wheezy/validation/rules.py:298
 msgid "Required to match validation pattern."
 msgstr "Required to match validation pattern."
 
-#: src/wheezy/validation/rules.py:322
+#: src/wheezy/validation/rules.py:330
 msgid ""
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "hyphens."
 "Invalid slug. The value must consist of letters, digits, underscopes and/or "
 "hyphens."
 
-#: src/wheezy/validation/rules.py:354
+#: src/wheezy/validation/rules.py:362
 msgid "Required to be a valid email address."
 msgstr "Required to be a valid email address."
 
-#: src/wheezy/validation/rules.py:402
+#: src/wheezy/validation/rules.py:410
 #, python-format
 msgid "Required to be greater or equal to %(min)s."
 msgstr "Required to be greater or equal to %(min)s."
 
-#: src/wheezy/validation/rules.py:406
+#: src/wheezy/validation/rules.py:414
 #, python-format
 msgid "The value must fall within the range %(min)s - %(max)s"
 msgstr "The value must fall within the range %(min)s - %(max)s"
 
-#: src/wheezy/validation/rules.py:413
+#: src/wheezy/validation/rules.py:421
 #, python-format
 msgid "Exceeds maximum allowed value of %(max)s."
 msgstr "Exceeds maximum allowed value of %(max)s."

File demos/public/src/membership/models.py

     def __init__(self):
         self.email = u('')
         self.display_name = u('')
+        self.account_type = 1  # 1 - user, 2 - business
 
 
 class Registration(object):

File demos/public/src/membership/validation.py

 from wheezy.validation.rules import compare
 from wheezy.validation.rules import length
 from wheezy.validation.rules import required
+from wheezy.validation.rules import range
 
 
 _ = lambda s: s
 
 account_validator = Validator({
     'email': [required, length(min=6, max=30)],
-    'display_name': [required, length(max=30)]
+    'display_name': [required, length(max=30)],
+    'account_type': [required, range(min=1, max=2)]
 })
 
 registration_validator = Validator({