annotate rhodecode/controllers/admin/settings.py @ 549:f99075170eb4

more renames for rhode code !!
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 06 Oct 2010 03:34:18 +0200
parents b75b77ef649d
children ba7e24cd4786
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 #!/usr/bin/env python
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 # encoding: utf-8
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 # settings controller for pylons
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
359
339d1368c10d new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
5 #
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 # This program is free software; you can redistribute it and/or
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # modify it under the terms of the GNU General Public License
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # as published by the Free Software Foundation; version 2
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 # of the License or (at your opinion) any later version of the license.
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 #
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 # 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
12 # 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
13 # 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
14 # GNU General Public License for more details.
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 #
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 # You should have received a copy of the GNU General Public License
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # along with this program; if not, write to the Free Software
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # MA 02110-1301, USA.
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 """
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 Created on July 14, 2010
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 settings controller for pylons
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 @author: marcink
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 """
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 from formencode import htmlfill
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
26 from pylons import request, session, tmpl_context as c, url, app_globals as g, \
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
27 config
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 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
29 from pylons.i18n.translation import _
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
30 from rhodecode.lib import helpers as h
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
31 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
32 HasPermissionAnyDecorator
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
33 from rhodecode.lib.base import BaseController, render
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
34 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
35 set_rhodecode_config, get_hg_settings, get_hg_ui_settings, make_ui
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
36 from rhodecode.model.db import User, UserLog, RhodeCodeSettings, RhodeCodeUi
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
37 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
38 ApplicationUiSettingsForm
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
39 from rhodecode.model.hg_model import HgModel
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
40 from rhodecode.model.user_model import UserModel
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
41 from rhodecode.lib.celerylib import tasks, run_task
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 import formencode
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 import logging
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
44 import traceback
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
45
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 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
47
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 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
50 """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
51 # 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
52 # file has a resource setup:
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 # map.resource('setting', 'settings', controller='admin/settings',
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 # 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
55
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 @LoginRequired()
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 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
59 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
60 c.admin_username = session.get('admin_username')
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 super(SettingsController, self).__before__()
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
62
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
63
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
64 @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
65 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
66 """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
67 # url('admin_settings')
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
68
381
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
69 defaults = get_hg_settings()
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
70 defaults.update(get_hg_ui_settings())
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
71 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
72 render('admin/settings/settings.html'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
73 defaults=defaults,
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
74 encoding="UTF-8",
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
75 force_defaults=False
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
76 )
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
78 @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
79 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
80 """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
81 # url('admin_settings')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
82
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
83 @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
84 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
85 """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
86 # url('admin_new_setting')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
87
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
88 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
89 def update(self, setting_id):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
90 """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
91 # 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
92 # <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
93 # Or using helpers:
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
94 # 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
95 # method='put')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
96 # url('admin_setting', setting_id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
97 if setting_id == 'mapping':
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
98 rm_obsolete = request.POST.get('destroy', False)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
99 log.debug('Rescanning directories with destroy=%s', rm_obsolete)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
100
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
101 initial = HgModel.repo_scan(g.paths[0][0], g.paths[0][1], g.baseui)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
102 repo2db_mapper(initial, rm_obsolete)
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
103 invalidate_cache('cached_repo_list')
537
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 489
diff changeset
104 h.flash(_('Repositories successfully rescanned'), category='success')
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
105
467
3fc3ce53659b starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents: 446
diff changeset
106 if setting_id == 'whoosh':
3fc3ce53659b starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents: 446
diff changeset
107 repo_location = 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
108 full_index = request.POST.get('full_index', False)
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
109 task = run_task(tasks.whoosh_index, repo_location, full_index)
467
3fc3ce53659b starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents: 446
diff changeset
110
3fc3ce53659b starting celery branch
Marcin Kuzminski <marcin@python-works.com>
parents: 446
diff changeset
111 h.flash(_('Whoosh reindex task scheduled'), category='success')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
112 if setting_id == 'global':
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
113
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
114 application_form = ApplicationSettingsForm()()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
115 try:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
116 form_result = application_form.to_python(dict(request.POST))
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
117
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
118 try:
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
119 hgsettings1 = self.sa.query(RhodeCodeSettings)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
120 .filter(RhodeCodeSettings.app_settings_name == 'title').one()
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
121 hgsettings1.app_settings_value = form_result['rhodecode_title']
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
122
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
123 hgsettings2 = self.sa.query(RhodeCodeSettings)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
124 .filter(RhodeCodeSettings.app_settings_name == 'realm').one()
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
125 hgsettings2.app_settings_value = form_result['rhodecode_realm']
381
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
126
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
127
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
128 self.sa.add(hgsettings1)
55377fdc1fc6 cleared global application settings.
Marcin Kuzminski <marcin@python-works.com>
parents: 380
diff changeset
129 self.sa.add(hgsettings2)
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
130 self.sa.commit()
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
131 set_rhodecode_config(config)
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
132 h.flash(_('Updated application settings'),
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
133 category='success')
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
134
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
135 except:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
136 log.error(traceback.format_exc())
537
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 489
diff changeset
137 h.flash(_('error occurred during updating application settings'),
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
138 category='error')
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
139
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
140 self.sa.rollback()
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
141
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
142
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
143 except formencode.Invalid as errors:
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
144 return htmlfill.render(
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
145 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
146 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
147 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
148 prefix_error=False,
339d1368c10d new style error display for settings, added flash msg for repo rescan
Marcin Kuzminski <marcin@python-works.com>
parents: 350
diff changeset
149 encoding="UTF-8")
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
150
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
151 if setting_id == 'mercurial':
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
152 application_form = ApplicationUiSettingsForm()()
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
153 try:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
154 form_result = application_form.to_python(dict(request.POST))
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
155
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
156 try:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
157
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
158 hgsettings1 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
159 .filter(RhodeCodeUi.ui_key == 'push_ssl').one()
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
160 hgsettings1.ui_value = form_result['web_push_ssl']
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
161
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
162 hgsettings2 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
163 .filter(RhodeCodeUi.ui_key == '/').one()
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
164 hgsettings2.ui_value = form_result['paths_root_path']
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
165
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
166
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
167 #HOOKS
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
168 hgsettings3 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
169 .filter(RhodeCodeUi.ui_key == 'changegroup.update').one()
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
170 hgsettings3.ui_active = bool(form_result['hooks_changegroup_update'])
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
171
549
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
172 hgsettings4 = self.sa.query(RhodeCodeUi)\
f99075170eb4 more renames for rhode code !!
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
173 .filter(RhodeCodeUi.ui_key == 'changegroup.repo_size').one()
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
174 hgsettings4.ui_active = bool(form_result['hooks_changegroup_repo_size'])
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
175
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
176
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
177
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
178
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
179 self.sa.add(hgsettings1)
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
180 self.sa.add(hgsettings2)
395
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
181 self.sa.add(hgsettings3)
e8af467b5a60 Added hooks managment into application settings
Marcin Kuzminski <marcin@python-works.com>
parents: 388
diff changeset
182 self.sa.add(hgsettings4)
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
183 self.sa.commit()
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
184
396
9416269860c9 little css update, and flash messages
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
185 h.flash(_('Updated mercurial settings'),
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
186 category='success')
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
187
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
188 except:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
189 log.error(traceback.format_exc())
537
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 489
diff changeset
190 h.flash(_('error occurred during updating application settings'),
388
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
191 category='error')
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
192
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
193 self.sa.rollback()
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
194
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
195
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
196 except formencode.Invalid as errors:
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
197 return htmlfill.render(
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
198 render('admin/settings/settings.html'),
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
199 defaults=errors.value,
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
200 errors=errors.error_dict or {},
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
201 prefix_error=False,
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
202 encoding="UTF-8")
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
203
3bcf9529d221 Added new application settings,Push ssl and repositories path
Marcin Kuzminski <marcin@python-works.com>
parents: 381
diff changeset
204
350
664a5b8c551a Added application settings, are now customizable from database
Marcin Kuzminski <marcin@python-works.com>
parents: 348
diff changeset
205
348
e8fc875467bd implemented manual repo rescann and remapping
Marcin Kuzminski <marcin@python-works.com>
parents: 346
diff changeset
206 return redirect(url('admin_settings'))
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
207
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
208 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
209 def delete(self, setting_id):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
210 """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
211 # 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
212 # <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
213 # Or using helpers:
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
214 # 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
215 # method='delete')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
216 # url('admin_setting', setting_id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
217
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
218 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
219 def show(self, setting_id, format='html'):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
220 """GET /admin/settings/setting_id: Show a specific item"""
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
221 # url('admin_setting', setting_id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
222
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
223 @HasPermissionAllDecorator('hg.admin')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
224 def edit(self, setting_id, format='html'):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
225 """GET /admin/settings/setting_id/edit: Form to edit an existing item"""
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
226 # url('admin_edit_setting', setting_id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
227
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
228
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
229 def my_account(self):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
230 """
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
231 GET /_admin/my_account Displays info about my account
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
232 """
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
233 # url('admin_settings_my_account')
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
234 c.user = self.sa.query(User).get(c.rhodecode_user.user_id)
446
a0a93357f954 started my page rewrite
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
235 c.user_repos = []
a0a93357f954 started my page rewrite
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
236 for repo in c.cached_repo_list.values():
a0a93357f954 started my page rewrite
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
237 if repo.dbrepo.user.username == c.user.username:
a0a93357f954 started my page rewrite
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
238 c.user_repos.append(repo)
a0a93357f954 started my page rewrite
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
239
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
240 if c.user.username == 'default':
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
241 h.flash(_("You can't edit this user since it's"
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
242 " crucial for entire application"), category='warning')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
243 return redirect(url('users'))
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
244
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
245 defaults = c.user.__dict__
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
246 return htmlfill.render(
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
247 render('admin/users/user_edit_my_account.html'),
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
248 defaults=defaults,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
249 encoding="UTF-8",
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
250 force_defaults=False
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
251 )
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
252
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
253 def my_account_update(self):
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
254 """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
255 # 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
256 # <input type="hidden" name="_method" value="PUT" />
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
257 # Or using helpers:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
258 # h.form(url('admin_settings_my_account_update'),
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
259 # method='put')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
260 # url('admin_settings_my_account_update', id=ID)
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
261 user_model = UserModel()
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
262 uid = c.rhodecode_user.user_id
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
263 _form = UserForm(edit=True, old_data={'user_id':uid,
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
264 'email':c.rhodecode_user.email})()
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
265 form_result = {}
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
266 try:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
267 form_result = _form.to_python(dict(request.POST))
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
268 user_model.update_my_account(uid, form_result)
396
9416269860c9 little css update, and flash messages
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
269 h.flash(_('Your account was updated succesfully'),
9416269860c9 little css update, and flash messages
Marcin Kuzminski <marcin@python-works.com>
parents: 395
diff changeset
270 category='success')
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
271
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
272 except formencode.Invalid as errors:
548
b75b77ef649d renamed hg_app to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
273 c.user = self.sa.query(User).get(c.rhodecode_user.user_id)
489
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
274 c.user_repos = []
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
275 for repo in c.cached_repo_list.values():
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
276 if repo.dbrepo.user.username == c.user.username:
460ad816820d fixed bug when new repo had no last commiter,
Marcin Kuzminski <marcin@python-works.com>
parents: 473
diff changeset
277 c.user_repos.append(repo)
371
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
278 return htmlfill.render(
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
279 render('admin/users/user_edit_my_account.html'),
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
280 defaults=errors.value,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
281 errors=errors.error_dict or {},
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
282 prefix_error=False,
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
283 encoding="UTF-8")
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
284 except Exception:
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
285 log.error(traceback.format_exc())
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
286 h.flash(_('error occured during update of user %s') \
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
287 % form_result.get('username'), category='error')
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
288
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
289 return redirect(url('my_account'))
5cd6616b8673 routes python 2.5 compatible
Marcin Kuzminski <marcin@python-works.com>
parents: 359
diff changeset
290
417
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 396
diff changeset
291 @HasPermissionAnyDecorator('hg.admin', 'hg.create.repository')
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
292 def create_repository(self):
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
293 """GET /_admin/create_repository: Form to create a new item"""
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
294 new_repo = request.GET.get('repo', '')
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
295 c.new_repo = h.repo_name_slug(new_repo)
346
51362853ac3b added settings rest controllers for admin, updated routes with easier submodule handling
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
296
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
297 return render('admin/repos/repo_add_create_repository.html')
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
298