Mercurial > kallithea
annotate rhodecode/controllers/admin/settings.py @ 3598:7d774f09dba5 beta
pullrequests: only create special select entry for a changeset if it has no symbolic name
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 26 Mar 2013 01:23:35 +0100 |
parents | 8173b0cfe9bd |
children | 802c94bdfc85 |
rev | line source |
---|---|
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
1 # -*- coding: utf-8 -*- |
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
2 """ |
860
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
832
diff
changeset
|
3 rhodecode.controllers.admin.settings |
5f7731e3ab4d
fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents:
832
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1164
diff
changeset
|
5 |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
6 settings controller for rhodecode admin |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1164
diff
changeset
|
7 |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
8 :created_on: Jul 14, 2010 |
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1798
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
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:
1164
diff
changeset
|
17 # |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
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:
1164
diff
changeset
|
22 # |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
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/>. |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
25 |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
26 import logging |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
27 import traceback |
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
28 import formencode |
2192
a801c4542f48
added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2086
diff
changeset
|
29 import pkg_resources |
a801c4542f48
added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2086
diff
changeset
|
30 import platform |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
31 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
32 from sqlalchemy import func |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from formencode import htmlfill |
1036
405b80e4ccd5
Major refactoring, removed when possible calls to app globals.
Marcin Kuzminski <marcin@python-works.com>
parents:
1027
diff
changeset
|
34 from pylons import request, session, tmpl_context as c, url, config |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 from pylons.controllers.util import abort, redirect |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 from pylons.i18n.translation import _ |
890
042d38683d42
implemented #89 google analytics code
Marcin Kuzminski <marcin@python-works.com>
parents:
860
diff
changeset
|
37 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
38 from rhodecode.lib import helpers as h |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
39 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
40 HasPermissionAnyDecorator, NotAnonymous, HasPermissionAny,\ |
3455
d5ae996eed11
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
Marcin Kuzminski <marcin@python-works.com>
parents:
3404
diff
changeset
|
41 HasReposGroupPermissionAll, HasReposGroupPermissionAny, AuthUser |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
42 from rhodecode.lib.base import BaseController, render |
705
9e9f1b919c0c
implements #60, ldap configuration and authentication.
Marcin Kuzminski <marcin@python-works.com>
parents:
692
diff
changeset
|
43 from rhodecode.lib.celerylib import tasks, run_task |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
44 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \ |
2890
84414d73c233
Add git version detection to warn users that Git used in system is to old. ref #588
Marcin Kuzminski <marcin@python-works.com>
parents:
2844
diff
changeset
|
45 set_rhodecode_config, repo_name_slug, check_git_version |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
46 from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \ |
2625
fc19979a8421
Added views for new ajax functions, got somehow lost in previos commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2544
diff
changeset
|
47 RhodeCodeSetting, PullRequest, PullRequestReviewers |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
537
diff
changeset
|
48 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \ |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
49 ApplicationUiSettingsForm, ApplicationVisualisationForm |
3239
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3233
diff
changeset
|
50 from rhodecode.model.scm import ScmModel, GroupList |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
51 from rhodecode.model.user import UserModel |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3145
diff
changeset
|
52 from rhodecode.model.repo import RepoModel |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1460
diff
changeset
|
53 from rhodecode.model.db import User |
1718
f78bee8eec78
reduce cookie size for better support of client side sessions
Marcin Kuzminski <marcin@python-works.com>
parents:
1717
diff
changeset
|
54 from rhodecode.model.notification import EmailNotificationModel |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1718
diff
changeset
|
55 from rhodecode.model.meta import Session |
3145
bee09f317edc
nicer representation of list of rescanned repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3142
diff
changeset
|
56 from rhodecode.lib.utils2 import str2bool, safe_unicode |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3145
diff
changeset
|
57 from rhodecode.lib.compat import json |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
58 from webob.exc import HTTPForbidden |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 log = logging.getLogger(__name__) |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 class SettingsController(BaseController): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 """REST Controller styled on the Atom Publishing Protocol""" |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 # To properly map this controller, ensure your config/routing.py |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 # file has a resource setup: |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1164
diff
changeset
|
66 # map.resource('setting', 'settings', controller='admin/settings', |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 # path_prefix='/admin', name_prefix='admin_') |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 @LoginRequired() |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 def __before__(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 c.admin_user = session.get('admin_user') |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 c.admin_username = session.get('admin_username') |
2207
17ff5693566b
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2192
diff
changeset
|
73 c.modules = sorted([(p.project_name, p.version) |
2890
84414d73c233
Add git version detection to warn users that Git used in system is to old. ref #588
Marcin Kuzminski <marcin@python-works.com>
parents:
2844
diff
changeset
|
74 for p in pkg_resources.working_set] |
84414d73c233
Add git version detection to warn users that Git used in system is to old. ref #588
Marcin Kuzminski <marcin@python-works.com>
parents:
2844
diff
changeset
|
75 + [('git', check_git_version())], |
2223
528f987f2459
fix ordering of system packages info
Marcin Kuzminski <marcin@python-works.com>
parents:
2207
diff
changeset
|
76 key=lambda k: k[0].lower()) |
2192
a801c4542f48
added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2086
diff
changeset
|
77 c.py_version = platform.python_version() |
2207
17ff5693566b
white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents:
2192
diff
changeset
|
78 c.platform = platform.platform() |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 super(SettingsController, self).__before__() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
80 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
81 @HasPermissionAllDecorator('hg.admin') |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 def index(self, format='html'): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 """GET /admin/settings: All items in the collection""" |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 # url('admin_settings') |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
85 |
1633
2c0d35e336b5
refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents:
1547
diff
changeset
|
86 defaults = RhodeCodeSetting.get_app_settings() |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
87 defaults.update(self._get_hg_ui_settings()) |
2192
a801c4542f48
added useful system info + packages to settings page.
Marcin Kuzminski <marcin@python-works.com>
parents:
2086
diff
changeset
|
88 |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
89 return htmlfill.render( |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
90 render('admin/settings/settings.html'), |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
91 defaults=defaults, |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
92 encoding="UTF-8", |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
93 force_defaults=False |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
94 ) |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
95 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
96 @HasPermissionAllDecorator('hg.admin') |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 def create(self): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 """POST /admin/settings: Create a new item""" |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 # url('admin_settings') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
100 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
101 @HasPermissionAllDecorator('hg.admin') |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 def new(self, format='html'): |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 """GET /admin/settings/new: Form to create a new item""" |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 # url('admin_new_setting') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
105 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
106 @HasPermissionAllDecorator('hg.admin') |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
107 def update(self, setting_id): |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
108 """PUT /admin/settings/setting_id: Update an existing item""" |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 # Forms posted to this method should contain a hidden field: |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 # <input type="hidden" name="_method" value="PUT" /> |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 # Or using helpers: |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
112 # h.form(url('admin_setting', setting_id=ID), |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 # method='put') |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
114 # url('admin_setting', setting_id=ID) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
115 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
116 if setting_id == 'mapping': |
348
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
117 rm_obsolete = request.POST.get('destroy', False) |
1976 | 118 log.debug('Rescanning directories with destroy=%s' % rm_obsolete) |
1036
405b80e4ccd5
Major refactoring, removed when possible calls to app globals.
Marcin Kuzminski <marcin@python-works.com>
parents:
1027
diff
changeset
|
119 initial = ScmModel().repo_scan() |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1036
diff
changeset
|
120 log.debug('invalidating all repositories') |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
661
diff
changeset
|
121 for repo_name in initial.keys(): |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
661
diff
changeset
|
122 invalidate_cache('get_repo_cached_%s' % repo_name) |
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
661
diff
changeset
|
123 |
1039
51b70569c330
extended admin rescan to show what repositories was added and what removed
Marcin Kuzminski <marcin@python-works.com>
parents:
1036
diff
changeset
|
124 added, removed = repo2db_mapper(initial, rm_obsolete) |
3145
bee09f317edc
nicer representation of list of rescanned repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3142
diff
changeset
|
125 _repr = lambda l: ', '.join(map(safe_unicode, l)) or '-' |
bee09f317edc
nicer representation of list of rescanned repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3142
diff
changeset
|
126 h.flash(_('Repositories successfully ' |
bee09f317edc
nicer representation of list of rescanned repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3142
diff
changeset
|
127 'rescanned added: %s ; removed: %s') % |
bee09f317edc
nicer representation of list of rescanned repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
3142
diff
changeset
|
128 (_repr(added), _repr(removed)), |
3142
1e7839c0930a
admin settings: show numbers in rescan flash message instead of python lists
Mads Kiilerich <madski@unity3d.com>
parents:
3140
diff
changeset
|
129 category='success') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
130 |
467
3fc3ce53659b
starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents:
446
diff
changeset
|
131 if setting_id == 'whoosh': |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
132 repo_location = self._get_hg_ui_settings()['paths_root_path'] |
489
460ad816820d
fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents:
473
diff
changeset
|
133 full_index = request.POST.get('full_index', False) |
1164 | 134 run_task(tasks.whoosh_index, repo_location, full_index) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
135 h.flash(_('Whoosh reindex task scheduled'), category='success') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
136 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
137 if setting_id == 'global': |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
138 |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
139 application_form = ApplicationSettingsForm()() |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
140 try: |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
141 form_result = application_form.to_python(dict(request.POST)) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
142 except formencode.Invalid, errors: |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
143 return htmlfill.render( |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
144 render('admin/settings/settings.html'), |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
145 defaults=errors.value, |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
146 errors=errors.error_dict or {}, |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
147 prefix_error=False, |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
148 encoding="UTF-8" |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
149 ) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
150 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
151 try: |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
152 sett1 = RhodeCodeSetting.get_by_name_or_create('title') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
153 sett1.app_settings_value = form_result['rhodecode_title'] |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
154 Session().add(sett1) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
155 |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
156 sett2 = RhodeCodeSetting.get_by_name_or_create('realm') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
157 sett2.app_settings_value = form_result['rhodecode_realm'] |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
158 Session().add(sett2) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
159 |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
160 sett3 = RhodeCodeSetting.get_by_name_or_create('ga_code') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
161 sett3.app_settings_value = form_result['rhodecode_ga_code'] |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
162 Session().add(sett3) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
163 |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
164 Session().commit() |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
165 set_rhodecode_config(config) |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
166 h.flash(_('Updated application settings'), category='success') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
167 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
168 except Exception: |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
169 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3455
diff
changeset
|
170 h.flash(_('Error occurred during updating ' |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
171 'application settings'), |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
172 category='error') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
173 |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
174 if setting_id == 'visual': |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
175 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
176 application_form = ApplicationVisualisationForm()() |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
177 try: |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
178 form_result = application_form.to_python(dict(request.POST)) |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
179 except formencode.Invalid, errors: |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
180 return htmlfill.render( |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
181 render('admin/settings/settings.html'), |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
182 defaults=errors.value, |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
183 errors=errors.error_dict or {}, |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
184 prefix_error=False, |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
185 encoding="UTF-8" |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
186 ) |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
187 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
188 try: |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
189 sett1 = RhodeCodeSetting.get_by_name_or_create('show_public_icon') |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
190 sett1.app_settings_value = \ |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
191 form_result['rhodecode_show_public_icon'] |
2936
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
192 Session().add(sett1) |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
193 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
194 sett2 = RhodeCodeSetting.get_by_name_or_create('show_private_icon') |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
195 sett2.app_settings_value = \ |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
196 form_result['rhodecode_show_private_icon'] |
2936
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
197 Session().add(sett2) |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
198 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
199 sett3 = RhodeCodeSetting.get_by_name_or_create('stylify_metatags') |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
200 sett3.app_settings_value = \ |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
201 form_result['rhodecode_stylify_metatags'] |
2936
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
202 Session().add(sett3) |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
203 |
2936
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
204 sett4 = RhodeCodeSetting.get_by_name_or_create('lightweight_dashboard') |
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
205 sett4.app_settings_value = \ |
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
206 form_result['rhodecode_lightweight_dashboard'] |
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
207 Session().add(sett4) |
62e493c7f436
Added lightweight dashboard option. ref #500
Marcin Kuzminski <marcin@python-works.com>
parents:
2890
diff
changeset
|
208 |
3308
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
209 sett4 = RhodeCodeSetting.get_by_name_or_create('repository_fields') |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
210 sett4.app_settings_value = \ |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
211 form_result['rhodecode_repository_fields'] |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
212 Session().add(sett4) |
72a91632b731
repository extra fields implementation
Marcin Kuzminski <marcin@python-works.com>
parents:
3239
diff
changeset
|
213 |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
214 Session().commit() |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
215 set_rhodecode_config(config) |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
216 h.flash(_('Updated visualisation settings'), |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
217 category='success') |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
218 |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
219 except Exception: |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
220 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3455
diff
changeset
|
221 h.flash(_('Error occurred during updating ' |
2674
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
222 'visualisation settings'), |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
223 category='error') |
a221706dab50
merged + fixed pull request #62: Implemented metatags and visualisation options.
Marcin Kuzminski <marcin@python-works.com>
parents:
2662
diff
changeset
|
224 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
225 if setting_id == 'vcs': |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
226 application_form = ApplicationUiSettingsForm()() |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
227 try: |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
228 form_result = application_form.to_python(dict(request.POST)) |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
229 except formencode.Invalid, errors: |
350
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
230 return htmlfill.render( |
664a5b8c551a
Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents:
348
diff
changeset
|
231 render('admin/settings/settings.html'), |
359
339d1368c10d
new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
232 defaults=errors.value, |
339d1368c10d
new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
233 errors=errors.error_dict or {}, |
339d1368c10d
new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents:
350
diff
changeset
|
234 prefix_error=False, |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
235 encoding="UTF-8" |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
236 ) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
237 |
388
3bcf9529d221
Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents:
381
diff
changeset
|
238 try: |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
239 sett = RhodeCodeUi.get_by_key('push_ssl') |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
240 sett.ui_value = form_result['web_push_ssl'] |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
241 Session().add(sett) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
242 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
243 sett = RhodeCodeUi.get_by_key('/') |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
244 sett.ui_value = form_result['paths_root_path'] |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
245 Session().add(sett) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
246 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
247 #HOOKS |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
248 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE) |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
249 sett.ui_active = form_result['hooks_changegroup_update'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
250 Session().add(sett) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
251 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
252 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_REPO_SIZE) |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
253 sett.ui_active = form_result['hooks_changegroup_repo_size'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
254 Session().add(sett) |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
255 |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
256 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PUSH) |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
257 sett.ui_active = form_result['hooks_changegroup_push_logger'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
258 Session().add(sett) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
259 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
260 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PULL) |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
261 sett.ui_active = form_result['hooks_outgoing_pull_logger'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
262 |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
263 Session().add(sett) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
264 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
265 ## EXTENSIONS |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
266 sett = RhodeCodeUi.get_by_key('largefiles') |
2844
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
267 if not sett: |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
268 #make one if it's not there ! |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
269 sett = RhodeCodeUi() |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
270 sett.ui_key = 'largefiles' |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
271 sett.ui_section = 'extensions' |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
272 sett.ui_active = form_result['extensions_largefiles'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
273 Session().add(sett) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
274 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
275 sett = RhodeCodeUi.get_by_key('hgsubversion') |
2844
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
276 if not sett: |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
277 #make one if it's not there ! |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
278 sett = RhodeCodeUi() |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
279 sett.ui_key = 'hgsubversion' |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
280 sett.ui_section = 'extensions' |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
281 |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
282 sett.ui_active = form_result['extensions_hgsubversion'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
283 Session().add(sett) |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
284 |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
285 # sett = RhodeCodeUi.get_by_key('hggit') |
2844
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
286 # if not sett: |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
287 # #make one if it's not there ! |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
288 # sett = RhodeCodeUi() |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
289 # sett.ui_key = 'hggit' |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
290 # sett.ui_section = 'extensions' |
7b0f803229be
autofix largefiles hggit hgsubversion options if they are not in the database
Marcin Kuzminski <marcin@python-works.com>
parents:
2835
diff
changeset
|
291 # |
3570
8173b0cfe9bd
settings: simplify handling of form values for hooks and extensions
Mads Kiilerich <madski@unity3d.com>
parents:
3565
diff
changeset
|
292 # sett.ui_active = form_result['extensions_hggit'] |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
293 # Session().add(sett) |
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
294 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
295 Session().commit() |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
296 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
297 h.flash(_('Updated VCS settings'), category='success') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
298 |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
299 except Exception: |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
300 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3455
diff
changeset
|
301 h.flash(_('Error occurred during updating ' |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
302 'application settings'), category='error') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
303 |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
304 if setting_id == 'hooks': |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
305 ui_key = request.POST.get('new_hook_ui_key') |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
306 ui_value = request.POST.get('new_hook_ui_value') |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
307 try: |
1673
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
308 |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
309 if ui_value and ui_key: |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
310 RhodeCodeUi.create_or_update_hook(ui_key, ui_value) |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
311 h.flash(_('Added new hook'), |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
312 category='success') |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
313 |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
314 # check for edits |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
315 update = False |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
316 _d = request.POST.dict_of_lists() |
1798
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
317 for k, v in zip(_d.get('hook_ui_key', []), |
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
318 _d.get('hook_ui_value_new', [])): |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
319 RhodeCodeUi.create_or_update_hook(k, v) |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
320 update = True |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
321 |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
322 if update: |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
323 h.flash(_('Updated hooks'), category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
324 Session().commit() |
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
325 except Exception: |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
326 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3455
diff
changeset
|
327 h.flash(_('Error occurred during hook creation'), |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
328 category='error') |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
329 |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
330 return redirect(url('admin_edit_setting', setting_id='hooks')) |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
331 |
1673
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
332 if setting_id == 'email': |
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
333 test_email = request.POST.get('test_email') |
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
334 test_email_subj = 'RhodeCode TestEmail' |
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
335 test_email_body = 'RhodeCode Email test' |
1798
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
336 |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
337 test_email_html_body = EmailNotificationModel()\ |
1798
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
338 .get_email_tmpl(EmailNotificationModel.TYPE_DEFAULT, |
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
339 body=test_email_body) |
1673
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
340 |
3140
105a0374faa1
admin, email test: fix test for test_email recipients
Mads Kiilerich <madski@unity3d.com>
parents:
3056
diff
changeset
|
341 recipients = [test_email] if test_email else None |
1798
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
342 |
2ee93fba129e
fixes testing email in settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
343 run_task(tasks.send_email, recipients, test_email_subj, |
1717
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
344 test_email_body, test_email_html_body) |
7ff304d3028f
Notification fixes
Marcin Kuzminski <marcin@python-works.com>
parents:
1712
diff
changeset
|
345 |
1673
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
346 h.flash(_('Email task created'), category='success') |
348
e8fc875467bd
implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents:
346
diff
changeset
|
347 return redirect(url('admin_settings')) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
348 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
349 @HasPermissionAllDecorator('hg.admin') |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
350 def delete(self, setting_id): |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
351 """DELETE /admin/settings/setting_id: Delete an existing item""" |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
352 # Forms posted to this method should contain a hidden field: |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
353 # <input type="hidden" name="_method" value="DELETE" /> |
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
354 # Or using helpers: |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
355 # h.form(url('admin_setting', setting_id=ID), |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
356 # method='delete') |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
357 # url('admin_setting', setting_id=ID) |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
358 if setting_id == 'hooks': |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
359 hook_id = request.POST.get('hook_id') |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
360 RhodeCodeUi.delete(hook_id) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
361 Session().commit() |
1673
333b3e7c991f
Added email sending test site
Marcin Kuzminski <marcin@python-works.com>
parents:
1633
diff
changeset
|
362 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
363 @HasPermissionAllDecorator('hg.admin') |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
364 def show(self, setting_id, format='html'): |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
365 """ |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
366 GET /admin/settings/setting_id: Show a specific item""" |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
367 # url('admin_setting', setting_id=ID) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
368 |
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
369 @HasPermissionAllDecorator('hg.admin') |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
370 def edit(self, setting_id, format='html'): |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
371 """ |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
372 GET /admin/settings/setting_id/edit: Form to |
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
373 edit an existing item""" |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
374 # url('admin_edit_setting', setting_id=ID) |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
375 |
1460
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
376 c.hooks = RhodeCodeUi.get_builtin_hooks() |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
377 c.custom_hooks = RhodeCodeUi.get_custom_hooks() |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
378 |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
379 return htmlfill.render( |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
380 render('admin/settings/hooks.html'), |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
381 defaults={}, |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
382 encoding="UTF-8", |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
383 force_defaults=False |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
384 ) |
b50348816a80
Added more advanced hook management into rhodecode admin settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1366
diff
changeset
|
385 |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
386 def _load_my_repos_data(self): |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
387 repos_list = Session().query(Repository)\ |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
388 .filter(Repository.user_id == |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
389 self.rhodecode_user.user_id)\ |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
390 .order_by(func.lower(Repository.repo_name)).all() |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
391 |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
392 repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list, |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
393 admin=True) |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
394 #json used to render the grid |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
395 return json.dumps(repos_data) |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
396 |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
397 @NotAnonymous() |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
398 def my_account(self): |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
399 """ |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1164
diff
changeset
|
400 GET /_admin/my_account Displays info about my account |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
401 """ |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
402 # url('admin_settings_my_account') |
665
070f32743632
Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents:
661
diff
changeset
|
403 |
1501
a828b83dfa4b
Deprecated UserModel removals
Marcin Kuzminski <marcin@python-works.com>
parents:
1460
diff
changeset
|
404 c.user = User.get(self.rhodecode_user.user_id) |
3455
d5ae996eed11
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
Marcin Kuzminski <marcin@python-works.com>
parents:
3404
diff
changeset
|
405 c.perm_user = AuthUser(user_id=self.rhodecode_user.user_id, |
d5ae996eed11
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
Marcin Kuzminski <marcin@python-works.com>
parents:
3404
diff
changeset
|
406 ip_addr=self.ip_addr) |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
407 c.ldap_dn = c.user.ldap_dn |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
408 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
409 if c.user.username == 'default': |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
410 h.flash(_("You can't edit this user since it's" |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
411 " crucial for entire application"), category='warning') |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
412 return redirect(url('users')) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
413 |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3145
diff
changeset
|
414 #json used to render the grid |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
415 c.data = self._load_my_repos_data() |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3145
diff
changeset
|
416 |
832
634596f81cfd
new improved models with helper functions for easier data fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
829
diff
changeset
|
417 defaults = c.user.get_dict() |
2353
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
418 |
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
419 c.form = htmlfill.render( |
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
420 render('admin/users/user_edit_my_account_form.html'), |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
421 defaults=defaults, |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
422 encoding="UTF-8", |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
423 force_defaults=False |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
424 ) |
2353
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
425 return render('admin/users/user_edit_my_account.html') |
346
51362853ac3b
added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
426 |
2626
4abce2c11c5f
My account pages shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2625
diff
changeset
|
427 @NotAnonymous() |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
428 def my_account_update(self): |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
429 """PUT /_admin/my_account_update: Update an existing item""" |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
430 # Forms posted to this method should contain a hidden field: |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
431 # <input type="hidden" name="_method" value="PUT" /> |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
432 # Or using helpers: |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
433 # h.form(url('admin_settings_my_account_update'), |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
434 # method='put') |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
435 # url('admin_settings_my_account_update', id=ID) |
1121
f3f847712f87
replaced all global calls to template context (rhodecode_user), into instance attributes
Marcin Kuzminski <marcin@python-works.com>
parents:
1112
diff
changeset
|
436 uid = self.rhodecode_user.user_id |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
437 c.user = User.get(self.rhodecode_user.user_id) |
3455
d5ae996eed11
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
Marcin Kuzminski <marcin@python-works.com>
parents:
3404
diff
changeset
|
438 c.perm_user = AuthUser(user_id=self.rhodecode_user.user_id, |
d5ae996eed11
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
Marcin Kuzminski <marcin@python-works.com>
parents:
3404
diff
changeset
|
439 ip_addr=self.ip_addr) |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
440 c.ldap_dn = c.user.ldap_dn |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2484
diff
changeset
|
441 email = self.rhodecode_user.email |
1245
5f2fbab7c429
PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents:
1206
diff
changeset
|
442 _form = UserForm(edit=True, |
2544
6ce3387bf0ce
Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents:
2484
diff
changeset
|
443 old_data={'user_id': uid, 'email': email})() |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
444 form_result = {} |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
445 try: |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
446 form_result = _form.to_python(dict(request.POST)) |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
447 skip_attrs = ['admin', 'active'] # skip attr for my account |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
448 if c.ldap_dn: |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
449 #forbid updating username for ldap accounts |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
450 skip_attrs.append('username') |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
451 UserModel().update(uid, form_result, skip_attrs=skip_attrs) |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
452 h.flash(_('Your account was updated successfully'), |
396
9416269860c9
little css update, and flash messages
Marcin Kuzminski <marcin@python-works.com>
parents:
395
diff
changeset
|
453 category='success') |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
454 Session().commit() |
564
ba7e24cd4786
refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents:
549
diff
changeset
|
455 except formencode.Invalid, errors: |
3159
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
456 #json used to render the grid |
4910b2607a29
fixes issue #658, my account edit was missing this functionality
Marcin Kuzminski <marcin@python-works.com>
parents:
3154
diff
changeset
|
457 c.data = self._load_my_repos_data() |
2353
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
458 c.form = htmlfill.render( |
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
459 render('admin/users/user_edit_my_account_form.html'), |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
460 defaults=errors.value, |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
461 errors=errors.error_dict or {}, |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
462 prefix_error=False, |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
463 encoding="UTF-8") |
2353
ef71d7e63806
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
Marcin Kuzminski <marcin@python-works.com>
parents:
2223
diff
changeset
|
464 return render('admin/users/user_edit_my_account.html') |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
465 except Exception: |
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
466 log.error(traceback.format_exc()) |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3455
diff
changeset
|
467 h.flash(_('Error occurred during update of user %s') \ |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
468 % form_result.get('username'), category='error') |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
469 |
371
5cd6616b8673
routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents:
359
diff
changeset
|
470 return redirect(url('my_account')) |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
471 |
2626
4abce2c11c5f
My account pages shouldn't be accessible by anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
2625
diff
changeset
|
472 @NotAnonymous() |
2625
fc19979a8421
Added views for new ajax functions, got somehow lost in previos commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2544
diff
changeset
|
473 def my_account_my_pullrequests(self): |
3404
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
474 c.show_closed = request.GET.get('pr_show_closed') |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
475 |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
476 def _filter(pr): |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
477 s = sorted(pr, key=lambda o: o.created_on, reverse=True) |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
478 if not c.show_closed: |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
479 s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s) |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
480 return s |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
481 |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
482 c.my_pull_requests = _filter(PullRequest.query()\ |
3154
0226b6d6b2b5
Use common function for generation of grid data
Marcin Kuzminski <marcin@python-works.com>
parents:
3145
diff
changeset
|
483 .filter(PullRequest.user_id == |
2625
fc19979a8421
Added views for new ajax functions, got somehow lost in previos commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2544
diff
changeset
|
484 self.rhodecode_user.user_id)\ |
3404
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
485 .all()) |
3389
1c4505e3be5b
show flags, and desc sort pull request based on created_date ref #765
Marcin Kuzminski <marcin@python-works.com>
parents:
3333
diff
changeset
|
486 |
3404
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
487 c.participate_in_pull_requests = _filter([ |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
488 x.pull_request for x in PullRequestReviewers.query()\ |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
489 .filter(PullRequestReviewers.user_id == |
7854097b189c
Hide closed pull requests on my page.
Marcin Kuzminski <marcin@python-works.com>
parents:
3389
diff
changeset
|
490 self.rhodecode_user.user_id).all()]) |
3389
1c4505e3be5b
show flags, and desc sort pull request based on created_date ref #765
Marcin Kuzminski <marcin@python-works.com>
parents:
3333
diff
changeset
|
491 |
2625
fc19979a8421
Added views for new ajax functions, got somehow lost in previos commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2544
diff
changeset
|
492 return render('admin/users/user_edit_my_account_pullrequests.html') |
fc19979a8421
Added views for new ajax functions, got somehow lost in previos commit
Marcin Kuzminski <marcin@python-works.com>
parents:
2544
diff
changeset
|
493 |
779
389d02a5df52
Added isanonymous decorator for checking permissions for anonymous access
Marcin Kuzminski <marcin@python-works.com>
parents:
765
diff
changeset
|
494 @NotAnonymous() |
380
ca54622e39a1
Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents:
371
diff
changeset
|
495 def create_repository(self): |
ca54622e39a1
Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents:
371
diff
changeset
|
496 """GET /_admin/create_repository: Form to create a new item""" |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
497 new_repo = request.GET.get('repo', '') |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
498 parent_group = request.GET.get('parent_group') |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
499 if not HasPermissionAny('hg.admin', 'hg.create.repository')(): |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
500 #you're not super admin nor have global create permissions, |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
501 #but maybe you have at least write permission to a parent group ? |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
502 _gr = RepoGroup.get(parent_group) |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
503 gr_name = _gr.group_name if _gr else None |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
504 if not HasReposGroupPermissionAny('group.admin', 'group.write')(group_name=gr_name): |
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
505 raise HTTPForbidden |
1161
f3c25bbd9148
added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
506 |
3239
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3233
diff
changeset
|
507 acl_groups = GroupList(RepoGroup.query().all(), |
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3233
diff
changeset
|
508 perm_set=['group.write', 'group.admin']) |
a9565b8b429b
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper
Marcin Kuzminski <marcin@python-works.com>
parents:
3233
diff
changeset
|
509 c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) |
1161
f3c25bbd9148
added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
510 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups) |
2484
69625d679b8a
fixed typo in repo create
Marcin Kuzminski <marcin@python-works.com>
parents:
2459
diff
changeset
|
511 choices, c.landing_revs = ScmModel().get_repo_landing_revs() |
1161
f3c25bbd9148
added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
512 |
1022
4f834b0abcd3
Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
513 c.new_repo = repo_name_slug(new_repo) |
1161
f3c25bbd9148
added proper groups names in add repo from settings
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
514 |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
515 ## apply the defaults from defaults page |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
516 defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True) |
3233
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3159
diff
changeset
|
517 if parent_group: |
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3159
diff
changeset
|
518 defaults.update({'repo_group': parent_group}) |
11b005b2d5e8
use the GET parent_group param to pre-fill the group choice
Marcin Kuzminski <marcin@python-works.com>
parents:
3159
diff
changeset
|
519 |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
520 return htmlfill.render( |
3333
069884383cc7
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder.
Marcin Kuzminski <marcin@python-works.com>
parents:
3308
diff
changeset
|
521 render('admin/repos/repo_add.html'), |
3056
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
522 defaults=defaults, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
523 errors={}, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
524 prefix_error=False, |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
525 encoding="UTF-8" |
6104dfd35b16
Implemented #379 defaults settings page for creation of repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
2958
diff
changeset
|
526 ) |
629
7e536d1af60d
Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents:
564
diff
changeset
|
527 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
528 def _get_hg_ui_settings(self): |
2662
91c442a489bb
sqlalchemy sessions cleanup in admin
Marcin Kuzminski <marcin@python-works.com>
parents:
2626
diff
changeset
|
529 ret = RhodeCodeUi.query().all() |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
530 |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
531 if not ret: |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
532 raise Exception('Could not get application ui settings !') |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
533 settings = {} |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
534 for each in ret: |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
535 k = each.ui_key |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
536 v = each.ui_value |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
537 if k == '/': |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
538 k = 'root_path' |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
539 |
2821
9c90be87ae05
fixed issue #560 require push ssl checkbox wasn't shown when option was enabled
Marcin Kuzminski <marcin@python-works.com>
parents:
2708
diff
changeset
|
540 if k == 'push_ssl': |
9c90be87ae05
fixed issue #560 require push ssl checkbox wasn't shown when option was enabled
Marcin Kuzminski <marcin@python-works.com>
parents:
2708
diff
changeset
|
541 v = str2bool(v) |
9c90be87ae05
fixed issue #560 require push ssl checkbox wasn't shown when option was enabled
Marcin Kuzminski <marcin@python-works.com>
parents:
2708
diff
changeset
|
542 |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
543 if k.find('.') != -1: |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
544 k = k.replace('.', '_') |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
545 |
2708
9bce679a3f49
Added form for controlling mercurial extensions
Marcin Kuzminski <marcin@python-works.com>
parents:
2674
diff
changeset
|
546 if each.ui_section in ['hooks', 'extensions']: |
756
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
547 v = each.ui_active |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
548 |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
549 settings[each.ui_section + '_' + k] = v |
01be209b9828
project refactoring, cleaned up lib.utils from rarly used functions, and place them
Marcin Kuzminski <marcin@python-works.com>
parents:
709
diff
changeset
|
550 return settings |