Mercurial > kallithea
annotate rhodecode/model/forms.py @ 2156:a27e4d44237e beta
Use __unicode__ instead of __repr__ in models.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 22 Mar 2012 02:44:42 +0200 |
parents | 98f912832811 |
children | 6c6718c06ea2 e1c1ebbe7346 |
rev | line source |
---|---|
0 | 1 """ this is forms validation classes |
2 http://formencode.org/module-formencode.validators.html | |
3 for list off all availible validators | |
4 | |
5 we can create our own validators | |
6 | |
7 The table below outlines the options which can be used in a schema in addition to the validators themselves | |
8 pre_validators [] These validators will be applied before the schema | |
9 chained_validators [] These validators will be applied after the schema | |
10 allow_extra_fields False If True, then it is not an error when keys that aren't associated with a validator are present | |
11 filter_extra_fields False If True, then keys that aren't associated with a validator are removed | |
12 if_key_missing NoDefault If this is given, then any keys that aren't available but are expected will be replaced with this value (and then validated). This does not override a present .if_missing attribute on validators. NoDefault is a special FormEncode class to mean that no default values has been specified and therefore missing keys shouldn't take a default value. | |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
13 ignore_key_missing False If True, then missing keys will be missing in the result, if the validator doesn't have .if_missing on it already |
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
14 |
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
15 |
0 | 16 <name> = formencode.validators.<name of validator> |
17 <name> must equal form name | |
18 list=[1,2,3,4,5] | |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
19 for SELECT use formencode.All(OneOf(list), Int()) |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
20 |
0 | 21 """ |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
22 import os |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
23 import re |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
24 import logging |
1298
e3deb588cf14
fixed http/s validation for clone_uri, and missing return value.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
25 import traceback |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
26 |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
27 import formencode |
242
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
238
diff
changeset
|
28 from formencode import All |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
29 from formencode.validators import UnicodeString, OneOf, Int, Number, Regex, \ |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
30 Email, Bool, StringBoolean, Set |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
31 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
32 from pylons.i18n.translation import _ |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
33 from webhelpers.pylonslib.secure_form import authentication_token |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
34 |
1533
c0e6057543ff
fixed hardcoded admin prefix check in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
35 from rhodecode.config.routing import ADMIN_PREFIX |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
1015
diff
changeset
|
36 from rhodecode.lib.utils import repo_name_slug |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
37 from rhodecode.lib.auth import authenticate, get_crypt_password |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
38 from rhodecode.lib.exceptions import LdapImportError |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1742
diff
changeset
|
39 from rhodecode.model.db import User, UsersGroup, RepoGroup, Repository |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
40 from rhodecode import BACKENDS |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
41 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
42 log = logging.getLogger(__name__) |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
43 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
44 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
45 #this is needed to translate the messages using _() in validators |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
46 class State_obj(object): |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
47 _ = staticmethod(_) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
48 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
49 |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
50 #============================================================================== |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
51 # VALIDATORS |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
52 #============================================================================== |
0 | 53 class ValidAuthToken(formencode.validators.FancyValidator): |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
54 messages = {'invalid_token': _('Token mismatch')} |
0 | 55 |
56 def validate_python(self, value, state): | |
57 | |
58 if value != authentication_token(): | |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
59 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
60 self.message('invalid_token', |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
61 state, search_number=value), |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
62 value, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
63 state |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
64 ) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
65 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
66 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
67 def ValidUsername(edit, old_data): |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
68 class _ValidUsername(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
69 |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
70 def validate_python(self, value, state): |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
71 if value in ['default', 'new_user']: |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
72 raise formencode.Invalid(_('Invalid username'), value, state) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
73 #check if user is unique |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
74 old_un = None |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
75 if edit: |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1742
diff
changeset
|
76 old_un = User.get(old_data.get('user_id')).username |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
77 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
78 if old_un != value or not edit: |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
79 if User.get_by_username(value, case_insensitive=True): |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
80 raise formencode.Invalid(_('This username already ' |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
81 'exists') , value, state) |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
82 |
960
029e69f0d21d
fixed #102 allowed '.' character in username
Marcin Kuzminski <marcin@python-works.com>
parents:
959
diff
changeset
|
83 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
84 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
85 _('Username may only contain alphanumeric characters ' |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
86 'underscores, periods or dashes and must begin with ' |
1963
9bbde54232dc
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1950
diff
changeset
|
87 'alphanumeric character'), |
9bbde54232dc
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1950
diff
changeset
|
88 value, |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
89 state |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
90 ) |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
91 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
92 return _ValidUsername |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
93 |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
94 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
95 def ValidUsersGroup(edit, old_data): |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
96 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
97 class _ValidUsersGroup(formencode.validators.FancyValidator): |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
98 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
99 def validate_python(self, value, state): |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
100 if value in ['default']: |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
101 raise formencode.Invalid(_('Invalid group name'), value, state) |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
102 #check if group is unique |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
103 old_ugname = None |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
104 if edit: |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
105 old_ugname = UsersGroup.get( |
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
106 old_data.get('users_group_id')).users_group_name |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
107 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
108 if old_ugname != value or not edit: |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
109 if UsersGroup.get_by_group_name(value, cache=False, |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
110 case_insensitive=True): |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
111 raise formencode.Invalid(_('This users group ' |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
112 'already exists'), value, |
1271
aa7e45ad0cea
Fixed permissions for users groups, group can have create repo permission now.
Marcin Kuzminski <marcin@python-works.com>
parents:
1261
diff
changeset
|
113 state) |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
114 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
115 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
116 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
117 _('RepoGroup name may only contain alphanumeric characters ' |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
118 'underscores, periods or dashes and must begin with ' |
1963
9bbde54232dc
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1950
diff
changeset
|
119 'alphanumeric character'), |
9bbde54232dc
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
1950
diff
changeset
|
120 value, |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
121 state |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
122 ) |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
123 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
124 return _ValidUsersGroup |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
125 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
126 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
127 def ValidReposGroup(edit, old_data): |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
128 class _ValidReposGroup(formencode.validators.FancyValidator): |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
129 |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
130 def validate_python(self, value, state): |
1735
344ddfeecce2
small fixes for detection of groups that already exists
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
131 # TODO WRITE VALIDATIONS |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
132 group_name = value.get('group_name') |
1735
344ddfeecce2
small fixes for detection of groups that already exists
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
133 group_parent_id = value.get('group_parent_id') |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
134 |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
135 # slugify repo group just in case :) |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
136 slug = repo_name_slug(group_name) |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
137 |
1349
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
138 # check for parent of self |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
139 parent_of_self = lambda: ( |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
140 old_data['group_id'] == int(group_parent_id) |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
141 if group_parent_id else False |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
142 ) |
1735
344ddfeecce2
small fixes for detection of groups that already exists
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
143 if edit and parent_of_self(): |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
144 e_dict = { |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
145 'group_parent_id': _('Cannot assign this group as parent') |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
146 } |
1349
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
147 raise formencode.Invalid('', value, state, |
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
148 error_dict=e_dict) |
526120c77a38
#47 added editing of groups, and moving them between. Added check constraint for groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1347
diff
changeset
|
149 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
150 old_gname = None |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
151 if edit: |
1735
344ddfeecce2
small fixes for detection of groups that already exists
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
152 old_gname = RepoGroup.get(old_data.get('group_id')).group_name |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
153 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
154 if old_gname != group_name or not edit: |
1735
344ddfeecce2
small fixes for detection of groups that already exists
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
155 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
156 # check group |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
157 gr = RepoGroup.query()\ |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
158 .filter(RepoGroup.group_name == slug)\ |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
159 .filter(RepoGroup.group_parent_id == group_parent_id)\ |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
160 .scalar() |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
161 |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
162 if gr: |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
163 e_dict = { |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
164 'group_name': _('This group already exists') |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
165 } |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
166 raise formencode.Invalid('', value, state, |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
167 error_dict=e_dict) |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
168 |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
169 # check for same repo |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
170 repo = Repository.query()\ |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
171 .filter(Repository.repo_name == slug)\ |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
172 .scalar() |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
173 |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
174 if repo: |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
175 e_dict = { |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
176 'group_name': _('Repository with this name already exists') |
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
177 } |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
178 raise formencode.Invalid('', value, state, |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
179 error_dict=e_dict) |
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
180 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
181 return _ValidReposGroup |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
182 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
183 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
184 class ValidPassword(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
185 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
186 def to_python(self, value, state): |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
187 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
188 if not value: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
189 return |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
190 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
191 if value.get('password'): |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
192 try: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
193 value['password'] = get_crypt_password(value['password']) |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
194 except UnicodeEncodeError: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
195 e_dict = {'password': _('Invalid characters in password')} |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
196 raise formencode.Invalid('', value, state, error_dict=e_dict) |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
197 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
198 if value.get('password_confirmation'): |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
199 try: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
200 value['password_confirmation'] = \ |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
201 get_crypt_password(value['password_confirmation']) |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
202 except UnicodeEncodeError: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
203 e_dict = { |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
204 'password_confirmation': _('Invalid characters in password') |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
205 } |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
206 raise formencode.Invalid('', value, state, error_dict=e_dict) |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
207 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
208 if value.get('new_password'): |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
209 try: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
210 value['new_password'] = \ |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
211 get_crypt_password(value['new_password']) |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
212 except UnicodeEncodeError: |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
213 e_dict = {'new_password': _('Invalid characters in password')} |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
214 raise formencode.Invalid('', value, state, error_dict=e_dict) |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
215 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
216 return value |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
217 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
218 |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
219 class ValidPasswordsMatch(formencode.validators.FancyValidator): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
220 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
221 def validate_python(self, value, state): |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
222 |
1597
019026a8cf67
implements #237 added password confirmation for my account and admin edit user.
Marcin Kuzminski <marcin@python-works.com>
parents:
1594
diff
changeset
|
223 pass_val = value.get('password') or value.get('new_password') |
019026a8cf67
implements #237 added password confirmation for my account and admin edit user.
Marcin Kuzminski <marcin@python-works.com>
parents:
1594
diff
changeset
|
224 if pass_val != value['password_confirmation']: |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
225 e_dict = {'password_confirmation': |
1472
aaec08ad9daf
Added pt_BR localization, added i18n wrappers on some places missing, fixed css in settings screen for longer labels.
Augusto Herrmann <augusto.herrmann@planejamento.gov.br>
parents:
1366
diff
changeset
|
226 _('Passwords do not match')} |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
227 raise formencode.Invalid('', value, state, error_dict=e_dict) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
228 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
229 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
230 class ValidAuth(formencode.validators.FancyValidator): |
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
231 messages = { |
1594 | 232 'invalid_password':_('invalid password'), |
233 'invalid_login':_('invalid user name'), | |
234 'disabled_account':_('Your account is disabled') | |
235 } | |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
236 |
1594 | 237 # error mapping |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
238 e_dict = {'username': messages['invalid_login'], |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
239 'password': messages['invalid_password']} |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
240 e_dict_disable = {'username': messages['disabled_account']} |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
241 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
242 def validate_python(self, value, state): |
415
04e8b31fb245
Changed password crypting scheme to bcrypt, added dependency for setup
Marcin Kuzminski <marcin@python-works.com>
parents:
395
diff
changeset
|
243 password = value['password'] |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
244 username = value['username'] |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1514
diff
changeset
|
245 user = User.get_by_username(username) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
246 |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
247 if authenticate(username, password): |
699
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
248 return value |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
249 else: |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
250 if user and user.active is False: |
1976 | 251 log.warning('user %s is disabled' % username) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
252 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
253 self.message('disabled_account', |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
254 state=State_obj), |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
255 value, state, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
256 error_dict=self.e_dict_disable |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
257 ) |
699
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
258 else: |
2025
7e979933ffec
more work on improving info logging
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
259 log.warning('user %s failed to authenticate' % username) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
260 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
261 self.message('invalid_password', |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
262 state=State_obj), value, state, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
263 error_dict=self.e_dict |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
264 ) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
265 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
266 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
267 class ValidRepoUser(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
268 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
269 def to_python(self, value, state): |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
270 try: |
1361
87ca17540603
fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1357
diff
changeset
|
271 User.query().filter(User.active == True)\ |
328
cec5cbc956c0
Repository managment permissions, fixed found bugs updated js, added extra checks for doubled users and non active ones
Marcin Kuzminski <marcin@python-works.com>
parents:
320
diff
changeset
|
272 .filter(User.username == value).one() |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
273 except Exception: |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
274 raise formencode.Invalid(_('This username is not valid'), |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
275 value, state) |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
276 return value |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
277 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
278 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
279 def ValidRepoName(edit, old_data): |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
280 class _ValidRepoName(formencode.validators.FancyValidator): |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
281 def to_python(self, value, state): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
282 |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
283 repo_name = value.get('repo_name') |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
284 |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
285 slug = repo_name_slug(repo_name) |
1533
c0e6057543ff
fixed hardcoded admin prefix check in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
286 if slug in [ADMIN_PREFIX, '']: |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
287 e_dict = {'repo_name': _('This repository name is disallowed')} |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
288 raise formencode.Invalid('', value, state, error_dict=e_dict) |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
289 |
1324
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
290 if value.get('repo_group'): |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
291 gr = RepoGroup.get(value.get('repo_group')) |
1324
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
292 group_path = gr.full_path |
1346
cf78d302d441
#47 implemented deleting of empty groups. Fixed problem with full paths on nested groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1345
diff
changeset
|
293 # value needs to be aware of group name in order to check |
1550
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
294 # db key This is an actual just the name to store in the |
1361
87ca17540603
fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1357
diff
changeset
|
295 # database |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
296 repo_name_full = group_path + RepoGroup.url_sep() + repo_name |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
297 |
1324
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
298 else: |
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
299 group_path = '' |
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
300 repo_name_full = repo_name |
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
301 |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
302 value['repo_name_full'] = repo_name_full |
1550
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
303 rename = old_data.get('repo_name') != repo_name_full |
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
304 create = not edit |
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
305 if rename or create: |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
306 |
1324
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
307 if group_path != '': |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1742
diff
changeset
|
308 if Repository.get_by_repo_name(repo_name_full): |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
309 e_dict = { |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
310 'repo_name': _('This repository already exists in ' |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
311 'a group "%s"') % gr.group_name |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
312 } |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
313 raise formencode.Invalid('', value, state, |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
314 error_dict=e_dict) |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
315 elif RepoGroup.get_by_group_name(repo_name_full): |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
316 e_dict = { |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
317 'repo_name': _('There is a group with this name ' |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
318 'already "%s"') % repo_name_full |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
319 } |
1550
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
320 raise formencode.Invalid('', value, state, |
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
321 error_dict=e_dict) |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
322 |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1742
diff
changeset
|
323 elif Repository.get_by_repo_name(repo_name_full): |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
324 e_dict = {'repo_name': _('This repository ' |
1324
e272be3244f0
fixed regresion made in previos commit, that introduced bug in handling regular repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1323
diff
changeset
|
325 'already exists')} |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
326 raise formencode.Invalid('', value, state, |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
327 error_dict=e_dict) |
1550
6f468ba37650
fixes #266 Rhodecode allows to create repo with the same name and in the same parent as group
Marcin Kuzminski <marcin@python-works.com>
parents:
1539
diff
changeset
|
328 |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
329 return value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
330 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
331 return _ValidRepoName |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
332 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
333 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
334 def ValidForkName(*args, **kwargs): |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
335 return ValidRepoName(*args, **kwargs) |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1364
diff
changeset
|
336 |
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1364
diff
changeset
|
337 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
338 def SlugifyName(): |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
339 class _SlugifyName(formencode.validators.FancyValidator): |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
340 |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
341 def to_python(self, value, state): |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
342 return repo_name_slug(value) |
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
343 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
344 return _SlugifyName |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
345 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
346 |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
347 def ValidCloneUri(): |
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
348 from rhodecode.lib.utils import make_ui |
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
349 |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
350 def url_handler(repo_type, url, proto, ui=None): |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
351 if repo_type == 'hg': |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
352 from mercurial.httprepo import httprepository, httpsrepository |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
353 if proto == 'https': |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
354 httpsrepository(make_ui('db'), url).capabilities |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
355 elif proto == 'http': |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
356 httprepository(make_ui('db'), url).capabilities |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
357 elif repo_type == 'git': |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
358 #TODO: write a git url validator |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
359 pass |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
360 |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
361 class _ValidCloneUri(formencode.validators.FancyValidator): |
1298
e3deb588cf14
fixed http/s validation for clone_uri, and missing return value.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
362 |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
363 def to_python(self, value, state): |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
364 |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
365 repo_type = value.get('repo_type') |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
366 url = value.get('clone_uri') |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
367 e_dict = {'clone_uri': _('invalid clone url')} |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
368 |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
369 if not url: |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
370 pass |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
371 elif url.startswith('https'): |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
372 try: |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
373 url_handler(repo_type, url, 'https', make_ui('db')) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
374 except Exception: |
1298
e3deb588cf14
fixed http/s validation for clone_uri, and missing return value.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
375 log.error(traceback.format_exc()) |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
376 raise formencode.Invalid('', value, state, error_dict=e_dict) |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
377 elif url.startswith('http'): |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
378 try: |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
379 url_handler(repo_type, url, 'http', make_ui('db')) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
380 except Exception: |
1298
e3deb588cf14
fixed http/s validation for clone_uri, and missing return value.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
381 log.error(traceback.format_exc()) |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
382 raise formencode.Invalid('', value, state, error_dict=e_dict) |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
383 else: |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
384 e_dict = {'clone_uri': _('Invalid clone url, provide a ' |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
385 'valid clone http\s url')} |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
386 raise formencode.Invalid('', value, state, error_dict=e_dict) |
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
387 |
1298
e3deb588cf14
fixed http/s validation for clone_uri, and missing return value.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
388 return value |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
389 |
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
390 return _ValidCloneUri |
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
391 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
392 |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
393 def ValidForkType(old_data): |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
394 class _ValidForkType(formencode.validators.FancyValidator): |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
395 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
396 def to_python(self, value, state): |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
397 if old_data['repo_type'] != value: |
1261
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
398 raise formencode.Invalid(_('Fork have to be the same ' |
30828b1ebe20
added dump validation of cloneurl, it can still freeze if server will ask for auth.
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
399 'type as original'), value, state) |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1364
diff
changeset
|
400 |
659
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
401 return value |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
402 return _ValidForkType |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
403 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
404 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
405 def ValidPerms(type_='repo'): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
406 if type_ == 'group': |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
407 EMPTY_PERM = 'group.none' |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
408 elif type_ == 'repo': |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
409 EMPTY_PERM = 'repository.none' |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
410 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
411 class _ValidPerms(formencode.validators.FancyValidator): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
412 messages = { |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
413 'perm_new_member_name': |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
414 _('This username or users group name is not valid') |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
415 } |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
416 |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
417 def to_python(self, value, state): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
418 perms_update = [] |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
419 perms_new = [] |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
420 # build a list of permission to update and new permission to create |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
421 for k, v in value.items(): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
422 # means new added member to permissions |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
423 if k.startswith('perm_new_member'): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
424 new_perm = value.get('perm_new_member', False) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
425 new_member = value.get('perm_new_member_name', False) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
426 new_type = value.get('perm_new_member_type') |
1013
d2a840b29858
#56 hacking on forms, and model for users groups
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
427 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
428 if new_member and new_perm: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
429 if (new_member, new_perm, new_type) not in perms_new: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
430 perms_new.append((new_member, new_perm, new_type)) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
431 elif k.startswith('u_perm_') or k.startswith('g_perm_'): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
432 member = k[7:] |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
433 t = {'u': 'user', |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
434 'g': 'users_group' |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
435 }[k[0]] |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
436 if member == 'default': |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
437 if value.get('private'): |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
438 # set none for default when updating to private repo |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
439 v = EMPTY_PERM |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
440 perms_update.append((member, v, t)) |
1015
65129c332d37
#56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents:
1014
diff
changeset
|
441 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
442 value['perms_updates'] = perms_update |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
443 value['perms_new'] = perms_new |
1014
6fdc3ff65fce
#56 added assignments of users groups into repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1013
diff
changeset
|
444 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
445 # update permissions |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
446 for k, v, t in perms_new: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
447 try: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
448 if t is 'user': |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
449 self.user_db = User.query()\ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
450 .filter(User.active == True)\ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
451 .filter(User.username == k).one() |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
452 if t is 'users_group': |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
453 self.user_db = UsersGroup.query()\ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
454 .filter(UsersGroup.users_group_active == True)\ |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
455 .filter(UsersGroup.users_group_name == k).one() |
1013
d2a840b29858
#56 hacking on forms, and model for users groups
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
456 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
457 except Exception: |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
458 msg = self.message('perm_new_member_name', |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
459 state=State_obj) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
460 raise formencode.Invalid( |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
461 msg, value, state, error_dict={'perm_new_member_name': msg} |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
462 ) |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
463 return value |
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
464 return _ValidPerms |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
465 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
466 |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
467 class ValidSettings(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
468 |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
469 def to_python(self, value, state): |
1757
2aa7f454204e
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
470 # settings form can't edit user |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
471 if 'user' in value: |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
472 del['value']['user'] |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
473 return value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
474 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
475 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
476 class ValidPath(formencode.validators.FancyValidator): |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
477 def to_python(self, value, state): |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
478 |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
479 if not os.path.isdir(value): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
480 msg = _('This is not a valid path') |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
481 raise formencode.Invalid(msg, value, state, |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
482 error_dict={'paths_root_path': msg}) |
631
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
483 return value |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
484 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
485 |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
486 def UniqSystemEmail(old_data): |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
487 class _UniqSystemEmail(formencode.validators.FancyValidator): |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
488 def to_python(self, value, state): |
741
54684e071457
fixes issue #78, ldap makes user validation caseInsensitive
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
489 value = value.lower() |
2072
98f912832811
fixes #376 Cannot edit user (using container auth)
Marcin Kuzminski <marcin@python-works.com>
parents:
2058
diff
changeset
|
490 if (old_data.get('email') or '').lower() != value: |
1757
2aa7f454204e
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
491 user = User.get_by_email(value, case_insensitive=True) |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
492 if user: |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
493 raise formencode.Invalid( |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
494 _("This e-mail address is already taken"), value, state |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
495 ) |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
496 return value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
497 |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
498 return _UniqSystemEmail |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
499 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
500 |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
501 class ValidSystemEmail(formencode.validators.FancyValidator): |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
502 def to_python(self, value, state): |
741
54684e071457
fixes issue #78, ldap makes user validation caseInsensitive
Marcin Kuzminski <marcin@python-works.com>
parents:
735
diff
changeset
|
503 value = value.lower() |
1757
2aa7f454204e
fixes #298, ldap email addresses created by rhodecode automatically during first login didn't get converted to lower case, which lead to lookup failures and than wrong checks for uniqueness. Fixed that by putting a setter on db model column that will enforce converting to lowercase.
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
504 user = User.get_by_email(value, case_insensitive=True) |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
505 if user is None: |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
506 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
507 _("This e-mail address doesn't exist."), value, state |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
508 ) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
509 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
510 return value |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
511 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
512 |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
513 class LdapLibValidator(formencode.validators.FancyValidator): |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
514 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
515 def to_python(self, value, state): |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
516 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
517 try: |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
518 import ldap |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
519 except ImportError: |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
520 raise LdapImportError |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
521 return value |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
522 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
523 |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
524 class AttrLoginValidator(formencode.validators.FancyValidator): |
775
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
525 |
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
526 def to_python(self, value, state): |
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
527 |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
528 if not value or not isinstance(value, (str, unicode)): |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
529 raise formencode.Invalid( |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
530 _("The LDAP Login attribute of the CN must be specified - " |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
531 "this is the name of the attribute that is equivalent " |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
532 "to 'username'"), value, state |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
533 ) |
775
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
534 |
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
535 return value |
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
536 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
537 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
538 #============================================================================== |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1159
diff
changeset
|
539 # FORMS |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
540 #============================================================================== |
45 | 541 class LoginForm(formencode.Schema): |
542 allow_extra_fields = True | |
543 filter_extra_fields = True | |
544 username = UnicodeString( | |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
545 strip=True, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
546 min=1, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
547 not_empty=True, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
548 messages={ |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
549 'empty': _('Please enter a login'), |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
550 'tooShort': _('Enter a value %(min)i characters long or more')} |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
551 ) |
0 | 552 |
45 | 553 password = UnicodeString( |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
554 strip=True, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
555 min=3, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
556 not_empty=True, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
557 messages={ |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
558 'empty': _('Please enter a password'), |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
559 'tooShort': _('Enter %(min)i characters or more')} |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
560 ) |
0 | 561 |
1802
145677a36675
Remember Me option on login
Matt Zuba <matt.zuba@goodwillaz.org>
parents:
1765
diff
changeset
|
562 remember = StringBoolean(if_missing=False) |
1818
cf51bbfb120e
auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents:
1802
diff
changeset
|
563 |
186
556473ba0399
fixed menu in home page, and added login html with forms that validates username and password.
Marcin Kuzminski <marcin@python-works.com>
parents:
45
diff
changeset
|
564 chained_validators = [ValidAuth] |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
565 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
566 |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
567 def UserForm(edit=False, old_data={}): |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
568 class _UserForm(formencode.Schema): |
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
569 allow_extra_fields = True |
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
570 filter_extra_fields = True |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
571 username = All(UnicodeString(strip=True, min=1, not_empty=True), |
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
572 ValidUsername(edit, old_data)) |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
573 if edit: |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
574 new_password = All(UnicodeString(strip=True, min=6, not_empty=False)) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
575 password_confirmation = All(UnicodeString(strip=True, min=6, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
576 not_empty=False)) |
329
aafd9a98ea58
added admin flag to users editing
Marcin Kuzminski <marcin@python-works.com>
parents:
328
diff
changeset
|
577 admin = StringBoolean(if_missing=False) |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
578 else: |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
579 password = All(UnicodeString(strip=True, min=6, not_empty=True)) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
580 password_confirmation = All(UnicodeString(strip=True, min=6, |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
581 not_empty=False)) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
582 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
583 active = StringBoolean(if_missing=False) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
584 name = UnicodeString(strip=True, min=1, not_empty=False) |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
585 lastname = UnicodeString(strip=True, min=1, not_empty=False) |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
586 email = All(Email(not_empty=True), UniqSystemEmail(old_data)) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
587 |
1597
019026a8cf67
implements #237 added password confirmation for my account and admin edit user.
Marcin Kuzminski <marcin@python-works.com>
parents:
1594
diff
changeset
|
588 chained_validators = [ValidPasswordsMatch, ValidPassword] |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
589 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
590 return _UserForm |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
591 |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
592 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
593 def UsersGroupForm(edit=False, old_data={}, available_members=[]): |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
594 class _UsersGroupForm(formencode.Schema): |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
595 allow_extra_fields = True |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
596 filter_extra_fields = True |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
597 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
598 users_group_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
599 ValidUsersGroup(edit, old_data)) |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
600 |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
601 users_group_active = StringBoolean(if_missing=False) |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
602 |
972
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
603 if edit: |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
604 users_group_members = OneOf(available_members, hideList=False, |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
605 testValueList=True, |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
606 if_missing=None, not_empty=False) |
2c8fd84935a4
#56 implemented users groups editing,
Marcin Kuzminski <marcin@python-works.com>
parents:
962
diff
changeset
|
607 |
959
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
608 return _UsersGroupForm |
fff21c9b075c
#56 fixed found bugs, implemented adding of new group + forms+validators
Marcin Kuzminski <marcin@python-works.com>
parents:
891
diff
changeset
|
609 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
610 |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
611 def ReposGroupForm(edit=False, old_data={}, available_groups=[]): |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
612 class _ReposGroupForm(formencode.Schema): |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
613 allow_extra_fields = True |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
614 filter_extra_fields = False |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
615 |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
616 group_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
617 SlugifyName()) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
618 group_description = UnicodeString(strip=True, min=1, |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
619 not_empty=True) |
1347
43b8e161be3f
#47 implemented basic edition of groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1346
diff
changeset
|
620 group_parent_id = OneOf(available_groups, hideList=False, |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
621 testValueList=True, |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
622 if_missing=None, not_empty=False) |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
623 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
624 chained_validators = [ValidReposGroup(edit, old_data), ValidPerms('group')] |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
625 |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
626 return _ReposGroupForm |
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
627 |
1898
a7dfe823933a
added validation to repo groups to check for conflicting repository name fixes #337
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
628 |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
629 def RegisterForm(edit=False, old_data={}): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
630 class _RegisterForm(formencode.Schema): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
631 allow_extra_fields = True |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
632 filter_extra_fields = True |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
633 username = All(ValidUsername(edit, old_data), |
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
634 UnicodeString(strip=True, min=1, not_empty=True)) |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
635 password = All(UnicodeString(strip=True, min=6, not_empty=True)) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
636 password_confirmation = All(UnicodeString(strip=True, min=6, not_empty=True)) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
637 active = StringBoolean(if_missing=False) |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
638 name = UnicodeString(strip=True, min=1, not_empty=False) |
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
639 lastname = UnicodeString(strip=True, min=1, not_empty=False) |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
640 email = All(Email(not_empty=True), UniqSystemEmail(old_data)) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
641 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
642 chained_validators = [ValidPasswordsMatch, ValidPassword] |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
643 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
644 return _RegisterForm |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
645 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
646 |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
647 def PasswordResetForm(): |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
648 class _PasswordResetForm(formencode.Schema): |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
649 allow_extra_fields = True |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
650 filter_extra_fields = True |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
651 email = All(ValidSystemEmail(), Email(not_empty=True)) |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
652 return _PasswordResetForm |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
653 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
654 |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
655 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(), |
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
656 repo_groups=[]): |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
657 class _RepoForm(formencode.Schema): |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
658 allow_extra_fields = True |
296
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
659 filter_extra_fields = False |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
660 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
661 SlugifyName()) |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
662 clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False)) |
1159
187a924ed653
Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
663 repo_group = OneOf(repo_groups, hideList=True) |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
664 repo_type = OneOf(supported_backends) |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
665 description = UnicodeString(strip=True, min=1, not_empty=True) |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
666 private = StringBoolean(if_missing=False) |
810
bd57d1cb9dc3
fixes #62, added option to disable statistics for each repository
Marcin Kuzminski <marcin@python-works.com>
parents:
775
diff
changeset
|
667 enable_statistics = StringBoolean(if_missing=False) |
962
72f008ed9b18
implemented #84 downloads can be enabled/disabled per each repository from now.
Marcin Kuzminski <marcin@python-works.com>
parents:
960
diff
changeset
|
668 enable_downloads = StringBoolean(if_missing=False) |
1112
6d0a7284949d
#109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents:
1022
diff
changeset
|
669 |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
670 if edit: |
1014
6fdc3ff65fce
#56 added assignments of users groups into repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1013
diff
changeset
|
671 #this is repo owner |
1323
a7a772ea7b95
fixed saving settings on repositories inside groups, also fixes #187
Marcin Kuzminski <marcin@python-works.com>
parents:
1298
diff
changeset
|
672 user = All(UnicodeString(not_empty=True), ValidRepoUser) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
673 |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
674 chained_validators = [ValidCloneUri()(), |
2058
fb51a6fc10ae
updated CONTRIBUTORS
Marcin Kuzminski <marcin@python-works.com>
parents:
2053
diff
changeset
|
675 ValidRepoName(edit, old_data), |
2053
e121e10d4142
fixed issue with remote repos on git
Marcin Kuzminski <marcin@python-works.com>
parents:
2025
diff
changeset
|
676 ValidPerms()] |
265
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
677 return _RepoForm |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
678 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
679 |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
680 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(), |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
681 repo_groups=[]): |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
682 class _RepoForkForm(formencode.Schema): |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
683 allow_extra_fields = True |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
684 filter_extra_fields = False |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
685 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
686 SlugifyName()) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
687 repo_group = OneOf(repo_groups, hideList=True) |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
688 repo_type = All(ValidForkType(old_data), OneOf(supported_backends)) |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
689 description = UnicodeString(strip=True, min=1, not_empty=True) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
690 private = StringBoolean(if_missing=False) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
691 copy_permissions = StringBoolean(if_missing=False) |
1742
40c4f7351574
added option to do a checkout after cloning a repository
Marcin Kuzminski <marcin@python-works.com>
parents:
1735
diff
changeset
|
692 update_after_clone = StringBoolean(if_missing=False) |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
693 fork_parent_id = UnicodeString() |
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
694 chained_validators = [ValidForkName(edit, old_data)] |
1366
9c0f5d558789
fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents:
1364
diff
changeset
|
695 |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
696 return _RepoForkForm |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
697 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
698 |
1594 | 699 def RepoSettingsForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(), |
700 repo_groups=[]): | |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
701 class _RepoForm(formencode.Schema): |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
702 allow_extra_fields = True |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
703 filter_extra_fields = False |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
704 repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
1345
3bce31f026b8
#47 implemented Adding of new repo_groups+forms+validators. Fixed sorting of repo groups by main names in multiple locations. Removed some unneeded calls to self.sa for exchange to .query() methods.
Marcin Kuzminski <marcin@python-works.com>
parents:
1324
diff
changeset
|
705 SlugifyName()) |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
706 description = UnicodeString(strip=True, min=1, not_empty=True) |
1594 | 707 repo_group = OneOf(repo_groups, hideList=True) |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
708 private = StringBoolean(if_missing=False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
709 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
710 chained_validators = [ValidRepoName(edit, old_data), ValidPerms(), |
1594 | 711 ValidSettings] |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
712 return _RepoForm |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
713 |
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
714 |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
715 def ApplicationSettingsForm(): |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
716 class _ApplicationSettingsForm(formencode.Schema): |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
717 allow_extra_fields = True |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
718 filter_extra_fields = False |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
719 rhodecode_title = UnicodeString(strip=True, min=1, not_empty=True) |
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
720 rhodecode_realm = UnicodeString(strip=True, min=1, not_empty=True) |
891
cca7286401b3
fixes for #89 ga code
Marcin Kuzminski <marcin@python-works.com>
parents:
890
diff
changeset
|
721 rhodecode_ga_code = UnicodeString(strip=True, min=1, not_empty=False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
722 |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
723 return _ApplicationSettingsForm |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
724 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
725 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
726 def ApplicationUiSettingsForm(): |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
727 class _ApplicationUiSettingsForm(formencode.Schema): |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
728 allow_extra_fields = True |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
729 filter_extra_fields = False |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
730 web_push_ssl = OneOf(['true', 'false'], if_missing='false') |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
731 paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=1, not_empty=True)) |
395
e8af467b5a60
Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
388
diff
changeset
|
732 hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False) |
e8af467b5a60
Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents:
388
diff
changeset
|
733 hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False) |
661
673de12e6bf6
added option to enable/disable of logger hooks from admin panel.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
734 hooks_pretxnchangegroup_push_logger = OneOf(['True', 'False'], if_missing=False) |
673de12e6bf6
added option to enable/disable of logger hooks from admin panel.
Marcin Kuzminski <marcin@python-works.com>
parents:
659
diff
changeset
|
735 hooks_preoutgoing_pull_logger = OneOf(['True', 'False'], if_missing=False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
736 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
737 return _ApplicationUiSettingsForm |
320
05b212954275
Implemented owner settings, as separete posibility to edit repositry by non administrative owner of repository
Marcin Kuzminski <marcin@python-works.com>
parents:
310
diff
changeset
|
738 |
1950
4ae17f819ee8
#344 optional firstname lastname on user creation
Marcin Kuzminski <marcin@python-works.com>
parents:
1898
diff
changeset
|
739 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
740 def DefaultPermissionsForm(perms_choices, register_choices, create_choices): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
741 class _DefaultPermissionsForm(formencode.Schema): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
742 allow_extra_fields = True |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
743 filter_extra_fields = True |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
744 overwrite_default = StringBoolean(if_missing=False) |
673
dd532af216d9
#49 Enabled anonymous access for web interface controllable from permissions pannel
Marcin Kuzminski <marcin@python-works.com>
parents:
661
diff
changeset
|
745 anonymous = OneOf(['True', 'False'], if_missing=False) |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
746 default_perm = OneOf(perms_choices) |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
747 default_register = OneOf(register_choices) |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
748 default_create = OneOf(create_choices) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
749 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
750 return _DefaultPermissionsForm |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
751 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
752 |
1290
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1271
diff
changeset
|
753 def LdapSettingsForm(tls_reqcert_choices, search_scope_choices, tls_kind_choices): |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
754 class _LdapSettingsForm(formencode.Schema): |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
755 allow_extra_fields = True |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
756 filter_extra_fields = True |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
757 pre_validators = [LdapLibValidator] |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
758 ldap_active = StringBoolean(if_missing=False) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
759 ldap_host = UnicodeString(strip=True,) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
760 ldap_port = Number(strip=True,) |
1290
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1271
diff
changeset
|
761 ldap_tls_kind = OneOf(tls_kind_choices) |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
762 ldap_tls_reqcert = OneOf(tls_reqcert_choices) |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
763 ldap_dn_user = UnicodeString(strip=True,) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
764 ldap_dn_pass = UnicodeString(strip=True,) |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
765 ldap_base_dn = UnicodeString(strip=True,) |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
766 ldap_filter = UnicodeString(strip=True,) |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
767 ldap_search_scope = OneOf(search_scope_choices) |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
768 ldap_attr_login = All(AttrLoginValidator, UnicodeString(strip=True,)) |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
769 ldap_attr_firstname = UnicodeString(strip=True,) |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
770 ldap_attr_lastname = UnicodeString(strip=True,) |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
972
diff
changeset
|
771 ldap_attr_email = UnicodeString(strip=True,) |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
772 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
773 return _LdapSettingsForm |