diff rhodecode/model/forms.py @ 3089:4cc9bb83ecb4 beta

Fixed some issues with edit form - unified code (but still a lot of duplicated code left over) - fixed forms - fixed validators
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 13 Dec 2012 03:34:19 +0100
parents 6104dfd35b16
children a5f0bc867edc 9b92cf5a0cca
line wrap: on
line diff
--- a/rhodecode/model/forms.py	Thu Dec 13 00:09:59 2012 +0100
+++ b/rhodecode/model/forms.py	Thu Dec 13 03:34:19 2012 +0100
@@ -173,7 +173,7 @@
              repo_groups=[], landing_revs=[]):
     class _RepoForm(formencode.Schema):
         allow_extra_fields = True
-        filter_extra_fields = True
+        filter_extra_fields = False
         repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
                         v.SlugifyName())
         repo_group = All(v.CanWriteGroup(),
@@ -181,11 +181,12 @@
         repo_type = v.OneOf(supported_backends)
         repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
         repo_private = v.StringBoolean(if_missing=False)
+        repo_landing_rev = v.OneOf(landing_revs, hideList=True)
+        clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
+
         repo_enable_statistics = v.StringBoolean(if_missing=False)
         repo_enable_downloads = v.StringBoolean(if_missing=False)
         repo_enable_locking = v.StringBoolean(if_missing=False)
-        repo_landing_rev = v.OneOf(landing_revs, hideList=True)
-        clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
 
         if edit:
             #this is repo owner
@@ -197,6 +198,27 @@
     return _RepoForm
 
 
+def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
+                     repo_groups=[], landing_revs=[]):
+    class _RepoForm(formencode.Schema):
+        allow_extra_fields = True
+        filter_extra_fields = False
+        repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
+                        v.SlugifyName())
+        repo_group = All(v.CanWriteGroup(),
+                         v.OneOf(repo_groups, hideList=True))
+        repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
+        repo_private = v.StringBoolean(if_missing=False)
+        repo_landing_rev = v.OneOf(landing_revs, hideList=True)
+        clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
+
+        chained_validators = [v.ValidCloneUri(),
+                              v.ValidRepoName(edit, old_data),
+                              v.ValidPerms(),
+                              v.ValidSettings()]
+    return _RepoForm
+
+
 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
                  repo_groups=[], landing_revs=[]):
     class _RepoForkForm(formencode.Schema):
@@ -218,23 +240,6 @@
     return _RepoForkForm
 
 
-def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
-                     repo_groups=[], landing_revs=[]):
-    class _RepoForm(formencode.Schema):
-        allow_extra_fields = True
-        filter_extra_fields = False
-        repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
-                        v.SlugifyName())
-        description = v.UnicodeString(strip=True, min=1, not_empty=True)
-        repo_group = All(v.CanWriteGroup(),
-                         v.OneOf(repo_groups, hideList=True))
-        private = v.StringBoolean(if_missing=False)
-        landing_rev = v.OneOf(landing_revs, hideList=True)
-        chained_validators = [v.ValidRepoName(edit, old_data), v.ValidPerms(),
-                              v.ValidSettings()]
-    return _RepoForm
-
-
 def ApplicationSettingsForm():
     class _ApplicationSettingsForm(formencode.Schema):
         allow_extra_fields = True