Show More
@@ -19,8 +19,10 b'' | |||
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import colander |
|
22 | import deform.widget | |
|
22 | 23 | |
|
23 | 24 | from rhodecode.translation import _ |
|
25 | from rhodecode.model.validation_schema.utils import convert_to_optgroup | |
|
24 | 26 | from rhodecode.model.validation_schema import validators, preparers, types |
|
25 | 27 | |
|
26 | 28 | DEFAULT_LANDING_REF = 'rev:tip' |
@@ -32,6 +34,11 b' def get_group_and_repo(repo_name):' | |||
|
32 | 34 | repo_name, get_object=True) |
|
33 | 35 | |
|
34 | 36 | |
|
37 | def get_repo_group(repo_group_id): | |
|
38 | from rhodecode.model.repo_group import RepoGroup | |
|
39 | return RepoGroup.get(repo_group_id), RepoGroup.CHOICES_SEPARATOR | |
|
40 | ||
|
41 | ||
|
35 | 42 | @colander.deferred |
|
36 | 43 | def deferred_repo_type_validator(node, kw): |
|
37 | 44 | options = kw.get('repo_type_options', []) |
@@ -53,11 +60,20 b' def deferred_repo_owner_validator(node, ' | |||
|
53 | 60 | |
|
54 | 61 | @colander.deferred |
|
55 | 62 | def deferred_landing_ref_validator(node, kw): |
|
56 | options = kw.get('repo_ref_options', [DEFAULT_LANDING_REF]) | |
|
63 | options = kw.get( | |
|
64 | 'repo_ref_options', [DEFAULT_LANDING_REF]) | |
|
57 | 65 | return colander.OneOf([x for x in options]) |
|
58 | 66 | |
|
59 | 67 | |
|
60 | 68 | @colander.deferred |
|
69 | def deferred_landing_ref_widget(node, kw): | |
|
70 | items = kw.get( | |
|
71 | 'repo_ref_items', [(DEFAULT_LANDING_REF, DEFAULT_LANDING_REF)]) | |
|
72 | items = convert_to_optgroup(items) | |
|
73 | return deform.widget.Select2Widget(values=items) | |
|
74 | ||
|
75 | ||
|
76 | @colander.deferred | |
|
61 | 77 | def deferred_fork_of_validator(node, kw): |
|
62 | 78 | old_values = kw.get('old_values') or {} |
|
63 | 79 | |
@@ -199,6 +215,19 b' def deferred_repo_name_validator(node, k' | |||
|
199 | 215 | no_git_suffix_validator, validators.valid_name_validator) |
|
200 | 216 | |
|
201 | 217 | |
|
218 | @colander.deferred | |
|
219 | def deferred_repo_group_validator(node, kw): | |
|
220 | options = kw.get( | |
|
221 | 'repo_repo_group_options') | |
|
222 | return colander.OneOf([x for x in options]) | |
|
223 | ||
|
224 | ||
|
225 | @colander.deferred | |
|
226 | def deferred_repo_group_widget(node, kw): | |
|
227 | items = kw.get('repo_repo_group_items') | |
|
228 | return deform.widget.Select2Widget(values=items) | |
|
229 | ||
|
230 | ||
|
202 | 231 | class GroupType(colander.Mapping): |
|
203 | 232 | def _validate(self, node, value): |
|
204 | 233 | try: |
@@ -220,8 +249,10 b' class GroupType(colander.Mapping):' | |||
|
220 | 249 | parent_group_name, |
|
221 | 250 | parent_group) = get_group_and_repo(validated_name) |
|
222 | 251 | |
|
252 | appstruct['repo_name_with_group'] = validated_name | |
|
223 | 253 | appstruct['repo_name_without_group'] = repo_name_without_group |
|
224 | 254 | appstruct['repo_group_name'] = parent_group_name or types.RootLocation |
|
255 | ||
|
225 | 256 | if parent_group: |
|
226 | 257 | appstruct['repo_group_id'] = parent_group.group_id |
|
227 | 258 | |
@@ -265,16 +296,19 b' class RepoSchema(colander.MappingSchema)' | |||
|
265 | 296 | |
|
266 | 297 | repo_owner = colander.SchemaNode( |
|
267 | 298 | colander.String(), |
|
268 |
validator=deferred_repo_owner_validator |
|
|
299 | validator=deferred_repo_owner_validator, | |
|
300 | widget=deform.widget.TextInputWidget()) | |
|
269 | 301 | |
|
270 | 302 | repo_description = colander.SchemaNode( |
|
271 |
colander.String(), missing='' |
|
|
303 | colander.String(), missing='', | |
|
304 | widget=deform.widget.TextAreaWidget()) | |
|
272 | 305 | |
|
273 | 306 | repo_landing_commit_ref = colander.SchemaNode( |
|
274 | 307 | colander.String(), |
|
275 | 308 | validator=deferred_landing_ref_validator, |
|
276 | 309 | preparers=[preparers.strip_preparer], |
|
277 |
missing=DEFAULT_LANDING_REF |
|
|
310 | missing=DEFAULT_LANDING_REF, | |
|
311 | widget=deferred_landing_ref_widget) | |
|
278 | 312 | |
|
279 | 313 | repo_clone_uri = colander.SchemaNode( |
|
280 | 314 | colander.String(), |
@@ -289,19 +323,19 b' class RepoSchema(colander.MappingSchema)' | |||
|
289 | 323 | |
|
290 | 324 | repo_private = colander.SchemaNode( |
|
291 | 325 | types.StringBooleanType(), |
|
292 | missing=False) | |
|
326 | missing=False, widget=deform.widget.CheckboxWidget()) | |
|
293 | 327 | repo_copy_permissions = colander.SchemaNode( |
|
294 | 328 | types.StringBooleanType(), |
|
295 | missing=False) | |
|
329 | missing=False, widget=deform.widget.CheckboxWidget()) | |
|
296 | 330 | repo_enable_statistics = colander.SchemaNode( |
|
297 | 331 | types.StringBooleanType(), |
|
298 | missing=False) | |
|
332 | missing=False, widget=deform.widget.CheckboxWidget()) | |
|
299 | 333 | repo_enable_downloads = colander.SchemaNode( |
|
300 | 334 | types.StringBooleanType(), |
|
301 | missing=False) | |
|
335 | missing=False, widget=deform.widget.CheckboxWidget()) | |
|
302 | 336 | repo_enable_locking = colander.SchemaNode( |
|
303 | 337 | types.StringBooleanType(), |
|
304 | missing=False) | |
|
338 | missing=False, widget=deform.widget.CheckboxWidget()) | |
|
305 | 339 | |
|
306 | 340 | def deserialize(self, cstruct): |
|
307 | 341 | """ |
General Comments 0
You need to be logged in to leave comments.
Login now