Mercurial > kallithea
annotate rhodecode/model/forms.py @ 1232:0dc8d578ff49
merges for stable
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 09 Apr 2011 18:38:18 +0200 |
parents | 9a9946320435 |
children | bf263968da47 |
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. | |
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 | |
14 | |
15 | |
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()) |
0 | 20 |
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 |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
25 |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
26 import formencode |
242
5da4ef115006
Added lastlogin to user after login, model db update
Marcin Kuzminski <marcin@python-works.com>
parents:
238
diff
changeset
|
27 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
|
28 from formencode.validators import UnicodeString, OneOf, Int, Number, Regex, \ |
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
29 Email, Bool, StringBoolean |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
30 |
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
|
31 from pylons.i18n.translation import _ |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
32 |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
33 import rhodecode.lib.helpers as h |
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
34 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
|
35 from rhodecode.lib.exceptions import LdapImportError |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
530
diff
changeset
|
36 from rhodecode.model import meta |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
37 from rhodecode.model.user import UserModel |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
38 from rhodecode.model.repo import RepoModel |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
39 from rhodecode.model.db import User |
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 from webhelpers.pylonslib.secure_form import authentication_token |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
43 |
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
|
44 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
|
45 |
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 #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
|
47 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
|
48 _ = staticmethod(_) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
49 |
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
|
50 #=============================================================================== |
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 |
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
|
52 #=============================================================================== |
0 | 53 class ValidAuthToken(formencode.validators.FancyValidator): |
54 messages = {'invalid_token':_('Token mismatch')} | |
55 | |
56 def validate_python(self, value, state): | |
57 | |
58 if value != authentication_token(): | |
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
|
59 raise formencode.Invalid(self.message('invalid_token', state, |
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
|
60 search_number=value), value, state) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
61 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
62 def ValidUsername(edit, old_data): |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
63 class _ValidUsername(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
64 |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
65 def validate_python(self, value, state): |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
66 if value in ['default', 'new_user']: |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
67 raise formencode.Invalid(_('Invalid username'), value, state) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
68 #check if user is unique |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
69 old_un = None |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
70 if edit: |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
71 old_un = UserModel().get(old_data.get('user_id')).username |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
72 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
73 if old_un != value or not edit: |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
74 if UserModel().get_by_username(value, cache=False, |
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
75 case_insensitive=True): |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
76 raise formencode.Invalid(_('This username already exists') , |
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
77 value, state) |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
78 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
79 |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
810
diff
changeset
|
80 if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None: |
743
c9fa3f53143b
added validation of username alphanumeric+dash only
Marcin Kuzminski <marcin@python-works.com>
parents:
742
diff
changeset
|
81 raise formencode.Invalid(_('Username may only contain ' |
1057
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
810
diff
changeset
|
82 'alphanumeric characters underscores, ' |
af6ca51fb80f
rhodecode release 1.1.3 changes
Marcin Kuzminski <marcin@python-works.com>
parents:
810
diff
changeset
|
83 'periods or dashes and must begin with ' |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
84 'alphanumeric character'), |
743
c9fa3f53143b
added validation of username alphanumeric+dash only
Marcin Kuzminski <marcin@python-works.com>
parents:
742
diff
changeset
|
85 value, state) |
745
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
86 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
87 |
c366b237c91d
added test for username and email case senstitive validators,
Marcin Kuzminski <marcin@python-works.com>
parents:
743
diff
changeset
|
88 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
89 return _ValidUsername |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
90 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
91 class ValidPassword(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
92 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
93 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
|
94 |
347
40bccabf4574
fixed bug for user update, when password was always set.
Marcin Kuzminski <marcin@python-works.com>
parents:
329
diff
changeset
|
95 if value: |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
96 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
97 if value.get('password'): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
98 try: |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
99 value['password'] = get_crypt_password(value['password']) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
100 except UnicodeEncodeError: |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
101 e_dict = {'password':_('Invalid characters in password')} |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
102 raise formencode.Invalid('', value, state, error_dict=e_dict) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
103 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
104 if value.get('password_confirmation'): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
105 try: |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
106 value['password_confirmation'] = \ |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
107 get_crypt_password(value['password_confirmation']) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
108 except UnicodeEncodeError: |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
109 e_dict = {'password_confirmation':_('Invalid characters in password')} |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
110 raise formencode.Invalid('', value, state, error_dict=e_dict) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
111 |
728
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
112 if value.get('new_password'): |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
113 try: |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
114 value['new_password'] = \ |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
115 get_crypt_password(value['new_password']) |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
116 except UnicodeEncodeError: |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
117 e_dict = {'new_password':_('Invalid characters in password')} |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
118 raise formencode.Invalid('', value, state, error_dict=e_dict) |
f1629c0c28cc
fixed bug in forms found due to testing,
Marcin Kuzminski <marcin@python-works.com>
parents:
722
diff
changeset
|
119 |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
120 return value |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
121 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
122 class ValidPasswordsMatch(formencode.validators.FancyValidator): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
123 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
124 def validate_python(self, value, state): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
125 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
126 if value['password'] != value['password_confirmation']: |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
127 e_dict = {'password_confirmation': |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
128 _('Password do not match')} |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
129 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
|
130 |
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
|
131 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
|
132 messages = { |
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
|
133 'invalid_password':_('invalid password'), |
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
|
134 'invalid_login':_('invalid user name'), |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
135 'disabled_account':_('Your account is disabled') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
136 |
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
|
137 } |
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
|
138 #error mapping |
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
|
139 e_dict = {'username':messages['invalid_login'], |
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
|
140 'password':messages['invalid_password']} |
227
351013049742
CHanged form error when user account is disabled.
Marcin Kuzminski <marcin@python-works.com>
parents:
201
diff
changeset
|
141 e_dict_disable = {'username':messages['disabled_account']} |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
142 |
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
|
143 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
|
144 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
|
145 username = value['username'] |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
146 user = UserModel().get_by_username(username) |
699
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
147 |
761
56c2850a5b5f
ldap auth rewrite, moved split authfunc into two functions,
Marcin Kuzminski <marcin@python-works.com>
parents:
746
diff
changeset
|
148 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
|
149 return value |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
150 else: |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
151 if user and user.active is False: |
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
|
152 log.warning('user %s is disabled', username) |
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
|
153 raise formencode.Invalid(self.message('disabled_account', |
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
|
154 state=State_obj), |
227
351013049742
CHanged form error when user account is disabled.
Marcin Kuzminski <marcin@python-works.com>
parents:
201
diff
changeset
|
155 value, state, |
351013049742
CHanged form error when user account is disabled.
Marcin Kuzminski <marcin@python-works.com>
parents:
201
diff
changeset
|
156 error_dict=self.e_dict_disable) |
699
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
157 else: |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
158 log.warning('user %s not authenticated', username) |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
159 raise formencode.Invalid(self.message('invalid_password', |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
160 state=State_obj), value, state, |
52da7cba88a6
Code refactor for auth func, preparing for ldap support
Marcin Kuzminski <marcin@python-works.com>
parents:
673
diff
changeset
|
161 error_dict=self.e_dict) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
162 |
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
|
163 class ValidRepoUser(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
164 |
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
|
165 def to_python(self, value, state): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
166 sa = meta.Session() |
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
|
167 try: |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
168 self.user_db = sa.query(User)\ |
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
|
169 .filter(User.active == True)\ |
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
|
170 .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
|
171 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
|
172 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
|
173 value, state) |
442
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
418
diff
changeset
|
174 finally: |
d66a7fa7689b
moved loged in user propagation out of forms,
Marcin Kuzminski <marcin@python-works.com>
parents:
418
diff
changeset
|
175 meta.Session.remove() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
176 |
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
|
177 return self.user_db.user_id |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
178 |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
179 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
|
180 class _ValidRepoName(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
181 |
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
|
182 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
|
183 slug = h.repo_name_slug(value) |
310
fc4027fe46bc
fixed bug when user is capable of creating _admin repository which is a link to admin interface
Marcin Kuzminski <marcin@python-works.com>
parents:
299
diff
changeset
|
184 if slug in ['_admin']: |
fc4027fe46bc
fixed bug when user is capable of creating _admin repository which is a link to admin interface
Marcin Kuzminski <marcin@python-works.com>
parents:
299
diff
changeset
|
185 raise formencode.Invalid(_('This repository name is disallowed'), |
fc4027fe46bc
fixed bug when user is capable of creating _admin repository which is a link to admin interface
Marcin Kuzminski <marcin@python-works.com>
parents:
299
diff
changeset
|
186 value, state) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
187 if old_data.get('repo_name') != value or not edit: |
735
dbec976d9975
added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents:
728
diff
changeset
|
188 if RepoModel().get_by_repo_name(slug, cache=False): |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
355
diff
changeset
|
189 raise formencode.Invalid(_('This repository already exists') , |
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
355
diff
changeset
|
190 value, state) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
191 return slug |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
192 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
193 |
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
|
194 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
|
195 |
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
|
196 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
|
197 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
|
198 |
758f64f3fbda
extended repo creation by repo type. fixed fork creation to maintain repo type.
Marcin Kuzminski <marcin@python-works.com>
parents:
631
diff
changeset
|
199 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
|
200 if old_data['repo_type'] != value: |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
201 raise formencode.Invalid(_('Fork have to be the same type as original'), |
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
202 value, state) |
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
|
203 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
|
204 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
|
205 |
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
|
206 class ValidPerms(formencode.validators.FancyValidator): |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
207 messages = {'perm_new_user_name':_('This username is not valid')} |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
208 |
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
|
209 def to_python(self, value, state): |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
210 perms_update = [] |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
211 perms_new = [] |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
212 #build a list of permission to update and new permission to create |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
213 for k, v in value.items(): |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
214 if k.startswith('perm_'): |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
215 if k.startswith('perm_new_user'): |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
216 new_perm = value.get('perm_new_user', False) |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
217 new_user = value.get('perm_new_user_name', False) |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
218 if new_user and new_perm: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
219 if (new_user, new_perm) not in perms_new: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
220 perms_new.append((new_user, new_perm)) |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
221 else: |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
222 usr = k[5:] |
299
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
223 if usr == 'default': |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
224 if value['private']: |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
225 #set none for default when updating to private repo |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
226 v = 'repository.none' |
d303aacb3349
repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents:
296
diff
changeset
|
227 perms_update.append((usr, v)) |
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
|
228 value['perms_updates'] = perms_update |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
229 value['perms_new'] = perms_new |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
230 sa = meta.Session |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
231 for k, v in perms_new: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
232 try: |
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
|
233 self.user_db = sa.query(User)\ |
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
|
234 .filter(User.active == True)\ |
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
|
235 .filter(User.username == k).one() |
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
|
236 except Exception: |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
237 msg = self.message('perm_new_user_name', |
29370bb76fa6
first permissions commit: added permission managment on repository edit. Changed db rmissions, validators.
Marcin Kuzminski <marcin@python-works.com>
parents:
265
diff
changeset
|
238 state=State_obj) |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
239 raise formencode.Invalid(msg, value, state, |
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
240 error_dict={'perm_new_user_name':msg}) |
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
|
241 return value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
242 |
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
|
243 class ValidSettings(formencode.validators.FancyValidator): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
244 |
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
|
245 def to_python(self, value, state): |
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
|
246 #settings form can't edit user |
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
|
247 if value.has_key('user'): |
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
|
248 del['value']['user'] |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
249 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
250 return value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
251 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
252 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
|
253 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
|
254 |
05528ad948c4
Hacking for git support,and new faster repo scan
Marcin Kuzminski <marcin@python-works.com>
parents:
629
diff
changeset
|
255 if not os.path.isdir(value): |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
256 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
|
257 raise formencode.Invalid(msg, value, state, |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
258 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
|
259 return value |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
260 |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
261 def UniqSystemEmail(old_data): |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
262 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
|
263 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
|
264 value = value.lower() |
490
74b9bed279ae
fixed validation of user email in user creation, and editing on admin panel
Marcin Kuzminski <marcin@python-works.com>
parents:
489
diff
changeset
|
265 if old_data.get('email') != value: |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
266 sa = meta.Session() |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
267 try: |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
268 user = sa.query(User).filter(User.email == value).scalar() |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
269 if user: |
746
18a3ca35d501
fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents:
745
diff
changeset
|
270 raise formencode.Invalid(_("This e-mail address is already taken") , |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
271 value, state) |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
272 finally: |
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
273 meta.Session.remove() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
274 |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
275 return value |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
276 |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
277 return _UniqSystemEmail |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
278 |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
279 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
|
280 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
|
281 value = value.lower() |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
282 sa = meta.Session |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
283 try: |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
284 user = sa.query(User).filter(User.email == value).scalar() |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
285 if user is None: |
746
18a3ca35d501
fixed grammar in taken email error
Marcin Kuzminski <marcin@python-works.com>
parents:
745
diff
changeset
|
286 raise formencode.Invalid(_("This e-mail address doesn't exist.") , |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
287 value, state) |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
288 finally: |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
289 meta.Session.remove() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
290 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
291 return value |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
292 |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
293 class LdapLibValidator(formencode.validators.FancyValidator): |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
294 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
295 def to_python(self, value, state): |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
296 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
297 try: |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
298 import ldap |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
299 except ImportError: |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
300 raise LdapImportError |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
301 return value |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
302 |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
303 def BaseDnValidator(ldap_enable): |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
304 class _BaseDnValidator(formencode.validators.FancyValidator): |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
305 |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
306 def to_python(self, value, state): |
775
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
307 |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
308 if not ldap_enable: |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
309 return '' |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
310 try: |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
311 value % {'user':'valid'} |
775
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
312 |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
313 if value.find('%(user)s') == -1: |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
314 raise formencode.Invalid(_("You need to specify %(user)s in " |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
315 "template for example uid=%(user)s " |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
316 ",dc=company...") , |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
317 value, state) |
775
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
318 |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
319 except KeyError: |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
320 raise formencode.Invalid(_("Wrong template used, only %(user)s " |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
321 "is an valid entry") , |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
322 value, state) |
775
aaf2fc59a39a
fixes #77 and adds extendable base Dn with custom uid specification
Marcin Kuzminski <marcin@python-works.com>
parents:
761
diff
changeset
|
323 |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
324 return value |
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
325 return _BaseDnValidator |
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
|
326 #=============================================================================== |
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
|
327 # FORMS |
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
|
328 #=============================================================================== |
45 | 329 class LoginForm(formencode.Schema): |
330 allow_extra_fields = True | |
331 filter_extra_fields = True | |
332 username = UnicodeString( | |
333 strip=True, | |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
334 min=1, |
45 | 335 not_empty=True, |
336 messages={ | |
337 'empty':_('Please enter a login'), | |
338 'tooShort':_('Enter a value %(min)i characters long or more')} | |
339 ) | |
0 | 340 |
45 | 341 password = UnicodeString( |
342 strip=True, | |
529
3a567e329fb6
updated whoosh deps,
Marcin Kuzminski <marcin@python-works.com>
parents:
527
diff
changeset
|
343 min=6, |
45 | 344 not_empty=True, |
345 messages={ | |
346 'empty':_('Please enter a password'), | |
555
03676d39dd0a
added fault tolerant case when celeryconfig is not present in the directory.
Marcin Kuzminski <marcin@python-works.com>
parents:
548
diff
changeset
|
347 'tooShort':_('Enter %(min)i characters or more')} |
45 | 348 ) |
0 | 349 |
350 | |
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
|
351 #chained validators have access to all data |
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
|
352 chained_validators = [ValidAuth] |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
353 |
357
ebdd1a89cdd9
Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
356
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 filter_extra_fields = True |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
358 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
|
359 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
|
360 if edit: |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
361 new_password = All(UnicodeString(strip=True, min=6, not_empty=False)) |
329
aafd9a98ea58
added admin flag to users editing
Marcin Kuzminski <marcin@python-works.com>
parents:
328
diff
changeset
|
362 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
|
363 else: |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
364 password = All(UnicodeString(strip=True, min=6, not_empty=True)) |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
365 active = StringBoolean(if_missing=False) |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
366 name = UnicodeString(strip=True, min=1, not_empty=True) |
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
367 lastname = UnicodeString(strip=True, min=1, not_empty=True) |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
475
diff
changeset
|
368 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
|
369 |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
370 chained_validators = [ValidPassword] |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
371 |
238
a55c17874486
Rewrite of user managment, improved forms, added some user info
Marcin Kuzminski <marcin@python-works.com>
parents:
234
diff
changeset
|
372 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
|
373 |
722
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
374 def RegisterForm(edit=False, old_data={}): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
375 class _RegisterForm(formencode.Schema): |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
376 allow_extra_fields = True |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
377 filter_extra_fields = True |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
378 username = All(ValidUsername(edit, old_data), |
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 active = StringBoolean(if_missing=False) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
383 name = UnicodeString(strip=True, min=1, not_empty=True) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
384 lastname = UnicodeString(strip=True, min=1, not_empty=True) |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
385 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
|
386 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
387 chained_validators = [ValidPasswordsMatch, ValidPassword] |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
388 |
02bdf2f296ff
fixes #69 password confirmation for register dialog.
Marcin Kuzminski <marcin@python-works.com>
parents:
710
diff
changeset
|
389 return _RegisterForm |
474
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
390 |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
391 def PasswordResetForm(): |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
392 class _PasswordResetForm(formencode.Schema): |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
393 allow_extra_fields = True |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
394 filter_extra_fields = True |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
395 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
|
396 return _PasswordResetForm |
a3d9d24acbec
Implemented password reset(forms/models/ tasks) and mailing tasks.
Marcin Kuzminski <marcin@python-works.com>
parents:
458
diff
changeset
|
397 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
398 def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()): |
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
|
399 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
|
400 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
|
401 filter_extra_fields = False |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
402 repo_name = 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
|
403 ValidRepoName(edit, old_data)) |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
404 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
|
405 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
|
406 enable_statistics = StringBoolean(if_missing=False) |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
407 repo_type = OneOf(supported_backends) |
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
|
408 if edit: |
0e5455fda8fd
Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents:
242
diff
changeset
|
409 user = All(Int(not_empty=True), ValidRepoUser) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
410 |
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
|
411 chained_validators = [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
|
412 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
|
413 |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
414 def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()): |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
415 class _RepoForkForm(formencode.Schema): |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
416 allow_extra_fields = True |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
417 filter_extra_fields = False |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
418 fork_name = 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
|
419 ValidRepoName(edit, old_data)) |
530
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
420 description = UnicodeString(strip=True, min=1, not_empty=True) |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
421 private = StringBoolean(if_missing=False) |
710
e2f3c8e6939d
Disable git support due to large problems with dulwich.
Marcin Kuzminski <marcin@python-works.com>
parents:
705
diff
changeset
|
422 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
|
423 return _RepoForkForm |
a08f610e545e
Implemented server side forks
Marcin Kuzminski <marcin@python-works.com>
parents:
529
diff
changeset
|
424 |
356
b0715a788432
Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents:
355
diff
changeset
|
425 def RepoSettingsForm(edit=False, old_data={}): |
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
|
426 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
|
427 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
|
428 filter_extra_fields = False |
742
1377a9d4bdb9
#78, fixed more reliable case insensitive searches
Marcin Kuzminski <marcin@python-works.com>
parents:
741
diff
changeset
|
429 repo_name = 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
|
430 ValidRepoName(edit, old_data)) |
527
6d44d3862ec4
fixes #36, removed username, name, lastname, minimal length restrictions,
Marcin Kuzminski <marcin@python-works.com>
parents:
490
diff
changeset
|
431 description = UnicodeString(strip=True, min=1, not_empty=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
|
432 private = StringBoolean(if_missing=False) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
433 |
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
|
434 chained_validators = [ValidPerms, ValidSettings] |
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
|
435 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
|
436 |
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
|
437 |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
438 def ApplicationSettingsForm(): |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
439 class _ApplicationSettingsForm(formencode.Schema): |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
440 allow_extra_fields = True |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
441 filter_extra_fields = False |
548
b75b77ef649d
renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
442 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
|
443 rhodecode_realm = UnicodeString(strip=True, min=1, not_empty=True) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
444 |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
347
diff
changeset
|
445 return _ApplicationSettingsForm |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
446 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
447 def ApplicationUiSettingsForm(): |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
448 class _ApplicationUiSettingsForm(formencode.Schema): |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
449 allow_extra_fields = True |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
450 filter_extra_fields = False |
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 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
|
457 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
458 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
|
459 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
460 def DefaultPermissionsForm(perms_choices, register_choices, create_choices): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
461 class _DefaultPermissionsForm(formencode.Schema): |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
462 allow_extra_fields = True |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
463 filter_extra_fields = True |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
464 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
|
465 anonymous = OneOf(['True', 'False'], if_missing=False) |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
466 default_perm = OneOf(perms_choices) |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
467 default_register = OneOf(register_choices) |
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
468 default_create = OneOf(create_choices) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
555
diff
changeset
|
469 |
417
3ed2d46a2ca7
permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents:
416
diff
changeset
|
470 return _DefaultPermissionsForm |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
471 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
472 |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
473 def LdapSettingsForm(ldap_enable): |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
474 class _LdapSettingsForm(formencode.Schema): |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
475 allow_extra_fields = True |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
476 filter_extra_fields = True |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
477 pre_validators = [LdapLibValidator] |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
478 ldap_active = StringBoolean(if_missing=False) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
479 ldap_host = UnicodeString(strip=True,) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
480 ldap_port = Number(strip=True,) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
481 ldap_ldaps = StringBoolean(if_missing=False) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
482 ldap_dn_user = UnicodeString(strip=True,) |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
483 ldap_dn_pass = UnicodeString(strip=True,) |
1145
9a9946320435
fixed ldap form, it doesn't validate the baseDN until enable checkbox is set
Marcin Kuzminski <marcin@python-works.com>
parents:
1057
diff
changeset
|
484 ldap_base_dn = All(BaseDnValidator(ldap_enable), UnicodeString(strip=True,)) |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
485 |
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
699
diff
changeset
|
486 return _LdapSettingsForm |