Mercurial > kallithea
annotate rhodecode/model/validators.py @ 2897:1f7b8c73c94a
Merge with beta
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 08 Oct 2012 22:37:09 +0200 |
parents | eb180eb16c18 |
children | 4cc9bb83ecb4 |
rev | line source |
---|---|
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 """ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 Set of generic validators |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 """ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 import os |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 import re |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 import formencode |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 import logging |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
8 from collections import defaultdict |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 from pylons.i18n.translation import _ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 from webhelpers.pylonslib.secure_form import authentication_token |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 from formencode.validators import ( |
2711
1de45f582f9d
added more validations when opening pull request
Marcin Kuzminski <marcin@python-works.com>
parents:
2706
diff
changeset
|
13 UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set, |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
14 NotEmpty |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 ) |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
16 from rhodecode.lib.compat import OrderedSet |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 from rhodecode.lib.utils import repo_name_slug |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
18 from rhodecode.model.db import RepoGroup, Repository, UsersGroup, User,\ |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
19 ChangesetStatus |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 from rhodecode.lib.exceptions import LdapImportError |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 from rhodecode.config.routing import ADMIN_PREFIX |
2835
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
22 from rhodecode.lib.auth import HasReposGroupPermissionAny |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
23 |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # silence warnings and pylint |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
25 UnicodeString, OneOf, Int, Number, Regex, Email, Bool, StringBoolean, Set, \ |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
26 NotEmpty |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 log = logging.getLogger(__name__) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
31 class UniqueList(formencode.FancyValidator): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
32 """ |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
33 Unique List ! |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
34 """ |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
35 messages = dict( |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
36 empty=_('Value cannot be an empty list'), |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
37 missing_value=_('Value cannot be an empty list'), |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
38 ) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
39 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
40 def _to_python(self, value, state): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
41 if isinstance(value, list): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
42 return value |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
43 elif isinstance(value, set): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
44 return list(value) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
45 elif isinstance(value, tuple): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
46 return list(value) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
47 elif value is None: |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
48 return [] |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
49 else: |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
50 return [value] |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
51 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
52 def empty_value(self, value): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
53 return [] |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
54 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
55 |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 class StateObj(object): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 """ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 this is needed to translate the messages using _() in validators |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 """ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 _ = staticmethod(_) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 def M(self, key, state=None, **kwargs): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 """ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 returns string from self.message based on given key, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 passed kw params are used to substitute %(named)s params inside |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 translated strings |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 :param msg: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 :param state: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 """ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 if state is None: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 state = StateObj() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 else: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 state._ = staticmethod(_) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 #inject validator into state object |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 return self.message(key, state, **kwargs) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 def ValidUsername(edit=False, old_data={}): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 'username_exists': _(u'Username "%(username)s" already exists'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 'system_invalid_username': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 _(u'Username "%(username)s" is forbidden'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 'invalid_username': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 _(u'Username may only contain alphanumeric characters ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
88 'underscores, periods or dashes and must begin with ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 'alphanumeric character') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
92 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
93 if value in ['default', 'new_user']: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
94 msg = M(self, 'system_invalid_username', state, username=value) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 raise formencode.Invalid(msg, value, state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
96 #check if user is unique |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 old_un = None |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 if edit: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 old_un = User.get(old_data.get('user_id')).username |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 if old_un != value or not edit: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 if User.get_by_username(value, case_insensitive=True): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 msg = M(self, 'username_exists', state, username=value) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 raise formencode.Invalid(msg, value, state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
106 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 msg = M(self, 'invalid_username', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
108 raise formencode.Invalid(msg, value, state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 def ValidRepoUser(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
115 'invalid_username': _(u'Username %(username)s is not valid') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
119 try: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 User.query().filter(User.active == True)\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 .filter(User.username == value).one() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 except Exception: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
123 msg = M(self, 'invalid_username', state, username=value) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
125 error_dict=dict(username=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
126 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
127 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 def ValidUsersGroup(edit=False, old_data={}): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
132 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
134 'invalid_group': _(u'Invalid users group name'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 'group_exist': _(u'Users group "%(usersgroup)s" already exists'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 'invalid_usersgroup_name': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 _(u'users group name may only contain alphanumeric ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 'characters underscores, periods or dashes and must begin ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 'with alphanumeric character') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
142 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 if value in ['default']: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 msg = M(self, 'invalid_group', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 error_dict=dict(users_group_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 #check if group is unique |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 old_ugname = None |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 if edit: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
151 old_id = old_data.get('users_group_id') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
152 old_ugname = UsersGroup.get(old_id).users_group_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
153 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
154 if old_ugname != value or not edit: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
155 is_existing_group = UsersGroup.get_by_group_name(value, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
156 case_insensitive=True) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
157 if is_existing_group: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
158 msg = M(self, 'group_exist', state, usersgroup=value) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
159 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 error_dict=dict(users_group_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
161 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
162 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
163 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
164 msg = M(self, 'invalid_usersgroup_name', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
165 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
166 error_dict=dict(users_group_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
167 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
168 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
169 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
170 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
171 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
172 def ValidReposGroup(edit=False, old_data={}): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
173 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
175 'group_parent_id': _(u'Cannot assign this group as parent'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
176 'group_exists': _(u'Group "%(group_name)s" already exists'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 'repo_exists': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
178 _(u'Repository with name "%(group_name)s" already exists') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
179 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
180 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
181 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
182 # TODO WRITE VALIDATIONS |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
183 group_name = value.get('group_name') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
184 group_parent_id = value.get('group_parent_id') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
185 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
186 # slugify repo group just in case :) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
187 slug = repo_name_slug(group_name) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
188 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
189 # check for parent of self |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
190 parent_of_self = lambda: ( |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
191 old_data['group_id'] == int(group_parent_id) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
192 if group_parent_id else False |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
193 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
194 if edit and parent_of_self(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
195 msg = M(self, 'group_parent_id', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
196 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
197 error_dict=dict(group_parent_id=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
198 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
199 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
200 old_gname = None |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
201 if edit: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
202 old_gname = RepoGroup.get(old_data.get('group_id')).group_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
203 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
204 if old_gname != group_name or not edit: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
205 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
206 # check group |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
207 gr = RepoGroup.query()\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
208 .filter(RepoGroup.group_name == slug)\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
209 .filter(RepoGroup.group_parent_id == group_parent_id)\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
210 .scalar() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
211 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
212 if gr: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
213 msg = M(self, 'group_exists', state, group_name=slug) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
214 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
215 error_dict=dict(group_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
216 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
217 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
218 # check for same repo |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
219 repo = Repository.query()\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
220 .filter(Repository.repo_name == slug)\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
221 .scalar() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
222 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
223 if repo: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
224 msg = M(self, 'repo_exists', state, group_name=slug) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
225 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
226 error_dict=dict(group_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
227 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
228 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
229 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
230 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
231 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
232 def ValidPassword(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
233 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
234 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
235 'invalid_password': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
236 _(u'Invalid characters (non-ascii) in password') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
237 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
238 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
239 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
240 try: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
241 (value or '').decode('ascii') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
242 except UnicodeError: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
243 msg = M(self, 'invalid_password', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
244 raise formencode.Invalid(msg, value, state,) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
245 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
246 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
247 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
248 def ValidPasswordsMatch(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
249 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
250 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
251 'password_mismatch': _(u'Passwords do not match'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
252 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
253 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
254 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
255 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
256 pass_val = value.get('password') or value.get('new_password') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
257 if pass_val != value['password_confirmation']: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
258 msg = M(self, 'password_mismatch', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
259 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
260 error_dict=dict(password_confirmation=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
261 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
262 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
263 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
264 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
265 def ValidAuth(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
266 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
267 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
268 'invalid_password': _(u'invalid password'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
269 'invalid_username': _(u'invalid user name'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
270 'disabled_account': _(u'Your account is disabled') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
271 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
272 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
273 def validate_python(self, value, state): |
2479
9225597688f4
Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
274 from rhodecode.lib.auth import authenticate |
9225597688f4
Added validation into user email map
Marcin Kuzminski <marcin@python-works.com>
parents:
2466
diff
changeset
|
275 |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
276 password = value['password'] |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
277 username = value['username'] |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
278 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
279 if not authenticate(username, password): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
280 user = User.get_by_username(username) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
281 if user and user.active is False: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
282 log.warning('user %s is disabled' % username) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
283 msg = M(self, 'disabled_account', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
284 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
285 error_dict=dict(username=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
286 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
287 else: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
288 log.warning('user %s failed to authenticate' % username) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
289 msg = M(self, 'invalid_username', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
290 msg2 = M(self, 'invalid_password', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
291 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
292 error_dict=dict(username=msg, password=msg2) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
293 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
294 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
295 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
296 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
297 def ValidAuthToken(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
298 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
299 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
300 'invalid_token': _(u'Token mismatch') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
301 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
302 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
303 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
304 if value != authentication_token(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
305 msg = M(self, 'invalid_token', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
306 raise formencode.Invalid(msg, value, state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
307 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
308 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
309 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
310 def ValidRepoName(edit=False, old_data={}): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
311 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
312 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
313 'invalid_repo_name': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
314 _(u'Repository name %(repo)s is disallowed'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
315 'repository_exists': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
316 _(u'Repository named %(repo)s already exists'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
317 'repository_in_group_exists': _(u'Repository "%(repo)s" already ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
318 'exists in group "%(group)s"'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
319 'same_group_exists': _(u'Repositories group with name "%(repo)s" ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
320 'already exists') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
321 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
322 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
323 def _to_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
324 repo_name = repo_name_slug(value.get('repo_name', '')) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
325 repo_group = value.get('repo_group') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
326 if repo_group: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
327 gr = RepoGroup.get(repo_group) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
328 group_path = gr.full_path |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
329 group_name = gr.group_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
330 # value needs to be aware of group name in order to check |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
331 # db key This is an actual just the name to store in the |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
332 # database |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
333 repo_name_full = group_path + RepoGroup.url_sep() + repo_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
334 else: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
335 group_name = group_path = '' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
336 repo_name_full = repo_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
337 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
338 value['repo_name'] = repo_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
339 value['repo_name_full'] = repo_name_full |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
340 value['group_path'] = group_path |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
341 value['group_name'] = group_name |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
342 return value |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
343 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
344 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
345 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
346 repo_name = value.get('repo_name') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
347 repo_name_full = value.get('repo_name_full') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
348 group_path = value.get('group_path') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
349 group_name = value.get('group_name') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
350 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
351 if repo_name in [ADMIN_PREFIX, '']: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
352 msg = M(self, 'invalid_repo_name', state, repo=repo_name) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
353 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
354 error_dict=dict(repo_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
355 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
356 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
357 rename = old_data.get('repo_name') != repo_name_full |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
358 create = not edit |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
359 if rename or create: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
360 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
361 if group_path != '': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
362 if Repository.get_by_repo_name(repo_name_full): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
363 msg = M(self, 'repository_in_group_exists', state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
364 repo=repo_name, group=group_name) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
365 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
366 error_dict=dict(repo_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
367 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
368 elif RepoGroup.get_by_group_name(repo_name_full): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
369 msg = M(self, 'same_group_exists', state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
370 repo=repo_name) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
371 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
372 error_dict=dict(repo_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
373 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
374 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
375 elif Repository.get_by_repo_name(repo_name_full): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
376 msg = M(self, 'repository_exists', state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
377 repo=repo_name) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
378 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
379 error_dict=dict(repo_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
380 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
381 return value |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
382 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
383 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
384 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
385 def ValidForkName(*args, **kwargs): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
386 return ValidRepoName(*args, **kwargs) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
387 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
388 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
389 def SlugifyName(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
390 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
391 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
392 def _to_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
393 return repo_name_slug(value) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
394 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
395 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
396 pass |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
397 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
398 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
399 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
400 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
401 def ValidCloneUri(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
402 from rhodecode.lib.utils import make_ui |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
403 |
2701 | 404 def url_handler(repo_type, url, ui=None): |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
405 if repo_type == 'hg': |
2706
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
406 from rhodecode.lib.vcs.backends.hg.repository import MercurialRepository |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
407 from mercurial.httppeer import httppeer |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
408 if url.startswith('http'): |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
409 ## initially check if it's at least the proper URL |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
410 ## or does it pass basic auth |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
411 MercurialRepository._check_url(url) |
2717
dd240b2b7a12
Added optional flag to make_ui to not clean sqlalchemy Session.
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
412 httppeer(ui, url)._capabilities() |
2701 | 413 elif url.startswith('svn+http'): |
414 from hgsubversion.svnrepo import svnremoterepo | |
2717
dd240b2b7a12
Added optional flag to make_ui to not clean sqlalchemy Session.
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
415 svnremoterepo(ui, url).capabilities |
2706
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
416 elif url.startswith('git+http'): |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
417 raise NotImplementedError() |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
418 |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
419 elif repo_type == 'git': |
2706
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
420 from rhodecode.lib.vcs.backends.git.repository import GitRepository |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
421 if url.startswith('http'): |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
422 ## initially check if it's at least the proper URL |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
423 ## or does it pass basic auth |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
424 GitRepository._check_url(url) |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
425 elif url.startswith('svn+http'): |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
426 raise NotImplementedError() |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
427 elif url.startswith('hg+http'): |
22f79562836c
Fixed validators for remote repos
Marcin Kuzminski <marcin@python-works.com>
parents:
2701
diff
changeset
|
428 raise NotImplementedError() |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
429 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
430 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
431 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
432 'clone_uri': _(u'invalid clone url'), |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
433 'invalid_clone_uri': _(u'Invalid clone url, provide a ' |
2700
f4b20558ae16
allow cloning with hgsubversion (reimplementing pull request 46)
domruf <dominikruf@gmail.com>
parents:
2479
diff
changeset
|
434 'valid clone http(s)/svn+http(s) url') |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
435 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
436 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
437 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
438 repo_type = value.get('repo_type') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
439 url = value.get('clone_uri') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
440 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
441 if not url: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
442 pass |
2701 | 443 else: |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
444 try: |
2717
dd240b2b7a12
Added optional flag to make_ui to not clean sqlalchemy Session.
Marcin Kuzminski <marcin@python-works.com>
parents:
2711
diff
changeset
|
445 url_handler(repo_type, url, make_ui('db', clear_session=False)) |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
446 except Exception: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
447 log.exception('Url validation failed') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
448 msg = M(self, 'clone_uri') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
449 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
450 error_dict=dict(clone_uri=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
451 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
452 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
453 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
454 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
455 def ValidForkType(old_data={}): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
456 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
457 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
458 'invalid_fork_type': _(u'Fork have to be the same type as parent') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
459 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
460 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
461 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
462 if old_data['repo_type'] != value: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
463 msg = M(self, 'invalid_fork_type', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
464 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
465 error_dict=dict(repo_type=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
466 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
467 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
468 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
469 |
2835
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
470 def CanWriteGroup(): |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
471 class _validator(formencode.validators.FancyValidator): |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
472 messages = { |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
473 'permission_denied': _(u"You don't have permissions " |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
474 "to create repository in this group") |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
475 } |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
476 |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
477 def validate_python(self, value, state): |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
478 gr = RepoGroup.get(value) |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
479 if not HasReposGroupPermissionAny( |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
480 'group.write', 'group.admin' |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
481 )(gr.group_name, 'get group of repo form'): |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
482 msg = M(self, 'permission_denied', state) |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
483 raise formencode.Invalid(msg, value, state, |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
484 error_dict=dict(repo_type=msg) |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
485 ) |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
486 return _validator |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
487 |
faffec4abbda
Implemented permissions for writing to repo
Marcin Kuzminski <marcin@python-works.com>
parents:
2820
diff
changeset
|
488 |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
489 def ValidPerms(type_='repo'): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
490 if type_ == 'group': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
491 EMPTY_PERM = 'group.none' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
492 elif type_ == 'repo': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
493 EMPTY_PERM = 'repository.none' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
494 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
495 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
496 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
497 'perm_new_member_name': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
498 _(u'This username or users group name is not valid') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
499 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
500 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
501 def to_python(self, value, state): |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
502 perms_update = OrderedSet() |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
503 perms_new = OrderedSet() |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
504 # build a list of permission to update and new permission to create |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
505 |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
506 #CLEAN OUT ORG VALUE FROM NEW MEMBERS, and group them using |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
507 new_perms_group = defaultdict(dict) |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
508 for k, v in value.copy().iteritems(): |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
509 if k.startswith('perm_new_member'): |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
510 del value[k] |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
511 _type, part = k.split('perm_new_member_') |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
512 args = part.split('_') |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
513 if len(args) == 1: |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
514 new_perms_group[args[0]]['perm'] = v |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
515 elif len(args) == 2: |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
516 _key, pos = args |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
517 new_perms_group[pos][_key] = v |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
518 |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
519 # fill new permissions in order of how they were added |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
520 for k in sorted(map(int, new_perms_group.keys())): |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
521 perm_dict = new_perms_group[str(k)] |
2820
c0cc8f8a71b0
Permissions on group can be set in recursive mode setting defined permission to all children
Marcin Kuzminski <marcin@python-works.com>
parents:
2759
diff
changeset
|
522 new_member = perm_dict.get('name') |
c0cc8f8a71b0
Permissions on group can be set in recursive mode setting defined permission to all children
Marcin Kuzminski <marcin@python-works.com>
parents:
2759
diff
changeset
|
523 new_perm = perm_dict.get('perm') |
c0cc8f8a71b0
Permissions on group can be set in recursive mode setting defined permission to all children
Marcin Kuzminski <marcin@python-works.com>
parents:
2759
diff
changeset
|
524 new_type = perm_dict.get('type') |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
525 if new_member and new_perm and new_type: |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
526 perms_new.add((new_member, new_perm, new_type)) |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
527 |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
528 for k, v in value.iteritems(): |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
529 if k.startswith('u_perm_') or k.startswith('g_perm_'): |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
530 member = k[7:] |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
531 t = {'u': 'user', |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
532 'g': 'users_group' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
533 }[k[0]] |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
534 if member == 'default': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
535 if value.get('private'): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
536 # set none for default when updating to |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
537 # private repo |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
538 v = EMPTY_PERM |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
539 perms_update.add((member, v, t)) |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
540 |
2759
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
541 value['perms_updates'] = list(perms_update) |
c61c2ccea2b4
#538 form for permissions can handle multiple users at once
Marcin Kuzminski <marcin@python-works.com>
parents:
2719
diff
changeset
|
542 value['perms_new'] = list(perms_new) |
2466
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
543 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
544 # update permissions |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
545 for k, v, t in perms_new: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
546 try: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
547 if t is 'user': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
548 self.user_db = User.query()\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
549 .filter(User.active == True)\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
550 .filter(User.username == k).one() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
551 if t is 'users_group': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
552 self.user_db = UsersGroup.query()\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
553 .filter(UsersGroup.users_group_active == True)\ |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
554 .filter(UsersGroup.users_group_name == k).one() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
555 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
556 except Exception: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
557 log.exception('Updated permission failed') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
558 msg = M(self, 'perm_new_member_type', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
559 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
560 error_dict=dict(perm_new_member_name=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
561 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
562 return value |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
563 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
564 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
565 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
566 def ValidSettings(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
567 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
568 def _to_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
569 # settings form can't edit user |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
570 if 'user' in value: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
571 del value['user'] |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
572 return value |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
573 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
574 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
575 pass |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
576 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
577 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
578 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
579 def ValidPath(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
580 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
581 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
582 'invalid_path': _(u'This is not a valid path') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
583 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
584 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
585 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
586 if not os.path.isdir(value): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
587 msg = M(self, 'invalid_path', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
588 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
589 error_dict=dict(paths_root_path=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
590 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
591 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
592 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
593 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
594 def UniqSystemEmail(old_data={}): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
595 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
596 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
597 'email_taken': _(u'This e-mail address is already taken') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
598 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
599 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
600 def _to_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
601 return value.lower() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
602 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
603 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
604 if (old_data.get('email') or '').lower() != value: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
605 user = User.get_by_email(value, case_insensitive=True) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
606 if user: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
607 msg = M(self, 'email_taken', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
608 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
609 error_dict=dict(email=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
610 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
611 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
612 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
613 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
614 def ValidSystemEmail(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
615 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
616 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
617 'non_existing_email': _(u'e-mail "%(email)s" does not exist.') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
618 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
619 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
620 def _to_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
621 return value.lower() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
622 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
623 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
624 user = User.get_by_email(value, case_insensitive=True) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
625 if user is None: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
626 msg = M(self, 'non_existing_email', state, email=value) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
627 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
628 error_dict=dict(email=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
629 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
630 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
631 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
632 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
633 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
634 def LdapLibValidator(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
635 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
636 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
637 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
638 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
639 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
640 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
641 try: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
642 import ldap |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
643 ldap # pyflakes silence ! |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
644 except ImportError: |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
645 raise LdapImportError() |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
646 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
647 return _validator |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
648 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
649 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
650 def AttrLoginValidator(): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
651 class _validator(formencode.validators.FancyValidator): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
652 messages = { |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
653 'invalid_cn': |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
654 _(u'The LDAP Login attribute of the CN must be specified - ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
655 'this is the name of the attribute that is equivalent ' |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
656 'to "username"') |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
657 } |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
658 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
659 def validate_python(self, value, state): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
660 if not value or not isinstance(value, (str, unicode)): |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
661 msg = M(self, 'invalid_cn', state) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
662 raise formencode.Invalid(msg, value, state, |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
663 error_dict=dict(ldap_attr_login=msg) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
664 ) |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
665 |
7010dc12f10c
Added rewritten validators module + tests
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
666 return _validator |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
667 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
668 |
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
|
669 def NotReviewedRevisions(repo_id): |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
670 class _validator(formencode.validators.FancyValidator): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
671 messages = { |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
672 'rev_already_reviewed': |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
673 _(u'Revisions %(revs)s are already part of pull request ' |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
674 'or have set status') |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
675 } |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
676 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
677 def validate_python(self, value, state): |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
678 # check revisions if they are not reviewed, or a part of another |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
679 # pull request |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
680 statuses = ChangesetStatus.query()\ |
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
|
681 .filter(ChangesetStatus.revision.in_(value))\ |
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
|
682 .filter(ChangesetStatus.repo_id == repo_id)\ |
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
|
683 .all() |
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
|
684 |
2719
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
685 errors = [] |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
686 for cs in statuses: |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
687 if cs.pull_request_id: |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
688 errors.append(['pull_req', cs.revision[:12]]) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
689 elif cs.status: |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
690 errors.append(['status', cs.revision[:12]]) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
691 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
692 if errors: |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
693 revs = ','.join([x[1] for x in errors]) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
694 msg = M(self, 'rev_already_reviewed', state, revs=revs) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
695 raise formencode.Invalid(msg, value, state, |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
696 error_dict=dict(revisions=revs) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
697 ) |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
698 |
2e7f7568ea92
Changed v.Set validation into our own that actually raises exceptions on missing values.
Marcin Kuzminski <marcin@python-works.com>
parents:
2717
diff
changeset
|
699 return _validator |