annotate rhodecode/model/forms.py @ 3629:802c94bdfc85 beta

#749 and #516 Removed dupliciting of repo settings for rhodecode admins and repo admins - repo admin now is allowed the same set of operations as the rhodecode admin - single logic for forms/validations/permissions - fixes #805 update external repo via webinterface -
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 28 Mar 2013 02:57:05 +0100
parents c734686b3cf2
children ff2ea58debb5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """ this is forms validation classes
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2 http://formencode.org/module-formencode.validators.html
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
3 for list off all availible validators
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
4
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
5 we can create our own validators
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
6
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
7 The table below outlines the options which can be used in a schema in addition to the validators themselves
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
8 pre_validators [] These validators will be applied before the schema
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
9 chained_validators [] These validators will be applied after the schema
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
10 allow_extra_fields False If True, then it is not an error when keys that aren't associated with a validator are present
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
11 filter_extra_fields False If True, then keys that aren't associated with a validator are removed
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
12 if_key_missing NoDefault If this is given, then any keys that aren't available but are expected will be replaced with this value (and then validated). This does not override a present .if_missing attribute on validators. NoDefault is a special FormEncode class to mean that no default values has been specified and therefore missing keys shouldn't take a default value.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1159
diff changeset
13 ignore_key_missing False If True, then missing keys will be missing in the result, if the validator doesn't have .if_missing on it already
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1159
diff changeset
14
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1159
diff changeset
15
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
16 <name> = formencode.validators.<name of validator>
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
17 <name> must equal form name
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
18 list=[1,2,3,4,5]
186
556473ba0399 fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
19 for SELECT use formencode.All(OneOf(list), Int())
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1159
diff changeset
20
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
21 """
761
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
22 import logging
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
23
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
24 import formencode
242
5da4ef115006 Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents: 238
diff changeset
25 from formencode import All
761
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
26
186
556473ba0399 fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
27 from pylons.i18n.translation import _
761
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
28
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
29 from rhodecode.model import validators as v
761
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
30 from rhodecode import BACKENDS
56c2850a5b5f ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents: 746
diff changeset
31
186
556473ba0399 fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
32 log = logging.getLogger(__name__)
556473ba0399 fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
33
1898
a7dfe823933a added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
34
45
a886f5eba757 implemented admin page login
marcink
parents: 0
diff changeset
35 class LoginForm(formencode.Schema):
a886f5eba757 implemented admin page login
marcink
parents: 0
diff changeset
36 allow_extra_fields = True
a886f5eba757 implemented admin page login
marcink
parents: 0
diff changeset
37 filter_extra_fields = True
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
38 username = v.UnicodeString(
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
39 strip=True,
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
40 min=1,
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
41 not_empty=True,
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
42 messages={
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
43 'empty': _(u'Please enter a login'),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
44 'tooShort': _(u'Enter a value %(min)i characters long or more')}
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
45 )
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
46
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
47 password = v.UnicodeString(
2181
e1c1ebbe7346 #419 don't strip passwords for login forms, make rhodecode more compatible with LDAP servers
Marcin Kuzminski <marcin@python-works.com>
parents: 2072
diff changeset
48 strip=False,
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
49 min=3,
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
50 not_empty=True,
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
51 messages={
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
52 'empty': _(u'Please enter a password'),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
53 'tooShort': _(u'Enter %(min)i characters or more')}
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
54 )
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
55
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
56 remember = v.StringBoolean(if_missing=False)
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1802
diff changeset
57
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
58 chained_validators = [v.ValidAuth()]
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
59
1898
a7dfe823933a added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
60
357
ebdd1a89cdd9 Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents: 356
diff changeset
61 def UserForm(edit=False, old_data={}):
238
a55c17874486 Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents: 234
diff changeset
62 class _UserForm(formencode.Schema):
a55c17874486 Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents: 234
diff changeset
63 allow_extra_fields = True
a55c17874486 Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents: 234
diff changeset
64 filter_extra_fields = True
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
65 username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
66 v.ValidUsername(edit, old_data))
238
a55c17874486 Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents: 234
diff changeset
67 if edit:
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
68 new_password = All(
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2485
diff changeset
69 v.ValidPassword(),
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
70 v.UnicodeString(strip=False, min=6, not_empty=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
71 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
72 password_confirmation = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
73 v.ValidPassword(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
74 v.UnicodeString(strip=False, min=6, not_empty=False),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
75 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
76 admin = v.StringBoolean(if_missing=False)
238
a55c17874486 Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents: 234
diff changeset
77 else:
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
78 password = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
79 v.ValidPassword(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
80 v.UnicodeString(strip=False, min=6, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
81 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
82 password_confirmation = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
83 v.ValidPassword(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
84 v.UnicodeString(strip=False, min=6, not_empty=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
85 )
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
86
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
87 active = v.StringBoolean(if_missing=False)
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2485
diff changeset
88 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
89 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
90 email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
91
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
92 chained_validators = [v.ValidPasswordsMatch()]
722
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
93
238
a55c17874486 Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents: 234
diff changeset
94 return _UserForm
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 242
diff changeset
95
959
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
96
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3308
diff changeset
97 def UserGroupForm(edit=False, old_data={}, available_members=[]):
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3308
diff changeset
98 class _UserGroupForm(formencode.Schema):
959
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
99 allow_extra_fields = True
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
100 filter_extra_fields = True
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
101
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
102 users_group_name = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
103 v.UnicodeString(strip=True, min=1, not_empty=True),
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3308
diff changeset
104 v.ValidUserGroup(edit, old_data)
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
105 )
959
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
106
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
107 users_group_active = v.StringBoolean(if_missing=False)
959
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
108
972
2c8fd84935a4 #56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents: 962
diff changeset
109 if edit:
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
110 users_group_members = v.OneOf(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
111 available_members, hideList=False, testValueList=True,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
112 if_missing=None, not_empty=False
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
113 )
972
2c8fd84935a4 #56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents: 962
diff changeset
114
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3308
diff changeset
115 return _UserGroupForm
959
fff21c9b075c #56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents: 891
diff changeset
116
1898
a7dfe823933a added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
117
3222
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
118 def ReposGroupForm(edit=False, old_data={}, available_groups=[],
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
119 can_create_in_root=False):
1345
3bce31f026b8 #47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents: 1324
diff changeset
120 class _ReposGroupForm(formencode.Schema):
3bce31f026b8 #47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents: 1324
diff changeset
121 allow_extra_fields = True
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1976
diff changeset
122 filter_extra_fields = False
1345
3bce31f026b8 #47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents: 1324
diff changeset
123
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
124 group_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
125 v.SlugifyName())
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
126 group_description = v.UnicodeString(strip=True, min=1,
3222
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
127 not_empty=False)
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
128 if edit:
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
129 #FIXME: do a special check that we cannot move a group to one of
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
130 #it's children
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
131 pass
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
132 group_parent_id = All(v.CanCreateGroup(can_create_in_root),
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
133 v.OneOf(available_groups, hideList=False,
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
134 testValueList=True,
b4daef4cc26d Group management delegation:
Marcin Kuzminski <marcin@python-works.com>
parents: 3175
diff changeset
135 if_missing=None, not_empty=True))
2749
3ed4dae499d0 Recursive set locking on all children of a group.
Marcin Kuzminski <marcin@python-works.com>
parents: 2726
diff changeset
136 enable_locking = v.StringBoolean(if_missing=False)
2820
c0cc8f8a71b0 Permissions on group can be set in recursive mode setting defined permission to all children
Marcin Kuzminski <marcin@python-works.com>
parents: 2815
diff changeset
137 recursive = v.StringBoolean(if_missing=False)
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
138 chained_validators = [v.ValidReposGroup(edit, old_data),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
139 v.ValidPerms('group')]
1345
3bce31f026b8 #47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents: 1324
diff changeset
140
3bce31f026b8 #47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents: 1324
diff changeset
141 return _ReposGroupForm
3bce31f026b8 #47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents: 1324
diff changeset
142
1898
a7dfe823933a added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
143
722
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
144 def RegisterForm(edit=False, old_data={}):
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
145 class _RegisterForm(formencode.Schema):
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
146 allow_extra_fields = True
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
147 filter_extra_fields = True
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
148 username = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
149 v.ValidUsername(edit, old_data),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
150 v.UnicodeString(strip=True, min=1, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
151 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
152 password = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
153 v.ValidPassword(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
154 v.UnicodeString(strip=False, min=6, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
155 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
156 password_confirmation = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
157 v.ValidPassword(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
158 v.UnicodeString(strip=False, min=6, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
159 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
160 active = v.StringBoolean(if_missing=False)
2595
6c83dc0226d2 renamed some leftover name -> firstname
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
161 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
162 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
163 email = All(v.Email(not_empty=True), v.UniqSystemEmail(old_data))
722
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
164
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
165 chained_validators = [v.ValidPasswordsMatch()]
722
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
166
02bdf2f296ff fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents: 710
diff changeset
167 return _RegisterForm
474
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
168
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
169
474
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
170 def PasswordResetForm():
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
171 class _PasswordResetForm(formencode.Schema):
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
172 allow_extra_fields = True
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
173 filter_extra_fields = True
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
174 email = All(v.ValidSystemEmail(), v.Email(not_empty=True))
474
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
175 return _PasswordResetForm
a3d9d24acbec Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents: 458
diff changeset
176
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
177
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1022
diff changeset
178 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
2460
12fa0c19c42f validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
179 repo_groups=[], landing_revs=[]):
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 242
diff changeset
180 class _RepoForm(formencode.Schema):
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 242
diff changeset
181 allow_extra_fields = True
3089
4cc9bb83ecb4 Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents: 3056
diff changeset
182 filter_extra_fields = False
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
183 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
184 v.SlugifyName())
3524
af96fb19b53a Pass in old groups data to CanWriteToGroup validator for later skipping group checks.
Marcin Kuzminski <marcin@python-works.com>
parents: 3486
diff changeset
185 repo_group = All(v.CanWriteGroup(old_data),
2835
faffec4abbda Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2820
diff changeset
186 v.OneOf(repo_groups, hideList=True))
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
187 repo_type = v.OneOf(supported_backends)
3056
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
188 repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
189 repo_private = v.StringBoolean(if_missing=False)
3089
4cc9bb83ecb4 Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents: 3056
diff changeset
190 repo_landing_rev = v.OneOf(landing_revs, hideList=True)
4cc9bb83ecb4 Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents: 3056
diff changeset
191 clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
4cc9bb83ecb4 Fixed some issues with edit form
Marcin Kuzminski <marcin@python-works.com>
parents: 3056
diff changeset
192
3056
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
193 repo_enable_statistics = v.StringBoolean(if_missing=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
194 repo_enable_downloads = v.StringBoolean(if_missing=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
195 repo_enable_locking = v.StringBoolean(if_missing=False)
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1022
diff changeset
196
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 242
diff changeset
197 if edit:
1014
6fdc3ff65fce #56 added assignments of users groups into repository
Marcin Kuzminski <marcin@python-works.com>
parents: 1013
diff changeset
198 #this is repo owner
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
199 user = All(v.UnicodeString(not_empty=True), v.ValidRepoUser())
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
200
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
201 chained_validators = [v.ValidCloneUri(),
3628
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
202 v.ValidRepoName(edit, old_data)]
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 242
diff changeset
203 return _RepoForm
320
05b212954275 Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents: 310
diff changeset
204
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
205
3628
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
206 def RepoPermsForm():
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
207 class _RepoPermsForm(formencode.Schema):
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
208 allow_extra_fields = True
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
209 filter_extra_fields = False
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
210 chained_validators = [v.ValidPerms()]
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
211 return _RepoPermsForm
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
212
c734686b3cf2 moved permission management into separate entity.
Marcin Kuzminski <marcin@python-works.com>
parents: 3524
diff changeset
213
3308
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
214 def RepoFieldForm():
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
215 class _RepoFieldForm(formencode.Schema):
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
216 filter_extra_fields = True
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
217 allow_extra_fields = True
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
218
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
219 new_field_key = All(v.FieldKey(),
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
220 v.UnicodeString(strip=True, min=3, not_empty=True))
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
221 new_field_value = v.UnicodeString(not_empty=False, if_missing='')
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
222 new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'],
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
223 if_missing='str')
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
224 new_field_label = v.UnicodeString(not_empty=False)
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
225 new_field_desc = v.UnicodeString(not_empty=False)
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
226
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
227 return _RepoFieldForm
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
228
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
229
2460
12fa0c19c42f validating choices for landing_rev
Marcin Kuzminski <marcin@python-works.com>
parents: 2459
diff changeset
230 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
2485
133209bf300c added landing revision into fork create form
Marcin Kuzminski <marcin@python-works.com>
parents: 2480
diff changeset
231 repo_groups=[], landing_revs=[]):
530
a08f610e545e Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents: 529
diff changeset
232 class _RepoForkForm(formencode.Schema):
a08f610e545e Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents: 529
diff changeset
233 allow_extra_fields = True
a08f610e545e Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents: 529
diff changeset
234 filter_extra_fields = False
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
235 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
236 v.SlugifyName())
2835
faffec4abbda Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2820
diff changeset
237 repo_group = All(v.CanWriteGroup(),
faffec4abbda Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents: 2820
diff changeset
238 v.OneOf(repo_groups, hideList=True))
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
239 repo_type = All(v.ValidForkType(old_data), v.OneOf(supported_backends))
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
240 description = v.UnicodeString(strip=True, min=1, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
241 private = v.StringBoolean(if_missing=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
242 copy_permissions = v.StringBoolean(if_missing=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
243 update_after_clone = v.StringBoolean(if_missing=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
244 fork_parent_id = v.UnicodeString()
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
245 chained_validators = [v.ValidForkName(edit, old_data)]
2485
133209bf300c added landing revision into fork create form
Marcin Kuzminski <marcin@python-works.com>
parents: 2480
diff changeset
246 landing_rev = v.OneOf(landing_revs, hideList=True)
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1364
diff changeset
247
530
a08f610e545e Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents: 529
diff changeset
248 return _RepoForkForm
a08f610e545e Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents: 529
diff changeset
249
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
250
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 347
diff changeset
251 def ApplicationSettingsForm():
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 347
diff changeset
252 class _ApplicationSettingsForm(formencode.Schema):
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 347
diff changeset
253 allow_extra_fields = True
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 347
diff changeset
254 filter_extra_fields = False
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
255 rhodecode_title = v.UnicodeString(strip=True, min=1, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
256 rhodecode_realm = v.UnicodeString(strip=True, min=1, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
257 rhodecode_ga_code = v.UnicodeString(strip=True, min=1, not_empty=False)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
258
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 347
diff changeset
259 return _ApplicationSettingsForm
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
260
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
261
2674
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
262 def ApplicationVisualisationForm():
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
263 class _ApplicationVisualisationForm(formencode.Schema):
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
264 allow_extra_fields = True
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
265 filter_extra_fields = False
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
266 rhodecode_show_public_icon = v.StringBoolean(if_missing=False)
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
267 rhodecode_show_private_icon = v.StringBoolean(if_missing=False)
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
268 rhodecode_stylify_metatags = v.StringBoolean(if_missing=False)
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
269
2936
62e493c7f436 Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents: 2893
diff changeset
270 rhodecode_lightweight_dashboard = v.StringBoolean(if_missing=False)
3308
72a91632b731 repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents: 3222
diff changeset
271 rhodecode_repository_fields = v.StringBoolean(if_missing=False)
2952
029a40c58df7 Added lightweight journal option for visual
Marcin Kuzminski <marcin@python-works.com>
parents: 2936
diff changeset
272 rhodecode_lightweight_journal = v.StringBoolean(if_missing=False)
2936
62e493c7f436 Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents: 2893
diff changeset
273
2674
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
274 return _ApplicationVisualisationForm
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
275
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
276
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
277 def ApplicationUiSettingsForm():
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
278 class _ApplicationUiSettingsForm(formencode.Schema):
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
279 allow_extra_fields = True
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
280 filter_extra_fields = False
2674
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
281 web_push_ssl = v.StringBoolean(if_missing=False)
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
282 paths_root_path = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
283 v.ValidPath(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
284 v.UnicodeString(strip=True, min=1, not_empty=True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
285 )
2674
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
286 hooks_changegroup_update = v.StringBoolean(if_missing=False)
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
287 hooks_changegroup_repo_size = v.StringBoolean(if_missing=False)
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
288 hooks_changegroup_push_logger = v.StringBoolean(if_missing=False)
2726
aa17c7a1b8a5 Implemented basic locking functionality.
Marcin Kuzminski <marcin@python-works.com>
parents: 2719
diff changeset
289 hooks_outgoing_pull_logger = v.StringBoolean(if_missing=False)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
290
2708
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
291 extensions_largefiles = v.StringBoolean(if_missing=False)
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
292 extensions_hgsubversion = v.StringBoolean(if_missing=False)
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
293 extensions_hggit = v.StringBoolean(if_missing=False)
9bce679a3f49 Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents: 2674
diff changeset
294
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
295 return _ApplicationUiSettingsForm
320
05b212954275 Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents: 310
diff changeset
296
1950
4ae17f819ee8 #344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents: 1898
diff changeset
297
3056
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
298 def DefaultPermissionsForm(repo_perms_choices, group_perms_choices,
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
299 register_choices, create_choices, fork_choices):
417
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 416
diff changeset
300 class _DefaultPermissionsForm(formencode.Schema):
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 416
diff changeset
301 allow_extra_fields = True
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 416
diff changeset
302 filter_extra_fields = True
3052
d3200c58764e implemented #663 Admin/permission: specify default repogroup perms
Marcin Kuzminski <marcin@python-works.com>
parents: 2986
diff changeset
303 overwrite_default_repo = v.StringBoolean(if_missing=False)
d3200c58764e implemented #663 Admin/permission: specify default repogroup perms
Marcin Kuzminski <marcin@python-works.com>
parents: 2986
diff changeset
304 overwrite_default_group = v.StringBoolean(if_missing=False)
2674
a221706dab50 merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents: 2595
diff changeset
305 anonymous = v.StringBoolean(if_missing=False)
3052
d3200c58764e implemented #663 Admin/permission: specify default repogroup perms
Marcin Kuzminski <marcin@python-works.com>
parents: 2986
diff changeset
306 default_repo_perm = v.OneOf(repo_perms_choices)
d3200c58764e implemented #663 Admin/permission: specify default repogroup perms
Marcin Kuzminski <marcin@python-works.com>
parents: 2986
diff changeset
307 default_group_perm = v.OneOf(group_perms_choices)
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
308 default_register = v.OneOf(register_choices)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
309 default_create = v.OneOf(create_choices)
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2708
diff changeset
310 default_fork = v.OneOf(fork_choices)
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 555
diff changeset
311
417
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 416
diff changeset
312 return _DefaultPermissionsForm
705
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
313
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
314
3056
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
315 def DefaultsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()):
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
316 class _DefaultsForm(formencode.Schema):
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
317 allow_extra_fields = True
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
318 filter_extra_fields = True
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
319 default_repo_type = v.OneOf(supported_backends)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
320 default_repo_private = v.StringBoolean(if_missing=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
321 default_repo_enable_statistics = v.StringBoolean(if_missing=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
322 default_repo_enable_downloads = v.StringBoolean(if_missing=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
323 default_repo_enable_locking = v.StringBoolean(if_missing=False)
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
324
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
325 return _DefaultsForm
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
326
6104dfd35b16 Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 3052
diff changeset
327
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
328 def LdapSettingsForm(tls_reqcert_choices, search_scope_choices,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
329 tls_kind_choices):
705
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
330 class _LdapSettingsForm(formencode.Schema):
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
331 allow_extra_fields = True
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
332 filter_extra_fields = True
2193
3ea397063fc7 fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents: 2181
diff changeset
333 #pre_validators = [LdapLibValidator]
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
334 ldap_active = v.StringBoolean(if_missing=False)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
335 ldap_host = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
336 ldap_port = v.Number(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
337 ldap_tls_kind = v.OneOf(tls_kind_choices)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
338 ldap_tls_reqcert = v.OneOf(tls_reqcert_choices)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
339 ldap_dn_user = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
340 ldap_dn_pass = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
341 ldap_base_dn = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
342 ldap_filter = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
343 ldap_search_scope = v.OneOf(search_scope_choices)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
344 ldap_attr_login = All(
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
345 v.AttrLoginValidator(),
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
346 v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
347 )
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
348 ldap_attr_firstname = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
349 ldap_attr_lastname = v.UnicodeString(strip=True,)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 2460
diff changeset
350 ldap_attr_email = v.UnicodeString(strip=True,)
705
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
351
9e9f1b919c0c implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents: 699
diff changeset
352 return _LdapSettingsForm
2479
9225597688f4 Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
353
9225597688f4 Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
354
9225597688f4 Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
355 def UserExtraEmailForm():
9225597688f4 Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
356 class _UserExtraEmailForm(formencode.Schema):
3125
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
357 email = All(v.UniqSystemEmail(), v.Email(not_empty=True))
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
358 return _UserExtraEmailForm
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
359
2479
9225597688f4 Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
360
3125
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
361 def UserExtraIpForm():
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
362 class _UserExtraIpForm(formencode.Schema):
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
363 ip = v.ValidIp()(not_empty=True)
9b92cf5a0cca Added UserIpMap interface for allowed IP addresses and IP restriction access
Marcin Kuzminski <marcin@python-works.com>
parents: 3089
diff changeset
364 return _UserExtraIpForm
2711
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
365
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
366
2893
eb180eb16c18 Fixed #585, checks for status of revision where to strict, and made opening pull request with those revision impossible due to previosly set status.
Marcin Kuzminski <marcin@python-works.com>
parents: 2835
diff changeset
367 def PullRequestForm(repo_id):
2711
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
368 class _PullRequestForm(formencode.Schema):
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
369 allow_extra_fields = True
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
370 filter_extra_fields = True
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
371
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
372 user = v.UnicodeString(strip=True, required=True)
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
373 org_repo = v.UnicodeString(strip=True, required=True)
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
374 org_ref = v.UnicodeString(strip=True, required=True)
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
375 other_repo = v.UnicodeString(strip=True, required=True)
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
376 other_ref = v.UnicodeString(strip=True, required=True)
3175
5d1d25c1c700 set the status of changesets initially on pull request, and make sure we care of version collisions.
Marcin Kuzminski <marcin@python-works.com>
parents: 3125
diff changeset
377 revisions = All(#v.NotReviewedRevisions(repo_id)(),
5d1d25c1c700 set the status of changesets initially on pull request, and make sure we care of version collisions.
Marcin Kuzminski <marcin@python-works.com>
parents: 3125
diff changeset
378 v.UniqueList(not_empty=True))
2719
2e7f7568ea92 Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents: 2711
diff changeset
379 review_members = v.UniqueList(not_empty=True)
2711
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
380
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
381 pullrequest_title = v.UnicodeString(strip=True, required=True, min=3)
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
382 pullrequest_desc = v.UnicodeString(strip=True, required=False)
1de45f582f9d added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
383
3486
2053053e0882 compare/pullrequest: introduce merge parameter
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
384 ancestor_rev = v.UnicodeString(strip=True, required=True)
2053053e0882 compare/pullrequest: introduce merge parameter
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
385 merge_rev = v.UnicodeString(strip=True, required=True)
2053053e0882 compare/pullrequest: introduce merge parameter
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
386
2815
acc05c33cc0c White space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 2749
diff changeset
387 return _PullRequestForm