##// END OF EJS Templates
users: do not require description on admin user creation
marcink -
r4056:0532bdf7 default
parent child Browse files
Show More
@@ -1,630 +1,631 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2
2
3 # Copyright (C) 2010-2019 RhodeCode GmbH
3 # Copyright (C) 2010-2019 RhodeCode GmbH
4 #
4 #
5 # This program is free software: you can redistribute it and/or modify
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License, version 3
6 # it under the terms of the GNU Affero General Public License, version 3
7 # (only), as published by the Free Software Foundation.
7 # (only), as published by the Free Software Foundation.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU Affero General Public License
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 #
16 #
17 # This program is dual-licensed. If you wish to learn more about the
17 # This program is dual-licensed. If you wish to learn more about the
18 # RhodeCode Enterprise Edition, including its added features, Support services,
18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20
20
21 """
21 """
22 this is forms validation classes
22 this is forms validation classes
23 http://formencode.org/module-formencode.validators.html
23 http://formencode.org/module-formencode.validators.html
24 for list off all availible validators
24 for list off all availible validators
25
25
26 we can create our own validators
26 we can create our own validators
27
27
28 The table below outlines the options which can be used in a schema in addition to the validators themselves
28 The table below outlines the options which can be used in a schema in addition to the validators themselves
29 pre_validators [] These validators will be applied before the schema
29 pre_validators [] These validators will be applied before the schema
30 chained_validators [] These validators will be applied after the schema
30 chained_validators [] These validators will be applied after the schema
31 allow_extra_fields False If True, then it is not an error when keys that aren't associated with a validator are present
31 allow_extra_fields False If True, then it is not an error when keys that aren't associated with a validator are present
32 filter_extra_fields False If True, then keys that aren't associated with a validator are removed
32 filter_extra_fields False If True, then keys that aren't associated with a validator are removed
33 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.
33 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.
34 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
34 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
35
35
36
36
37 <name> = formencode.validators.<name of validator>
37 <name> = formencode.validators.<name of validator>
38 <name> must equal form name
38 <name> must equal form name
39 list=[1,2,3,4,5]
39 list=[1,2,3,4,5]
40 for SELECT use formencode.All(OneOf(list), Int())
40 for SELECT use formencode.All(OneOf(list), Int())
41
41
42 """
42 """
43
43
44 import deform
44 import deform
45 import logging
45 import logging
46 import formencode
46 import formencode
47
47
48 from pkg_resources import resource_filename
48 from pkg_resources import resource_filename
49 from formencode import All, Pipe
49 from formencode import All, Pipe
50
50
51 from pyramid.threadlocal import get_current_request
51 from pyramid.threadlocal import get_current_request
52
52
53 from rhodecode import BACKENDS
53 from rhodecode import BACKENDS
54 from rhodecode.lib import helpers
54 from rhodecode.lib import helpers
55 from rhodecode.model import validators as v
55 from rhodecode.model import validators as v
56
56
57 log = logging.getLogger(__name__)
57 log = logging.getLogger(__name__)
58
58
59
59
60 deform_templates = resource_filename('deform', 'templates')
60 deform_templates = resource_filename('deform', 'templates')
61 rhodecode_templates = resource_filename('rhodecode', 'templates/forms')
61 rhodecode_templates = resource_filename('rhodecode', 'templates/forms')
62 search_path = (rhodecode_templates, deform_templates)
62 search_path = (rhodecode_templates, deform_templates)
63
63
64
64
65 class RhodecodeFormZPTRendererFactory(deform.ZPTRendererFactory):
65 class RhodecodeFormZPTRendererFactory(deform.ZPTRendererFactory):
66 """ Subclass of ZPTRendererFactory to add rhodecode context variables """
66 """ Subclass of ZPTRendererFactory to add rhodecode context variables """
67 def __call__(self, template_name, **kw):
67 def __call__(self, template_name, **kw):
68 kw['h'] = helpers
68 kw['h'] = helpers
69 kw['request'] = get_current_request()
69 kw['request'] = get_current_request()
70 return self.load(template_name)(**kw)
70 return self.load(template_name)(**kw)
71
71
72
72
73 form_renderer = RhodecodeFormZPTRendererFactory(search_path)
73 form_renderer = RhodecodeFormZPTRendererFactory(search_path)
74 deform.Form.set_default_renderer(form_renderer)
74 deform.Form.set_default_renderer(form_renderer)
75
75
76
76
77 def LoginForm(localizer):
77 def LoginForm(localizer):
78 _ = localizer
78 _ = localizer
79
79
80 class _LoginForm(formencode.Schema):
80 class _LoginForm(formencode.Schema):
81 allow_extra_fields = True
81 allow_extra_fields = True
82 filter_extra_fields = True
82 filter_extra_fields = True
83 username = v.UnicodeString(
83 username = v.UnicodeString(
84 strip=True,
84 strip=True,
85 min=1,
85 min=1,
86 not_empty=True,
86 not_empty=True,
87 messages={
87 messages={
88 'empty': _(u'Please enter a login'),
88 'empty': _(u'Please enter a login'),
89 'tooShort': _(u'Enter a value %(min)i characters long or more')
89 'tooShort': _(u'Enter a value %(min)i characters long or more')
90 }
90 }
91 )
91 )
92
92
93 password = v.UnicodeString(
93 password = v.UnicodeString(
94 strip=False,
94 strip=False,
95 min=3,
95 min=3,
96 max=72,
96 max=72,
97 not_empty=True,
97 not_empty=True,
98 messages={
98 messages={
99 'empty': _(u'Please enter a password'),
99 'empty': _(u'Please enter a password'),
100 'tooShort': _(u'Enter %(min)i characters or more')}
100 'tooShort': _(u'Enter %(min)i characters or more')}
101 )
101 )
102
102
103 remember = v.StringBoolean(if_missing=False)
103 remember = v.StringBoolean(if_missing=False)
104
104
105 chained_validators = [v.ValidAuth(localizer)]
105 chained_validators = [v.ValidAuth(localizer)]
106 return _LoginForm
106 return _LoginForm
107
107
108
108
109 def UserForm(localizer, edit=False, available_languages=None, old_data=None):
109 def UserForm(localizer, edit=False, available_languages=None, old_data=None):
110 old_data = old_data or {}
110 old_data = old_data or {}
111 available_languages = available_languages or []
111 available_languages = available_languages or []
112 _ = localizer
112 _ = localizer
113
113
114 class _UserForm(formencode.Schema):
114 class _UserForm(formencode.Schema):
115 allow_extra_fields = True
115 allow_extra_fields = True
116 filter_extra_fields = True
116 filter_extra_fields = True
117 username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
117 username = All(v.UnicodeString(strip=True, min=1, not_empty=True),
118 v.ValidUsername(localizer, edit, old_data))
118 v.ValidUsername(localizer, edit, old_data))
119 if edit:
119 if edit:
120 new_password = All(
120 new_password = All(
121 v.ValidPassword(localizer),
121 v.ValidPassword(localizer),
122 v.UnicodeString(strip=False, min=6, max=72, not_empty=False)
122 v.UnicodeString(strip=False, min=6, max=72, not_empty=False)
123 )
123 )
124 password_confirmation = All(
124 password_confirmation = All(
125 v.ValidPassword(localizer),
125 v.ValidPassword(localizer),
126 v.UnicodeString(strip=False, min=6, max=72, not_empty=False),
126 v.UnicodeString(strip=False, min=6, max=72, not_empty=False),
127 )
127 )
128 admin = v.StringBoolean(if_missing=False)
128 admin = v.StringBoolean(if_missing=False)
129 else:
129 else:
130 password = All(
130 password = All(
131 v.ValidPassword(localizer),
131 v.ValidPassword(localizer),
132 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
132 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
133 )
133 )
134 password_confirmation = All(
134 password_confirmation = All(
135 v.ValidPassword(localizer),
135 v.ValidPassword(localizer),
136 v.UnicodeString(strip=False, min=6, max=72, not_empty=False)
136 v.UnicodeString(strip=False, min=6, max=72, not_empty=False)
137 )
137 )
138
138
139 password_change = v.StringBoolean(if_missing=False)
139 password_change = v.StringBoolean(if_missing=False)
140 create_repo_group = v.StringBoolean(if_missing=False)
140 create_repo_group = v.StringBoolean(if_missing=False)
141
141
142 active = v.StringBoolean(if_missing=False)
142 active = v.StringBoolean(if_missing=False)
143 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
143 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
144 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
144 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
145 email = All(v.UniqSystemEmail(localizer, old_data), v.Email(not_empty=True))
145 email = All(v.UniqSystemEmail(localizer, old_data), v.Email(not_empty=True))
146 description = v.UnicodeString(strip=True, min=1, max=250, not_empty=False)
146 description = v.UnicodeString(strip=True, min=1, max=250, not_empty=False,
147 if_missing='')
147 extern_name = v.UnicodeString(strip=True)
148 extern_name = v.UnicodeString(strip=True)
148 extern_type = v.UnicodeString(strip=True)
149 extern_type = v.UnicodeString(strip=True)
149 language = v.OneOf(available_languages, hideList=False,
150 language = v.OneOf(available_languages, hideList=False,
150 testValueList=True, if_missing=None)
151 testValueList=True, if_missing=None)
151 chained_validators = [v.ValidPasswordsMatch(localizer)]
152 chained_validators = [v.ValidPasswordsMatch(localizer)]
152 return _UserForm
153 return _UserForm
153
154
154
155
155 def UserGroupForm(localizer, edit=False, old_data=None, allow_disabled=False):
156 def UserGroupForm(localizer, edit=False, old_data=None, allow_disabled=False):
156 old_data = old_data or {}
157 old_data = old_data or {}
157 _ = localizer
158 _ = localizer
158
159
159 class _UserGroupForm(formencode.Schema):
160 class _UserGroupForm(formencode.Schema):
160 allow_extra_fields = True
161 allow_extra_fields = True
161 filter_extra_fields = True
162 filter_extra_fields = True
162
163
163 users_group_name = All(
164 users_group_name = All(
164 v.UnicodeString(strip=True, min=1, not_empty=True),
165 v.UnicodeString(strip=True, min=1, not_empty=True),
165 v.ValidUserGroup(localizer, edit, old_data)
166 v.ValidUserGroup(localizer, edit, old_data)
166 )
167 )
167 user_group_description = v.UnicodeString(strip=True, min=1,
168 user_group_description = v.UnicodeString(strip=True, min=1,
168 not_empty=False)
169 not_empty=False)
169
170
170 users_group_active = v.StringBoolean(if_missing=False)
171 users_group_active = v.StringBoolean(if_missing=False)
171
172
172 if edit:
173 if edit:
173 # this is user group owner
174 # this is user group owner
174 user = All(
175 user = All(
175 v.UnicodeString(not_empty=True),
176 v.UnicodeString(not_empty=True),
176 v.ValidRepoUser(localizer, allow_disabled))
177 v.ValidRepoUser(localizer, allow_disabled))
177 return _UserGroupForm
178 return _UserGroupForm
178
179
179
180
180 def RepoGroupForm(localizer, edit=False, old_data=None, available_groups=None,
181 def RepoGroupForm(localizer, edit=False, old_data=None, available_groups=None,
181 can_create_in_root=False, allow_disabled=False):
182 can_create_in_root=False, allow_disabled=False):
182 _ = localizer
183 _ = localizer
183 old_data = old_data or {}
184 old_data = old_data or {}
184 available_groups = available_groups or []
185 available_groups = available_groups or []
185
186
186 class _RepoGroupForm(formencode.Schema):
187 class _RepoGroupForm(formencode.Schema):
187 allow_extra_fields = True
188 allow_extra_fields = True
188 filter_extra_fields = False
189 filter_extra_fields = False
189
190
190 group_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
191 group_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
191 v.SlugifyName(localizer),)
192 v.SlugifyName(localizer),)
192 group_description = v.UnicodeString(strip=True, min=1,
193 group_description = v.UnicodeString(strip=True, min=1,
193 not_empty=False)
194 not_empty=False)
194 group_copy_permissions = v.StringBoolean(if_missing=False)
195 group_copy_permissions = v.StringBoolean(if_missing=False)
195
196
196 group_parent_id = v.OneOf(available_groups, hideList=False,
197 group_parent_id = v.OneOf(available_groups, hideList=False,
197 testValueList=True, not_empty=True)
198 testValueList=True, not_empty=True)
198 enable_locking = v.StringBoolean(if_missing=False)
199 enable_locking = v.StringBoolean(if_missing=False)
199 chained_validators = [
200 chained_validators = [
200 v.ValidRepoGroup(localizer, edit, old_data, can_create_in_root)]
201 v.ValidRepoGroup(localizer, edit, old_data, can_create_in_root)]
201
202
202 if edit:
203 if edit:
203 # this is repo group owner
204 # this is repo group owner
204 user = All(
205 user = All(
205 v.UnicodeString(not_empty=True),
206 v.UnicodeString(not_empty=True),
206 v.ValidRepoUser(localizer, allow_disabled))
207 v.ValidRepoUser(localizer, allow_disabled))
207 return _RepoGroupForm
208 return _RepoGroupForm
208
209
209
210
210 def RegisterForm(localizer, edit=False, old_data=None):
211 def RegisterForm(localizer, edit=False, old_data=None):
211 _ = localizer
212 _ = localizer
212 old_data = old_data or {}
213 old_data = old_data or {}
213
214
214 class _RegisterForm(formencode.Schema):
215 class _RegisterForm(formencode.Schema):
215 allow_extra_fields = True
216 allow_extra_fields = True
216 filter_extra_fields = True
217 filter_extra_fields = True
217 username = All(
218 username = All(
218 v.ValidUsername(localizer, edit, old_data),
219 v.ValidUsername(localizer, edit, old_data),
219 v.UnicodeString(strip=True, min=1, not_empty=True)
220 v.UnicodeString(strip=True, min=1, not_empty=True)
220 )
221 )
221 password = All(
222 password = All(
222 v.ValidPassword(localizer),
223 v.ValidPassword(localizer),
223 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
224 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
224 )
225 )
225 password_confirmation = All(
226 password_confirmation = All(
226 v.ValidPassword(localizer),
227 v.ValidPassword(localizer),
227 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
228 v.UnicodeString(strip=False, min=6, max=72, not_empty=True)
228 )
229 )
229 active = v.StringBoolean(if_missing=False)
230 active = v.StringBoolean(if_missing=False)
230 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
231 firstname = v.UnicodeString(strip=True, min=1, not_empty=False)
231 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
232 lastname = v.UnicodeString(strip=True, min=1, not_empty=False)
232 email = All(v.UniqSystemEmail(localizer, old_data), v.Email(not_empty=True))
233 email = All(v.UniqSystemEmail(localizer, old_data), v.Email(not_empty=True))
233
234
234 chained_validators = [v.ValidPasswordsMatch(localizer)]
235 chained_validators = [v.ValidPasswordsMatch(localizer)]
235 return _RegisterForm
236 return _RegisterForm
236
237
237
238
238 def PasswordResetForm(localizer):
239 def PasswordResetForm(localizer):
239 _ = localizer
240 _ = localizer
240
241
241 class _PasswordResetForm(formencode.Schema):
242 class _PasswordResetForm(formencode.Schema):
242 allow_extra_fields = True
243 allow_extra_fields = True
243 filter_extra_fields = True
244 filter_extra_fields = True
244 email = All(v.ValidSystemEmail(localizer), v.Email(not_empty=True))
245 email = All(v.ValidSystemEmail(localizer), v.Email(not_empty=True))
245 return _PasswordResetForm
246 return _PasswordResetForm
246
247
247
248
248 def RepoForm(localizer, edit=False, old_data=None, repo_groups=None, allow_disabled=False):
249 def RepoForm(localizer, edit=False, old_data=None, repo_groups=None, allow_disabled=False):
249 _ = localizer
250 _ = localizer
250 old_data = old_data or {}
251 old_data = old_data or {}
251 repo_groups = repo_groups or []
252 repo_groups = repo_groups or []
252 supported_backends = BACKENDS.keys()
253 supported_backends = BACKENDS.keys()
253
254
254 class _RepoForm(formencode.Schema):
255 class _RepoForm(formencode.Schema):
255 allow_extra_fields = True
256 allow_extra_fields = True
256 filter_extra_fields = False
257 filter_extra_fields = False
257 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
258 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
258 v.SlugifyName(localizer), v.CannotHaveGitSuffix(localizer))
259 v.SlugifyName(localizer), v.CannotHaveGitSuffix(localizer))
259 repo_group = All(v.CanWriteGroup(localizer, old_data),
260 repo_group = All(v.CanWriteGroup(localizer, old_data),
260 v.OneOf(repo_groups, hideList=True))
261 v.OneOf(repo_groups, hideList=True))
261 repo_type = v.OneOf(supported_backends, required=False,
262 repo_type = v.OneOf(supported_backends, required=False,
262 if_missing=old_data.get('repo_type'))
263 if_missing=old_data.get('repo_type'))
263 repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
264 repo_description = v.UnicodeString(strip=True, min=1, not_empty=False)
264 repo_private = v.StringBoolean(if_missing=False)
265 repo_private = v.StringBoolean(if_missing=False)
265 repo_copy_permissions = v.StringBoolean(if_missing=False)
266 repo_copy_permissions = v.StringBoolean(if_missing=False)
266 clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
267 clone_uri = All(v.UnicodeString(strip=True, min=1, not_empty=False))
267
268
268 repo_enable_statistics = v.StringBoolean(if_missing=False)
269 repo_enable_statistics = v.StringBoolean(if_missing=False)
269 repo_enable_downloads = v.StringBoolean(if_missing=False)
270 repo_enable_downloads = v.StringBoolean(if_missing=False)
270 repo_enable_locking = v.StringBoolean(if_missing=False)
271 repo_enable_locking = v.StringBoolean(if_missing=False)
271
272
272 if edit:
273 if edit:
273 # this is repo owner
274 # this is repo owner
274 user = All(
275 user = All(
275 v.UnicodeString(not_empty=True),
276 v.UnicodeString(not_empty=True),
276 v.ValidRepoUser(localizer, allow_disabled))
277 v.ValidRepoUser(localizer, allow_disabled))
277 clone_uri_change = v.UnicodeString(
278 clone_uri_change = v.UnicodeString(
278 not_empty=False, if_missing=v.Missing)
279 not_empty=False, if_missing=v.Missing)
279
280
280 chained_validators = [v.ValidCloneUri(localizer),
281 chained_validators = [v.ValidCloneUri(localizer),
281 v.ValidRepoName(localizer, edit, old_data)]
282 v.ValidRepoName(localizer, edit, old_data)]
282 return _RepoForm
283 return _RepoForm
283
284
284
285
285 def RepoPermsForm(localizer):
286 def RepoPermsForm(localizer):
286 _ = localizer
287 _ = localizer
287
288
288 class _RepoPermsForm(formencode.Schema):
289 class _RepoPermsForm(formencode.Schema):
289 allow_extra_fields = True
290 allow_extra_fields = True
290 filter_extra_fields = False
291 filter_extra_fields = False
291 chained_validators = [v.ValidPerms(localizer, type_='repo')]
292 chained_validators = [v.ValidPerms(localizer, type_='repo')]
292 return _RepoPermsForm
293 return _RepoPermsForm
293
294
294
295
295 def RepoGroupPermsForm(localizer, valid_recursive_choices):
296 def RepoGroupPermsForm(localizer, valid_recursive_choices):
296 _ = localizer
297 _ = localizer
297
298
298 class _RepoGroupPermsForm(formencode.Schema):
299 class _RepoGroupPermsForm(formencode.Schema):
299 allow_extra_fields = True
300 allow_extra_fields = True
300 filter_extra_fields = False
301 filter_extra_fields = False
301 recursive = v.OneOf(valid_recursive_choices)
302 recursive = v.OneOf(valid_recursive_choices)
302 chained_validators = [v.ValidPerms(localizer, type_='repo_group')]
303 chained_validators = [v.ValidPerms(localizer, type_='repo_group')]
303 return _RepoGroupPermsForm
304 return _RepoGroupPermsForm
304
305
305
306
306 def UserGroupPermsForm(localizer):
307 def UserGroupPermsForm(localizer):
307 _ = localizer
308 _ = localizer
308
309
309 class _UserPermsForm(formencode.Schema):
310 class _UserPermsForm(formencode.Schema):
310 allow_extra_fields = True
311 allow_extra_fields = True
311 filter_extra_fields = False
312 filter_extra_fields = False
312 chained_validators = [v.ValidPerms(localizer, type_='user_group')]
313 chained_validators = [v.ValidPerms(localizer, type_='user_group')]
313 return _UserPermsForm
314 return _UserPermsForm
314
315
315
316
316 def RepoFieldForm(localizer):
317 def RepoFieldForm(localizer):
317 _ = localizer
318 _ = localizer
318
319
319 class _RepoFieldForm(formencode.Schema):
320 class _RepoFieldForm(formencode.Schema):
320 filter_extra_fields = True
321 filter_extra_fields = True
321 allow_extra_fields = True
322 allow_extra_fields = True
322
323
323 new_field_key = All(v.FieldKey(localizer),
324 new_field_key = All(v.FieldKey(localizer),
324 v.UnicodeString(strip=True, min=3, not_empty=True))
325 v.UnicodeString(strip=True, min=3, not_empty=True))
325 new_field_value = v.UnicodeString(not_empty=False, if_missing=u'')
326 new_field_value = v.UnicodeString(not_empty=False, if_missing=u'')
326 new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'],
327 new_field_type = v.OneOf(['str', 'unicode', 'list', 'tuple'],
327 if_missing='str')
328 if_missing='str')
328 new_field_label = v.UnicodeString(not_empty=False)
329 new_field_label = v.UnicodeString(not_empty=False)
329 new_field_desc = v.UnicodeString(not_empty=False)
330 new_field_desc = v.UnicodeString(not_empty=False)
330 return _RepoFieldForm
331 return _RepoFieldForm
331
332
332
333
333 def RepoForkForm(localizer, edit=False, old_data=None,
334 def RepoForkForm(localizer, edit=False, old_data=None,
334 supported_backends=BACKENDS.keys(), repo_groups=None):
335 supported_backends=BACKENDS.keys(), repo_groups=None):
335 _ = localizer
336 _ = localizer
336 old_data = old_data or {}
337 old_data = old_data or {}
337 repo_groups = repo_groups or []
338 repo_groups = repo_groups or []
338
339
339 class _RepoForkForm(formencode.Schema):
340 class _RepoForkForm(formencode.Schema):
340 allow_extra_fields = True
341 allow_extra_fields = True
341 filter_extra_fields = False
342 filter_extra_fields = False
342 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
343 repo_name = All(v.UnicodeString(strip=True, min=1, not_empty=True),
343 v.SlugifyName(localizer))
344 v.SlugifyName(localizer))
344 repo_group = All(v.CanWriteGroup(localizer, ),
345 repo_group = All(v.CanWriteGroup(localizer, ),
345 v.OneOf(repo_groups, hideList=True))
346 v.OneOf(repo_groups, hideList=True))
346 repo_type = All(v.ValidForkType(localizer, old_data), v.OneOf(supported_backends))
347 repo_type = All(v.ValidForkType(localizer, old_data), v.OneOf(supported_backends))
347 description = v.UnicodeString(strip=True, min=1, not_empty=True)
348 description = v.UnicodeString(strip=True, min=1, not_empty=True)
348 private = v.StringBoolean(if_missing=False)
349 private = v.StringBoolean(if_missing=False)
349 copy_permissions = v.StringBoolean(if_missing=False)
350 copy_permissions = v.StringBoolean(if_missing=False)
350 fork_parent_id = v.UnicodeString()
351 fork_parent_id = v.UnicodeString()
351 chained_validators = [v.ValidForkName(localizer, edit, old_data)]
352 chained_validators = [v.ValidForkName(localizer, edit, old_data)]
352 return _RepoForkForm
353 return _RepoForkForm
353
354
354
355
355 def ApplicationSettingsForm(localizer):
356 def ApplicationSettingsForm(localizer):
356 _ = localizer
357 _ = localizer
357
358
358 class _ApplicationSettingsForm(formencode.Schema):
359 class _ApplicationSettingsForm(formencode.Schema):
359 allow_extra_fields = True
360 allow_extra_fields = True
360 filter_extra_fields = False
361 filter_extra_fields = False
361 rhodecode_title = v.UnicodeString(strip=True, max=40, not_empty=False)
362 rhodecode_title = v.UnicodeString(strip=True, max=40, not_empty=False)
362 rhodecode_realm = v.UnicodeString(strip=True, min=1, not_empty=True)
363 rhodecode_realm = v.UnicodeString(strip=True, min=1, not_empty=True)
363 rhodecode_pre_code = v.UnicodeString(strip=True, min=1, not_empty=False)
364 rhodecode_pre_code = v.UnicodeString(strip=True, min=1, not_empty=False)
364 rhodecode_post_code = v.UnicodeString(strip=True, min=1, not_empty=False)
365 rhodecode_post_code = v.UnicodeString(strip=True, min=1, not_empty=False)
365 rhodecode_captcha_public_key = v.UnicodeString(strip=True, min=1, not_empty=False)
366 rhodecode_captcha_public_key = v.UnicodeString(strip=True, min=1, not_empty=False)
366 rhodecode_captcha_private_key = v.UnicodeString(strip=True, min=1, not_empty=False)
367 rhodecode_captcha_private_key = v.UnicodeString(strip=True, min=1, not_empty=False)
367 rhodecode_create_personal_repo_group = v.StringBoolean(if_missing=False)
368 rhodecode_create_personal_repo_group = v.StringBoolean(if_missing=False)
368 rhodecode_personal_repo_group_pattern = v.UnicodeString(strip=True, min=1, not_empty=False)
369 rhodecode_personal_repo_group_pattern = v.UnicodeString(strip=True, min=1, not_empty=False)
369 return _ApplicationSettingsForm
370 return _ApplicationSettingsForm
370
371
371
372
372 def ApplicationVisualisationForm(localizer):
373 def ApplicationVisualisationForm(localizer):
373 from rhodecode.model.db import Repository
374 from rhodecode.model.db import Repository
374 _ = localizer
375 _ = localizer
375
376
376 class _ApplicationVisualisationForm(formencode.Schema):
377 class _ApplicationVisualisationForm(formencode.Schema):
377 allow_extra_fields = True
378 allow_extra_fields = True
378 filter_extra_fields = False
379 filter_extra_fields = False
379 rhodecode_show_public_icon = v.StringBoolean(if_missing=False)
380 rhodecode_show_public_icon = v.StringBoolean(if_missing=False)
380 rhodecode_show_private_icon = v.StringBoolean(if_missing=False)
381 rhodecode_show_private_icon = v.StringBoolean(if_missing=False)
381 rhodecode_stylify_metatags = v.StringBoolean(if_missing=False)
382 rhodecode_stylify_metatags = v.StringBoolean(if_missing=False)
382
383
383 rhodecode_repository_fields = v.StringBoolean(if_missing=False)
384 rhodecode_repository_fields = v.StringBoolean(if_missing=False)
384 rhodecode_lightweight_journal = v.StringBoolean(if_missing=False)
385 rhodecode_lightweight_journal = v.StringBoolean(if_missing=False)
385 rhodecode_dashboard_items = v.Int(min=5, not_empty=True)
386 rhodecode_dashboard_items = v.Int(min=5, not_empty=True)
386 rhodecode_admin_grid_items = v.Int(min=5, not_empty=True)
387 rhodecode_admin_grid_items = v.Int(min=5, not_empty=True)
387 rhodecode_show_version = v.StringBoolean(if_missing=False)
388 rhodecode_show_version = v.StringBoolean(if_missing=False)
388 rhodecode_use_gravatar = v.StringBoolean(if_missing=False)
389 rhodecode_use_gravatar = v.StringBoolean(if_missing=False)
389 rhodecode_markup_renderer = v.OneOf(['markdown', 'rst'])
390 rhodecode_markup_renderer = v.OneOf(['markdown', 'rst'])
390 rhodecode_gravatar_url = v.UnicodeString(min=3)
391 rhodecode_gravatar_url = v.UnicodeString(min=3)
391 rhodecode_clone_uri_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI)
392 rhodecode_clone_uri_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI)
392 rhodecode_clone_uri_ssh_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI_SSH)
393 rhodecode_clone_uri_ssh_tmpl = v.UnicodeString(not_empty=False, if_empty=Repository.DEFAULT_CLONE_URI_SSH)
393 rhodecode_support_url = v.UnicodeString()
394 rhodecode_support_url = v.UnicodeString()
394 rhodecode_show_revision_number = v.StringBoolean(if_missing=False)
395 rhodecode_show_revision_number = v.StringBoolean(if_missing=False)
395 rhodecode_show_sha_length = v.Int(min=4, not_empty=True)
396 rhodecode_show_sha_length = v.Int(min=4, not_empty=True)
396 return _ApplicationVisualisationForm
397 return _ApplicationVisualisationForm
397
398
398
399
399 class _BaseVcsSettingsForm(formencode.Schema):
400 class _BaseVcsSettingsForm(formencode.Schema):
400
401
401 allow_extra_fields = True
402 allow_extra_fields = True
402 filter_extra_fields = False
403 filter_extra_fields = False
403 hooks_changegroup_repo_size = v.StringBoolean(if_missing=False)
404 hooks_changegroup_repo_size = v.StringBoolean(if_missing=False)
404 hooks_changegroup_push_logger = v.StringBoolean(if_missing=False)
405 hooks_changegroup_push_logger = v.StringBoolean(if_missing=False)
405 hooks_outgoing_pull_logger = v.StringBoolean(if_missing=False)
406 hooks_outgoing_pull_logger = v.StringBoolean(if_missing=False)
406
407
407 # PR/Code-review
408 # PR/Code-review
408 rhodecode_pr_merge_enabled = v.StringBoolean(if_missing=False)
409 rhodecode_pr_merge_enabled = v.StringBoolean(if_missing=False)
409 rhodecode_use_outdated_comments = v.StringBoolean(if_missing=False)
410 rhodecode_use_outdated_comments = v.StringBoolean(if_missing=False)
410
411
411 # hg
412 # hg
412 extensions_largefiles = v.StringBoolean(if_missing=False)
413 extensions_largefiles = v.StringBoolean(if_missing=False)
413 extensions_evolve = v.StringBoolean(if_missing=False)
414 extensions_evolve = v.StringBoolean(if_missing=False)
414 phases_publish = v.StringBoolean(if_missing=False)
415 phases_publish = v.StringBoolean(if_missing=False)
415
416
416 rhodecode_hg_use_rebase_for_merging = v.StringBoolean(if_missing=False)
417 rhodecode_hg_use_rebase_for_merging = v.StringBoolean(if_missing=False)
417 rhodecode_hg_close_branch_before_merging = v.StringBoolean(if_missing=False)
418 rhodecode_hg_close_branch_before_merging = v.StringBoolean(if_missing=False)
418
419
419 # git
420 # git
420 vcs_git_lfs_enabled = v.StringBoolean(if_missing=False)
421 vcs_git_lfs_enabled = v.StringBoolean(if_missing=False)
421 rhodecode_git_use_rebase_for_merging = v.StringBoolean(if_missing=False)
422 rhodecode_git_use_rebase_for_merging = v.StringBoolean(if_missing=False)
422 rhodecode_git_close_branch_before_merging = v.StringBoolean(if_missing=False)
423 rhodecode_git_close_branch_before_merging = v.StringBoolean(if_missing=False)
423
424
424 # svn
425 # svn
425 vcs_svn_proxy_http_requests_enabled = v.StringBoolean(if_missing=False)
426 vcs_svn_proxy_http_requests_enabled = v.StringBoolean(if_missing=False)
426 vcs_svn_proxy_http_server_url = v.UnicodeString(strip=True, if_missing=None)
427 vcs_svn_proxy_http_server_url = v.UnicodeString(strip=True, if_missing=None)
427
428
428 # cache
429 # cache
429 rhodecode_diff_cache = v.StringBoolean(if_missing=False)
430 rhodecode_diff_cache = v.StringBoolean(if_missing=False)
430
431
431
432
432 def ApplicationUiSettingsForm(localizer):
433 def ApplicationUiSettingsForm(localizer):
433 _ = localizer
434 _ = localizer
434
435
435 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
436 class _ApplicationUiSettingsForm(_BaseVcsSettingsForm):
436 web_push_ssl = v.StringBoolean(if_missing=False)
437 web_push_ssl = v.StringBoolean(if_missing=False)
437 paths_root_path = All(
438 paths_root_path = All(
438 v.ValidPath(localizer),
439 v.ValidPath(localizer),
439 v.UnicodeString(strip=True, min=1, not_empty=True)
440 v.UnicodeString(strip=True, min=1, not_empty=True)
440 )
441 )
441 largefiles_usercache = All(
442 largefiles_usercache = All(
442 v.ValidPath(localizer),
443 v.ValidPath(localizer),
443 v.UnicodeString(strip=True, min=2, not_empty=True))
444 v.UnicodeString(strip=True, min=2, not_empty=True))
444 vcs_git_lfs_store_location = All(
445 vcs_git_lfs_store_location = All(
445 v.ValidPath(localizer),
446 v.ValidPath(localizer),
446 v.UnicodeString(strip=True, min=2, not_empty=True))
447 v.UnicodeString(strip=True, min=2, not_empty=True))
447 extensions_hgsubversion = v.StringBoolean(if_missing=False)
448 extensions_hgsubversion = v.StringBoolean(if_missing=False)
448 extensions_hggit = v.StringBoolean(if_missing=False)
449 extensions_hggit = v.StringBoolean(if_missing=False)
449 new_svn_branch = v.ValidSvnPattern(localizer, section='vcs_svn_branch')
450 new_svn_branch = v.ValidSvnPattern(localizer, section='vcs_svn_branch')
450 new_svn_tag = v.ValidSvnPattern(localizer, section='vcs_svn_tag')
451 new_svn_tag = v.ValidSvnPattern(localizer, section='vcs_svn_tag')
451 return _ApplicationUiSettingsForm
452 return _ApplicationUiSettingsForm
452
453
453
454
454 def RepoVcsSettingsForm(localizer, repo_name):
455 def RepoVcsSettingsForm(localizer, repo_name):
455 _ = localizer
456 _ = localizer
456
457
457 class _RepoVcsSettingsForm(_BaseVcsSettingsForm):
458 class _RepoVcsSettingsForm(_BaseVcsSettingsForm):
458 inherit_global_settings = v.StringBoolean(if_missing=False)
459 inherit_global_settings = v.StringBoolean(if_missing=False)
459 new_svn_branch = v.ValidSvnPattern(localizer,
460 new_svn_branch = v.ValidSvnPattern(localizer,
460 section='vcs_svn_branch', repo_name=repo_name)
461 section='vcs_svn_branch', repo_name=repo_name)
461 new_svn_tag = v.ValidSvnPattern(localizer,
462 new_svn_tag = v.ValidSvnPattern(localizer,
462 section='vcs_svn_tag', repo_name=repo_name)
463 section='vcs_svn_tag', repo_name=repo_name)
463 return _RepoVcsSettingsForm
464 return _RepoVcsSettingsForm
464
465
465
466
466 def LabsSettingsForm(localizer):
467 def LabsSettingsForm(localizer):
467 _ = localizer
468 _ = localizer
468
469
469 class _LabSettingsForm(formencode.Schema):
470 class _LabSettingsForm(formencode.Schema):
470 allow_extra_fields = True
471 allow_extra_fields = True
471 filter_extra_fields = False
472 filter_extra_fields = False
472 return _LabSettingsForm
473 return _LabSettingsForm
473
474
474
475
475 def ApplicationPermissionsForm(
476 def ApplicationPermissionsForm(
476 localizer, register_choices, password_reset_choices,
477 localizer, register_choices, password_reset_choices,
477 extern_activate_choices):
478 extern_activate_choices):
478 _ = localizer
479 _ = localizer
479
480
480 class _DefaultPermissionsForm(formencode.Schema):
481 class _DefaultPermissionsForm(formencode.Schema):
481 allow_extra_fields = True
482 allow_extra_fields = True
482 filter_extra_fields = True
483 filter_extra_fields = True
483
484
484 anonymous = v.StringBoolean(if_missing=False)
485 anonymous = v.StringBoolean(if_missing=False)
485 default_register = v.OneOf(register_choices)
486 default_register = v.OneOf(register_choices)
486 default_register_message = v.UnicodeString()
487 default_register_message = v.UnicodeString()
487 default_password_reset = v.OneOf(password_reset_choices)
488 default_password_reset = v.OneOf(password_reset_choices)
488 default_extern_activate = v.OneOf(extern_activate_choices)
489 default_extern_activate = v.OneOf(extern_activate_choices)
489 return _DefaultPermissionsForm
490 return _DefaultPermissionsForm
490
491
491
492
492 def ObjectPermissionsForm(localizer, repo_perms_choices, group_perms_choices,
493 def ObjectPermissionsForm(localizer, repo_perms_choices, group_perms_choices,
493 user_group_perms_choices):
494 user_group_perms_choices):
494 _ = localizer
495 _ = localizer
495
496
496 class _ObjectPermissionsForm(formencode.Schema):
497 class _ObjectPermissionsForm(formencode.Schema):
497 allow_extra_fields = True
498 allow_extra_fields = True
498 filter_extra_fields = True
499 filter_extra_fields = True
499 overwrite_default_repo = v.StringBoolean(if_missing=False)
500 overwrite_default_repo = v.StringBoolean(if_missing=False)
500 overwrite_default_group = v.StringBoolean(if_missing=False)
501 overwrite_default_group = v.StringBoolean(if_missing=False)
501 overwrite_default_user_group = v.StringBoolean(if_missing=False)
502 overwrite_default_user_group = v.StringBoolean(if_missing=False)
502
503
503 default_repo_perm = v.OneOf(repo_perms_choices)
504 default_repo_perm = v.OneOf(repo_perms_choices)
504 default_group_perm = v.OneOf(group_perms_choices)
505 default_group_perm = v.OneOf(group_perms_choices)
505 default_user_group_perm = v.OneOf(user_group_perms_choices)
506 default_user_group_perm = v.OneOf(user_group_perms_choices)
506
507
507 return _ObjectPermissionsForm
508 return _ObjectPermissionsForm
508
509
509
510
510 def BranchPermissionsForm(localizer, branch_perms_choices):
511 def BranchPermissionsForm(localizer, branch_perms_choices):
511 _ = localizer
512 _ = localizer
512
513
513 class _BranchPermissionsForm(formencode.Schema):
514 class _BranchPermissionsForm(formencode.Schema):
514 allow_extra_fields = True
515 allow_extra_fields = True
515 filter_extra_fields = True
516 filter_extra_fields = True
516 overwrite_default_branch = v.StringBoolean(if_missing=False)
517 overwrite_default_branch = v.StringBoolean(if_missing=False)
517 default_branch_perm = v.OneOf(branch_perms_choices)
518 default_branch_perm = v.OneOf(branch_perms_choices)
518
519
519 return _BranchPermissionsForm
520 return _BranchPermissionsForm
520
521
521
522
522 def UserPermissionsForm(localizer, create_choices, create_on_write_choices,
523 def UserPermissionsForm(localizer, create_choices, create_on_write_choices,
523 repo_group_create_choices, user_group_create_choices,
524 repo_group_create_choices, user_group_create_choices,
524 fork_choices, inherit_default_permissions_choices):
525 fork_choices, inherit_default_permissions_choices):
525 _ = localizer
526 _ = localizer
526
527
527 class _DefaultPermissionsForm(formencode.Schema):
528 class _DefaultPermissionsForm(formencode.Schema):
528 allow_extra_fields = True
529 allow_extra_fields = True
529 filter_extra_fields = True
530 filter_extra_fields = True
530
531
531 anonymous = v.StringBoolean(if_missing=False)
532 anonymous = v.StringBoolean(if_missing=False)
532
533
533 default_repo_create = v.OneOf(create_choices)
534 default_repo_create = v.OneOf(create_choices)
534 default_repo_create_on_write = v.OneOf(create_on_write_choices)
535 default_repo_create_on_write = v.OneOf(create_on_write_choices)
535 default_user_group_create = v.OneOf(user_group_create_choices)
536 default_user_group_create = v.OneOf(user_group_create_choices)
536 default_repo_group_create = v.OneOf(repo_group_create_choices)
537 default_repo_group_create = v.OneOf(repo_group_create_choices)
537 default_fork_create = v.OneOf(fork_choices)
538 default_fork_create = v.OneOf(fork_choices)
538 default_inherit_default_permissions = v.OneOf(inherit_default_permissions_choices)
539 default_inherit_default_permissions = v.OneOf(inherit_default_permissions_choices)
539 return _DefaultPermissionsForm
540 return _DefaultPermissionsForm
540
541
541
542
542 def UserIndividualPermissionsForm(localizer):
543 def UserIndividualPermissionsForm(localizer):
543 _ = localizer
544 _ = localizer
544
545
545 class _DefaultPermissionsForm(formencode.Schema):
546 class _DefaultPermissionsForm(formencode.Schema):
546 allow_extra_fields = True
547 allow_extra_fields = True
547 filter_extra_fields = True
548 filter_extra_fields = True
548
549
549 inherit_default_permissions = v.StringBoolean(if_missing=False)
550 inherit_default_permissions = v.StringBoolean(if_missing=False)
550 return _DefaultPermissionsForm
551 return _DefaultPermissionsForm
551
552
552
553
553 def DefaultsForm(localizer, edit=False, old_data=None, supported_backends=BACKENDS.keys()):
554 def DefaultsForm(localizer, edit=False, old_data=None, supported_backends=BACKENDS.keys()):
554 _ = localizer
555 _ = localizer
555 old_data = old_data or {}
556 old_data = old_data or {}
556
557
557 class _DefaultsForm(formencode.Schema):
558 class _DefaultsForm(formencode.Schema):
558 allow_extra_fields = True
559 allow_extra_fields = True
559 filter_extra_fields = True
560 filter_extra_fields = True
560 default_repo_type = v.OneOf(supported_backends)
561 default_repo_type = v.OneOf(supported_backends)
561 default_repo_private = v.StringBoolean(if_missing=False)
562 default_repo_private = v.StringBoolean(if_missing=False)
562 default_repo_enable_statistics = v.StringBoolean(if_missing=False)
563 default_repo_enable_statistics = v.StringBoolean(if_missing=False)
563 default_repo_enable_downloads = v.StringBoolean(if_missing=False)
564 default_repo_enable_downloads = v.StringBoolean(if_missing=False)
564 default_repo_enable_locking = v.StringBoolean(if_missing=False)
565 default_repo_enable_locking = v.StringBoolean(if_missing=False)
565 return _DefaultsForm
566 return _DefaultsForm
566
567
567
568
568 def AuthSettingsForm(localizer):
569 def AuthSettingsForm(localizer):
569 _ = localizer
570 _ = localizer
570
571
571 class _AuthSettingsForm(formencode.Schema):
572 class _AuthSettingsForm(formencode.Schema):
572 allow_extra_fields = True
573 allow_extra_fields = True
573 filter_extra_fields = True
574 filter_extra_fields = True
574 auth_plugins = All(v.ValidAuthPlugins(localizer),
575 auth_plugins = All(v.ValidAuthPlugins(localizer),
575 v.UniqueListFromString(localizer)(not_empty=True))
576 v.UniqueListFromString(localizer)(not_empty=True))
576 return _AuthSettingsForm
577 return _AuthSettingsForm
577
578
578
579
579 def UserExtraEmailForm(localizer):
580 def UserExtraEmailForm(localizer):
580 _ = localizer
581 _ = localizer
581
582
582 class _UserExtraEmailForm(formencode.Schema):
583 class _UserExtraEmailForm(formencode.Schema):
583 email = All(v.UniqSystemEmail(localizer), v.Email(not_empty=True))
584 email = All(v.UniqSystemEmail(localizer), v.Email(not_empty=True))
584 return _UserExtraEmailForm
585 return _UserExtraEmailForm
585
586
586
587
587 def UserExtraIpForm(localizer):
588 def UserExtraIpForm(localizer):
588 _ = localizer
589 _ = localizer
589
590
590 class _UserExtraIpForm(formencode.Schema):
591 class _UserExtraIpForm(formencode.Schema):
591 ip = v.ValidIp(localizer)(not_empty=True)
592 ip = v.ValidIp(localizer)(not_empty=True)
592 return _UserExtraIpForm
593 return _UserExtraIpForm
593
594
594
595
595 def PullRequestForm(localizer, repo_id):
596 def PullRequestForm(localizer, repo_id):
596 _ = localizer
597 _ = localizer
597
598
598 class ReviewerForm(formencode.Schema):
599 class ReviewerForm(formencode.Schema):
599 user_id = v.Int(not_empty=True)
600 user_id = v.Int(not_empty=True)
600 reasons = All()
601 reasons = All()
601 rules = All(v.UniqueList(localizer, convert=int)())
602 rules = All(v.UniqueList(localizer, convert=int)())
602 mandatory = v.StringBoolean()
603 mandatory = v.StringBoolean()
603
604
604 class _PullRequestForm(formencode.Schema):
605 class _PullRequestForm(formencode.Schema):
605 allow_extra_fields = True
606 allow_extra_fields = True
606 filter_extra_fields = True
607 filter_extra_fields = True
607
608
608 common_ancestor = v.UnicodeString(strip=True, required=True)
609 common_ancestor = v.UnicodeString(strip=True, required=True)
609 source_repo = v.UnicodeString(strip=True, required=True)
610 source_repo = v.UnicodeString(strip=True, required=True)
610 source_ref = v.UnicodeString(strip=True, required=True)
611 source_ref = v.UnicodeString(strip=True, required=True)
611 target_repo = v.UnicodeString(strip=True, required=True)
612 target_repo = v.UnicodeString(strip=True, required=True)
612 target_ref = v.UnicodeString(strip=True, required=True)
613 target_ref = v.UnicodeString(strip=True, required=True)
613 revisions = All(#v.NotReviewedRevisions(localizer, repo_id)(),
614 revisions = All(#v.NotReviewedRevisions(localizer, repo_id)(),
614 v.UniqueList(localizer)(not_empty=True))
615 v.UniqueList(localizer)(not_empty=True))
615 review_members = formencode.ForEach(ReviewerForm())
616 review_members = formencode.ForEach(ReviewerForm())
616 pullrequest_title = v.UnicodeString(strip=True, required=True, min=1, max=255)
617 pullrequest_title = v.UnicodeString(strip=True, required=True, min=1, max=255)
617 pullrequest_desc = v.UnicodeString(strip=True, required=False)
618 pullrequest_desc = v.UnicodeString(strip=True, required=False)
618 description_renderer = v.UnicodeString(strip=True, required=False)
619 description_renderer = v.UnicodeString(strip=True, required=False)
619
620
620 return _PullRequestForm
621 return _PullRequestForm
621
622
622
623
623 def IssueTrackerPatternsForm(localizer):
624 def IssueTrackerPatternsForm(localizer):
624 _ = localizer
625 _ = localizer
625
626
626 class _IssueTrackerPatternsForm(formencode.Schema):
627 class _IssueTrackerPatternsForm(formencode.Schema):
627 allow_extra_fields = True
628 allow_extra_fields = True
628 filter_extra_fields = False
629 filter_extra_fields = False
629 chained_validators = [v.ValidPattern(localizer)]
630 chained_validators = [v.ValidPattern(localizer)]
630 return _IssueTrackerPatternsForm
631 return _IssueTrackerPatternsForm
@@ -1,147 +1,147 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="/base/base.mako"/>
2 <%inherit file="/base/base.mako"/>
3
3
4 <%def name="title()">
4 <%def name="title()">
5 ${_('Add user')}
5 ${_('Add user')}
6 %if c.rhodecode_name:
6 %if c.rhodecode_name:
7 &middot; ${h.branding(c.rhodecode_name)}
7 &middot; ${h.branding(c.rhodecode_name)}
8 %endif
8 %endif
9 </%def>
9 </%def>
10 <%def name="breadcrumbs_links()">
10 <%def name="breadcrumbs_links()">
11 ${h.link_to(_('Admin'),h.route_path('admin_home'))}
11 ${h.link_to(_('Admin'),h.route_path('admin_home'))}
12 &raquo;
12 &raquo;
13 ${h.link_to(_('Users'),h.route_path('users'))}
13 ${h.link_to(_('Users'),h.route_path('users'))}
14 &raquo;
14 &raquo;
15 ${_('Add User')}
15 ${_('Add User')}
16 </%def>
16 </%def>
17
17
18 <%def name="menu_bar_nav()">
18 <%def name="menu_bar_nav()">
19 ${self.menu_items(active='admin')}
19 ${self.menu_items(active='admin')}
20 </%def>
20 </%def>
21
21
22 <%def name="main()">
22 <%def name="main()">
23 <div class="box">
23 <div class="box">
24 <!-- box / title -->
24 <!-- box / title -->
25 <div class="title">
25 <div class="title">
26 ${self.breadcrumbs()}
26 ${self.breadcrumbs()}
27 </div>
27 </div>
28 <!-- end box / title -->
28 <!-- end box / title -->
29 ${h.secure_form(h.route_path('users_create'), request=request)}
29 ${h.secure_form(h.route_path('users_create'), request=request)}
30 <div class="form">
30 <div class="form">
31 <!-- fields -->
31 <!-- fields -->
32 <div class="fields">
32 <div class="fields">
33 <div class="field">
33 <div class="field">
34 <div class="label">
34 <div class="label">
35 <label for="username">${_('Username')}:</label>
35 <label for="username">${_('Username')}:</label>
36 </div>
36 </div>
37 <div class="input">
37 <div class="input">
38 ${h.text('username', class_='medium')}
38 ${h.text('username', class_='medium')}
39 </div>
39 </div>
40 </div>
40 </div>
41
41
42 <div class="field">
42 <div class="field">
43 <div class="label">
43 <div class="label">
44 <label for="password">${_('Password')}:</label>
44 <label for="password">${_('Password')}:</label>
45 </div>
45 </div>
46 <div class="input">
46 <div class="input">
47 ${h.password('password', class_='medium')}
47 ${h.password('password', class_='medium')}
48 </div>
48 </div>
49 </div>
49 </div>
50
50
51 <div class="field">
51 <div class="field">
52 <div class="label">
52 <div class="label">
53 <label for="password_confirmation">${_('Password confirmation')}:</label>
53 <label for="password_confirmation">${_('Password confirmation')}:</label>
54 </div>
54 </div>
55 <div class="input">
55 <div class="input">
56 ${h.password('password_confirmation',autocomplete="off", class_='medium')}
56 ${h.password('password_confirmation',autocomplete="off", class_='medium')}
57 <div class="info-block">
57 <div class="info-block">
58 <a id="generate_password" href="#">
58 <a id="generate_password" href="#">
59 <i class="icon-lock"></i> ${_('Generate password')}
59 <i class="icon-lock"></i> ${_('Generate password')}
60 </a>
60 </a>
61 <span id="generate_password_preview"></span>
61 <span id="generate_password_preview"></span>
62 </div>
62 </div>
63 </div>
63 </div>
64 </div>
64 </div>
65
65
66 <div class="field">
66 <div class="field">
67 <div class="label">
67 <div class="label">
68 <label for="firstname">${_('First Name')}:</label>
68 <label for="firstname">${_('First Name')}:</label>
69 </div>
69 </div>
70 <div class="input">
70 <div class="input">
71 ${h.text('firstname', class_='medium')}
71 ${h.text('firstname', class_='medium')}
72 </div>
72 </div>
73 </div>
73 </div>
74
74
75 <div class="field">
75 <div class="field">
76 <div class="label">
76 <div class="label">
77 <label for="lastname">${_('Last Name')}:</label>
77 <label for="lastname">${_('Last Name')}:</label>
78 </div>
78 </div>
79 <div class="input">
79 <div class="input">
80 ${h.text('lastname', class_='medium')}
80 ${h.text('lastname', class_='medium')}
81 </div>
81 </div>
82 </div>
82 </div>
83
83
84 <div class="field">
84 <div class="field">
85 <div class="label">
85 <div class="label">
86 <label for="email">${_('Email')}:</label>
86 <label for="email">${_('Email')}:</label>
87 </div>
87 </div>
88 <div class="input">
88 <div class="input">
89 ${h.text('email', class_='medium')}
89 ${h.text('email', class_='medium')}
90 ${h.hidden('extern_name', c.default_extern_type)}
90 ${h.hidden('extern_name', c.default_extern_type)}
91 ${h.hidden('extern_type', c.default_extern_type)}
91 ${h.hidden('extern_type', c.default_extern_type)}
92 </div>
92 </div>
93 </div>
93 </div>
94
94
95 <div class="field">
95 <div class="field">
96 <div class="label label-checkbox">
96 <div class="label label-checkbox">
97 <label for="active">${_('Active')}:</label>
97 <label for="active">${_('Active')}:</label>
98 </div>
98 </div>
99 <div class="checkboxes">
99 <div class="checkboxes">
100 ${h.checkbox('active',value=True,checked='checked')}
100 ${h.checkbox('active',value=True,checked='checked')}
101 </div>
101 </div>
102 </div>
102 </div>
103
103
104 <div class="field">
104 <div class="field">
105 <div class="label label-checkbox">
105 <div class="label label-checkbox">
106 <label for="password_change">${_('Password change')}:</label>
106 <label for="password_change">${_('Password change')}:</label>
107 </div>
107 </div>
108 <div class="checkboxes">
108 <div class="checkboxes">
109 ${h.checkbox('password_change',value=True)}
109 ${h.checkbox('password_change',value=True)}
110 <span class="help-block">${_('Force user to change his password on the next login')}</span>
110 <span class="help-block">${_('Force user to change his password on the next login')}</span>
111 </div>
111 </div>
112 </div>
112 </div>
113
113
114 <div class="field">
114 <div class="field">
115 <div class="label label-checkbox">
115 <div class="label label-checkbox">
116 <label for="create_repo_group">${_('Add personal repository group')}:</label>
116 <label for="create_repo_group">${_('Add personal repository group')}:</label>
117 </div>
117 </div>
118 <div class="checkboxes">
118 <div class="checkboxes">
119 ${h.checkbox('create_repo_group',value=True, checked=c.default_create_repo_group)}
119 ${h.checkbox('create_repo_group',value=True, checked=c.default_create_repo_group)}
120 <span class="help-block">
120 <span class="help-block">
121 ${_('New group will be created at: `/%(path)s`') % {'path': c.personal_repo_group_name}}<br/>
121 ${_('New group will be created at: `/{path}`').format(path=c.personal_repo_group_name)}<br/>
122 ${_('User will be automatically set as this group owner.')}
122 ${_('User will be automatically set as this group owner.')}
123 </span>
123 </span>
124 </div>
124 </div>
125 </div>
125 </div>
126
126
127 <div class="buttons">
127 <div class="buttons">
128 ${h.submit('save',_('Save'),class_="btn")}
128 ${h.submit('save',_('Save'),class_="btn")}
129 </div>
129 </div>
130 </div>
130 </div>
131 </div>
131 </div>
132 ${h.end_form()}
132 ${h.end_form()}
133 </div>
133 </div>
134 <script>
134 <script>
135 $(document).ready(function(){
135 $(document).ready(function(){
136 $('#username').focus();
136 $('#username').focus();
137
137
138 $('#generate_password').on('click', function(e){
138 $('#generate_password').on('click', function(e){
139 var tmpl = "(${_('generated password:')} {0})";
139 var tmpl = "(${_('generated password:')} {0})";
140 var new_passwd = generatePassword(12);
140 var new_passwd = generatePassword(12);
141 $('#generate_password_preview').html(tmpl.format(new_passwd));
141 $('#generate_password_preview').html(tmpl.format(new_passwd));
142 $('#password').val(new_passwd);
142 $('#password').val(new_passwd);
143 $('#password_confirmation').val(new_passwd);
143 $('#password_confirmation').val(new_passwd);
144 })
144 })
145 })
145 })
146 </script>
146 </script>
147 </%def>
147 </%def>
General Comments 0
You need to be logged in to leave comments. Login now