Mercurial > kallithea
annotate rhodecode/controllers/admin/ldap_settings.py @ 2783:a93c07ade43a beta
Added huge diff protection for RSS/ATOM feeds.
It can really be a performance killer for huge diffs.
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 02 Sep 2012 23:29:07 +0200 |
parents | 91c442a489bb |
children | 63e58ef80ef1 a8f2d78d14ea |
rev | line source |
---|---|
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
3 rhodecode.controllers.admin.ldap_settings |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 ldap controller for RhodeCode |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
7 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: Nov 26, 2010 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
17 # |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
991
diff
changeset
|
22 # |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import logging |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import formencode |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 import traceback |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 from formencode import htmlfill |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 from pylons import request, response, session, tmpl_context as c, url |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from pylons.controllers.util import abort, redirect |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from pylons.i18n.translation import _ |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
35 from sqlalchemy.exc import DatabaseError |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
36 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 from rhodecode.lib.base import BaseController, render |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 from rhodecode.lib import helpers as h |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
40 from rhodecode.lib.exceptions import LdapImportError |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 from rhodecode.model.forms import LdapSettingsForm |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
42 from rhodecode.model.db import RhodeCodeSetting |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2193
diff
changeset
|
43 from rhodecode.model.meta import Session |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 log = logging.getLogger(__name__) |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 class LdapSettingsController(BaseController): |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
50 search_scope_choices = [('BASE', _('BASE'),), |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
51 ('ONELEVEL', _('ONELEVEL'),), |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
52 ('SUBTREE', _('SUBTREE'),), |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
53 ] |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
54 search_scope_default = 'SUBTREE' |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
55 |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
56 tls_reqcert_choices = [('NEVER', _('NEVER'),), |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
57 ('ALLOW', _('ALLOW'),), |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
58 ('TRY', _('TRY'),), |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
59 ('DEMAND', _('DEMAND'),), |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
60 ('HARD', _('HARD'),), |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
61 ] |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
62 tls_reqcert_default = 'DEMAND' |
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
63 |
1290
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
64 tls_kind_choices = [('PLAIN', _('No encryption'),), |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
65 ('LDAPS', _('LDAPS connection'),), |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
66 ('START_TLS', _('START_TLS on LDAP connection'),) |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
67 ] |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
68 |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
69 tls_kind_default = 'PLAIN' |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
70 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 @LoginRequired() |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 @HasPermissionAllDecorator('hg.admin') |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 def __before__(self): |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 c.admin_user = session.get('admin_user') |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 c.admin_username = session.get('admin_username') |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
76 c.search_scope_choices = self.search_scope_choices |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
77 c.tls_reqcert_choices = self.tls_reqcert_choices |
1290
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
78 c.tls_kind_choices = self.tls_kind_choices |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
79 |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
80 c.search_scope_cur = self.search_scope_default |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
81 c.tls_reqcert_cur = self.tls_reqcert_default |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
82 c.tls_kind_cur = self.tls_kind_default |
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
83 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 super(LdapSettingsController, self).__before__() |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 def index(self): |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
87 defaults = RhodeCodeSetting.get_ldap_settings() |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
88 c.search_scope_cur = defaults.get('ldap_search_scope') |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
89 c.tls_reqcert_cur = defaults.get('ldap_tls_reqcert') |
1290
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
90 c.tls_kind_cur = defaults.get('ldap_tls_kind') |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
92 return htmlfill.render( |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
93 render('admin/ldap/ldap.html'), |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
94 defaults=defaults, |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 encoding="UTF-8", |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
96 force_defaults=True,) |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 def ldap_settings(self): |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
772
diff
changeset
|
99 """POST ldap create and store ldap settings""" |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 |
991
b232a36cc51f
Improve LDAP authentication
Thayne Harbaugh <thayne@fusionio.com>
parents:
902
diff
changeset
|
101 _form = LdapSettingsForm([x[0] for x in self.tls_reqcert_choices], |
1290
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
102 [x[0] for x in self.search_scope_choices], |
74685a31cc43
Enable start_tls connection encryption.
"Lorenzo M. Catucci" <lorenzo@sancho.ccd.uniroma2.it>
parents:
1245
diff
changeset
|
103 [x[0] for x in self.tls_kind_choices])() |
2193
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
104 # check the ldap lib |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
105 ldap_active = False |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
106 try: |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
107 import ldap |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
108 ldap_active = True |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
109 except ImportError: |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
110 pass |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 try: |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 form_result = _form.to_python(dict(request.POST)) |
2193
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
114 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
115 try: |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 for k, v in form_result.items(): |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 if k.startswith('ldap_'): |
2193
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
119 if k == 'ldap_active': |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
120 v = ldap_active |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1307
diff
changeset
|
121 setting = RhodeCodeSetting.get_by_name(k) |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 setting.app_settings_value = v |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2193
diff
changeset
|
123 Session().add(setting) |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2193
diff
changeset
|
125 Session().commit() |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
126 h.flash(_('Ldap settings updated successfully'), |
2193
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
127 category='success') |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
128 if not ldap_active: |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
129 #if ldap is missing send an info to user |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
130 h.flash(_('Unable to activate ldap. The "python-ldap" library ' |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
131 'is missing.'), category='warning') |
3ea397063fc7
fixed #374 LDAP config is now saved but deactivated if python-ldap lib is missing
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
132 |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 except (DatabaseError,): |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
134 raise |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 except formencode.Invalid, errors: |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
137 e = errors.error_dict or {} |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 return htmlfill.render( |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
140 render('admin/ldap/ldap.html'), |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 defaults=errors.value, |
1292
c0335c1dee36
added some fixes to LDAP form re-submition, new simples ldap-settings getter.
Marcin Kuzminski <marcin@python-works.com>
parents:
1290
diff
changeset
|
142 errors=e, |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 prefix_error=False, |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
144 encoding="UTF-8") |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 except Exception: |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 log.error(traceback.format_exc()) |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
772
diff
changeset
|
147 h.flash(_('error occurred during update of ldap settings'), |
769
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 category='error') |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 |
4bdcc08b04c4
fixes #77 moved out ldap config to it's own section
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 return redirect(url('ldap_home')) |