##// END OF EJS Templates
merge the two context menu bar stripes - save some vertical space
merge the two context menu bar stripes - save some vertical space

File last commit:

r3570:8173b0cf beta
r3612:a8373e8f beta
Show More
settings.py
550 lines | 21.6 KiB | text/x-python | PythonLexer
Added isanonymous decorator for checking permissions for anonymous access
r779 # -*- coding: utf-8 -*-
"""
fixed spelling mistakes, and some minor docs bugs
r860 rhodecode.controllers.admin.settings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source code cleanup: remove trailing white space, normalize file endings
r1203
Added isanonymous decorator for checking permissions for anonymous access
r779 settings controller for rhodecode admin
source code cleanup: remove trailing white space, normalize file endings
r1203
Added isanonymous decorator for checking permissions for anonymous access
r779 :created_on: Jul 14, 2010
:author: marcink
2012 copyrights
r1824 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
Added isanonymous decorator for checking permissions for anonymous access
r779 :license: GPLv3, see COPYING for more details.
"""
fixed license issue #149
r1206 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
renamed project to rhodecode
r547 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
source code cleanup: remove trailing white space, normalize file endings
r1203 #
renamed project to rhodecode
r547 # You should have received a copy of the GNU General Public License
fixed license issue #149
r1206 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Added isanonymous decorator for checking permissions for anonymous access
r779
implemented #89 google analytics code
r890 import logging
import traceback
import formencode
added useful system info + packages to settings page.
r2192 import pkg_resources
import platform
implemented #89 google analytics code
r890
Code refactor number 2
r1022 from sqlalchemy import func
renamed project to rhodecode
r547 from formencode import htmlfill
Major refactoring, removed when possible calls to app globals....
r1036 from pylons import request, session, tmpl_context as c, url, config
renamed project to rhodecode
r547 from pylons.controllers.util import abort, redirect
from pylons.i18n.translation import _
implemented #89 google analytics code
r890
renamed project to rhodecode
r547 from rhodecode.lib import helpers as h
from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder....
r3333 HasPermissionAnyDecorator, NotAnonymous, HasPermissionAny,\
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
r3455 HasReposGroupPermissionAll, HasReposGroupPermissionAny, AuthUser
renamed project to rhodecode
r547 from rhodecode.lib.base import BaseController, render
implements #60, ldap configuration and authentication....
r705 from rhodecode.lib.celerylib import tasks, run_task
renamed project to rhodecode
r547 from rhodecode.lib.utils import repo2db_mapper, invalidate_cache, \
Add git version detection to warn users that Git used in system is to old. ref #588...
r2890 set_rhodecode_config, repo_name_slug, check_git_version
refactoring of models names for repoGroup permissions
r1633 from rhodecode.model.db import RhodeCodeUi, Repository, RepoGroup, \
Added views for new ajax functions, got somehow lost in previos commit
r2625 RhodeCodeSetting, PullRequest, PullRequestReviewers
renamed project to rhodecode
r547 from rhodecode.model.forms import UserForm, ApplicationSettingsForm, \
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 ApplicationUiSettingsForm, ApplicationVisualisationForm
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper...
r3239 from rhodecode.model.scm import ScmModel, GroupList
Code refactoring,models renames...
r629 from rhodecode.model.user import UserModel
Use common function for generation of grid data...
r3154 from rhodecode.model.repo import RepoModel
Deprecated UserModel removals...
r1501 from rhodecode.model.db import User
reduce cookie size for better support of client side sessions
r1718 from rhodecode.model.notification import EmailNotificationModel
commit less models...
r1749 from rhodecode.model.meta import Session
nicer representation of list of rescanned repositories
r3145 from rhodecode.lib.utils2 import str2bool, safe_unicode
Use common function for generation of grid data...
r3154 from rhodecode.lib.compat import json
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder....
r3333 from webob.exc import HTTPForbidden
renamed project to rhodecode
r547 log = logging.getLogger(__name__)
class SettingsController(BaseController):
"""REST Controller styled on the Atom Publishing Protocol"""
# To properly map this controller, ensure your config/routing.py
# file has a resource setup:
source code cleanup: remove trailing white space, normalize file endings
r1203 # map.resource('setting', 'settings', controller='admin/settings',
renamed project to rhodecode
r547 # path_prefix='/admin', name_prefix='admin_')
@LoginRequired()
def __before__(self):
c.admin_user = session.get('admin_user')
c.admin_username = session.get('admin_username')
white space cleanup
r2207 c.modules = sorted([(p.project_name, p.version)
Add git version detection to warn users that Git used in system is to old. ref #588...
r2890 for p in pkg_resources.working_set]
+ [('git', check_git_version())],
fix ordering of system packages info
r2223 key=lambda k: k[0].lower())
added useful system info + packages to settings page.
r2192 c.py_version = platform.python_version()
white space cleanup
r2207 c.platform = platform.platform()
renamed project to rhodecode
r547 super(SettingsController, self).__before__()
Code refactoring,models renames...
r629
@HasPermissionAllDecorator('hg.admin')
renamed project to rhodecode
r547 def index(self, format='html'):
"""GET /admin/settings: All items in the collection"""
# url('admin_settings')
refactoring of models names for repoGroup permissions
r1633 defaults = RhodeCodeSetting.get_app_settings()
Added form for controlling mercurial extensions...
r2708 defaults.update(self._get_hg_ui_settings())
added useful system info + packages to settings page.
r2192
renamed project to rhodecode
r547 return htmlfill.render(
render('admin/settings/settings.html'),
defaults=defaults,
encoding="UTF-8",
force_defaults=False
Code refactoring,models renames...
r629 )
renamed project to rhodecode
r547 @HasPermissionAllDecorator('hg.admin')
def create(self):
"""POST /admin/settings: Create a new item"""
# url('admin_settings')
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 @HasPermissionAllDecorator('hg.admin')
def new(self, format='html'):
"""GET /admin/settings/new: Form to create a new item"""
# url('admin_new_setting')
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 @HasPermissionAllDecorator('hg.admin')
def update(self, setting_id):
"""PUT /admin/settings/setting_id: Update an existing item"""
# Forms posted to this method should contain a hidden field:
# <input type="hidden" name="_method" value="PUT" />
# Or using helpers:
# h.form(url('admin_setting', setting_id=ID),
# method='put')
# url('admin_setting', setting_id=ID)
sqlalchemy sessions cleanup in admin...
r2662
renamed project to rhodecode
r547 if setting_id == 'mapping':
rm_obsolete = request.POST.get('destroy', False)
garden...
r1976 log.debug('Rescanning directories with destroy=%s' % rm_obsolete)
Major refactoring, removed when possible calls to app globals....
r1036 initial = ScmModel().repo_scan()
extended admin rescan to show what repositories was added and what removed...
r1039 log.debug('invalidating all repositories')
Moved out reposcan into hg Model....
r665 for repo_name in initial.keys():
invalidate_cache('get_repo_cached_%s' % repo_name)
extended admin rescan to show what repositories was added and what removed...
r1039 added, removed = repo2db_mapper(initial, rm_obsolete)
nicer representation of list of rescanned repositories
r3145 _repr = lambda l: ', '.join(map(safe_unicode, l)) or '-'
h.flash(_('Repositories successfully '
'rescanned added: %s ; removed: %s') %
(_repr(added), _repr(removed)),
Mads Kiilerich
admin settings: show numbers in rescan flash message instead of python lists
r3142 category='success')
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 if setting_id == 'whoosh':
Added form for controlling mercurial extensions...
r2708 repo_location = self._get_hg_ui_settings()['paths_root_path']
renamed project to rhodecode
r547 full_index = request.POST.get('full_index', False)
pep8
r1164 run_task(tasks.whoosh_index, repo_location, full_index)
sqlalchemy sessions cleanup in admin...
r2662 h.flash(_('Whoosh reindex task scheduled'), category='success')
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 if setting_id == 'global':
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 application_form = ApplicationSettingsForm()()
try:
form_result = application_form.to_python(dict(request.POST))
sqlalchemy sessions cleanup in admin...
r2662 except formencode.Invalid, errors:
return htmlfill.render(
render('admin/settings/settings.html'),
defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
encoding="UTF-8"
)
Code refactoring,models renames...
r629
sqlalchemy sessions cleanup in admin...
r2662 try:
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 sett1 = RhodeCodeSetting.get_by_name_or_create('title')
sqlalchemy sessions cleanup in admin...
r2662 sett1.app_settings_value = form_result['rhodecode_title']
Session().add(sett1)
Code refactoring,models renames...
r629
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 sett2 = RhodeCodeSetting.get_by_name_or_create('realm')
sqlalchemy sessions cleanup in admin...
r2662 sett2.app_settings_value = form_result['rhodecode_realm']
Session().add(sett2)
Code refactoring,models renames...
r629
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 sett3 = RhodeCodeSetting.get_by_name_or_create('ga_code')
sqlalchemy sessions cleanup in admin...
r2662 sett3.app_settings_value = form_result['rhodecode_ga_code']
Session().add(sett3)
Session().commit()
set_rhodecode_config(config)
h.flash(_('Updated application settings'), category='success')
Code refactoring,models renames...
r629
sqlalchemy sessions cleanup in admin...
r2662 except Exception:
log.error(traceback.format_exc())
Mads Kiilerich
consistently capitalize initial letter in flash messages
r3565 h.flash(_('Error occurred during updating '
sqlalchemy sessions cleanup in admin...
r2662 'application settings'),
category='error')
Code refactoring,models renames...
r629
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 if setting_id == 'visual':
application_form = ApplicationVisualisationForm()()
try:
form_result = application_form.to_python(dict(request.POST))
except formencode.Invalid, errors:
return htmlfill.render(
render('admin/settings/settings.html'),
defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
encoding="UTF-8"
)
try:
sett1 = RhodeCodeSetting.get_by_name_or_create('show_public_icon')
sett1.app_settings_value = \
form_result['rhodecode_show_public_icon']
Added lightweight dashboard option. ref #500
r2936 Session().add(sett1)
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674
sett2 = RhodeCodeSetting.get_by_name_or_create('show_private_icon')
sett2.app_settings_value = \
form_result['rhodecode_show_private_icon']
Added lightweight dashboard option. ref #500
r2936 Session().add(sett2)
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674
sett3 = RhodeCodeSetting.get_by_name_or_create('stylify_metatags')
sett3.app_settings_value = \
form_result['rhodecode_stylify_metatags']
Added lightweight dashboard option. ref #500
r2936 Session().add(sett3)
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674
Added lightweight dashboard option. ref #500
r2936 sett4 = RhodeCodeSetting.get_by_name_or_create('lightweight_dashboard')
sett4.app_settings_value = \
form_result['rhodecode_lightweight_dashboard']
Session().add(sett4)
repository extra fields implementation...
r3308 sett4 = RhodeCodeSetting.get_by_name_or_create('repository_fields')
sett4.app_settings_value = \
form_result['rhodecode_repository_fields']
Session().add(sett4)
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 Session().commit()
set_rhodecode_config(config)
h.flash(_('Updated visualisation settings'),
category='success')
except Exception:
log.error(traceback.format_exc())
Mads Kiilerich
consistently capitalize initial letter in flash messages
r3565 h.flash(_('Error occurred during updating '
merged + fixed pull request #62: Implemented metatags and visualisation options....
r2674 'visualisation settings'),
category='error')
sqlalchemy sessions cleanup in admin...
r2662 if setting_id == 'vcs':
application_form = ApplicationUiSettingsForm()()
try:
form_result = application_form.to_python(dict(request.POST))
refactor codes and setup for python 2.5...
r564 except formencode.Invalid, errors:
renamed project to rhodecode
r547 return htmlfill.render(
render('admin/settings/settings.html'),
defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
sqlalchemy sessions cleanup in admin...
r2662 encoding="UTF-8"
)
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 try:
Added form for controlling mercurial extensions...
r2708 sett = RhodeCodeUi.get_by_key('push_ssl')
sett.ui_value = form_result['web_push_ssl']
Session().add(sett)
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 sett = RhodeCodeUi.get_by_key('/')
sett.ui_value = form_result['paths_root_path']
Session().add(sett)
Code refactoring,models renames...
r629
sqlalchemy sessions cleanup in admin...
r2662 #HOOKS
Added form for controlling mercurial extensions...
r2708 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_UPDATE)
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 sett.ui_active = form_result['hooks_changegroup_update']
Added form for controlling mercurial extensions...
r2708 Session().add(sett)
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_REPO_SIZE)
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 sett.ui_active = form_result['hooks_changegroup_repo_size']
Added form for controlling mercurial extensions...
r2708 Session().add(sett)
sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PUSH)
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 sett.ui_active = form_result['hooks_changegroup_push_logger']
Added form for controlling mercurial extensions...
r2708 Session().add(sett)
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 sett = RhodeCodeUi.get_by_key(RhodeCodeUi.HOOK_PULL)
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 sett.ui_active = form_result['hooks_outgoing_pull_logger']
Added form for controlling mercurial extensions...
r2708
Session().add(sett)
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 ## EXTENSIONS
sett = RhodeCodeUi.get_by_key('largefiles')
autofix largefiles hggit hgsubversion options if they are not in the database
r2844 if not sett:
#make one if it's not there !
sett = RhodeCodeUi()
sett.ui_key = 'largefiles'
sett.ui_section = 'extensions'
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 sett.ui_active = form_result['extensions_largefiles']
Added form for controlling mercurial extensions...
r2708 Session().add(sett)
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 sett = RhodeCodeUi.get_by_key('hgsubversion')
autofix largefiles hggit hgsubversion options if they are not in the database
r2844 if not sett:
#make one if it's not there !
sett = RhodeCodeUi()
sett.ui_key = 'hgsubversion'
sett.ui_section = 'extensions'
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 sett.ui_active = form_result['extensions_hgsubversion']
Added form for controlling mercurial extensions...
r2708 Session().add(sett)
# sett = RhodeCodeUi.get_by_key('hggit')
autofix largefiles hggit hgsubversion options if they are not in the database
r2844 # if not sett:
# #make one if it's not there !
# sett = RhodeCodeUi()
# sett.ui_key = 'hggit'
# sett.ui_section = 'extensions'
#
Mads Kiilerich
settings: simplify handling of form values for hooks and extensions...
r3570 # sett.ui_active = form_result['extensions_hggit']
Added form for controlling mercurial extensions...
r2708 # Session().add(sett)
sqlalchemy sessions cleanup in admin...
r2662 Session().commit()
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 h.flash(_('Updated VCS settings'), category='success')
Code refactoring,models renames...
r629
sqlalchemy sessions cleanup in admin...
r2662 except Exception:
log.error(traceback.format_exc())
Mads Kiilerich
consistently capitalize initial letter in flash messages
r3565 h.flash(_('Error occurred during updating '
sqlalchemy sessions cleanup in admin...
r2662 'application settings'), category='error')
Code refactoring,models renames...
r629
Added more advanced hook management into rhodecode admin settings
r1460 if setting_id == 'hooks':
ui_key = request.POST.get('new_hook_ui_key')
ui_value = request.POST.get('new_hook_ui_value')
try:
Added email sending test site
r1673
Added more advanced hook management into rhodecode admin settings
r1460 if ui_value and ui_key:
RhodeCodeUi.create_or_update_hook(ui_key, ui_value)
h.flash(_('Added new hook'),
category='success')
# check for edits
update = False
_d = request.POST.dict_of_lists()
fixes testing email in settings
r1798 for k, v in zip(_d.get('hook_ui_key', []),
_d.get('hook_ui_value_new', [])):
Added more advanced hook management into rhodecode admin settings
r1460 RhodeCodeUi.create_or_update_hook(k, v)
update = True
if update:
h.flash(_('Updated hooks'), category='success')
sqlalchemy sessions cleanup in admin...
r2662 Session().commit()
except Exception:
Added more advanced hook management into rhodecode admin settings
r1460 log.error(traceback.format_exc())
Mads Kiilerich
consistently capitalize initial letter in flash messages
r3565 h.flash(_('Error occurred during hook creation'),
Added more advanced hook management into rhodecode admin settings
r1460 category='error')
return redirect(url('admin_edit_setting', setting_id='hooks'))
Added email sending test site
r1673 if setting_id == 'email':
test_email = request.POST.get('test_email')
test_email_subj = 'RhodeCode TestEmail'
test_email_body = 'RhodeCode Email test'
fixes testing email in settings
r1798
Notification fixes...
r1717 test_email_html_body = EmailNotificationModel()\
fixes testing email in settings
r1798 .get_email_tmpl(EmailNotificationModel.TYPE_DEFAULT,
body=test_email_body)
Added email sending test site
r1673
Mads Kiilerich
admin, email test: fix test for test_email recipients
r3140 recipients = [test_email] if test_email else None
fixes testing email in settings
r1798
run_task(tasks.send_email, recipients, test_email_subj,
Notification fixes...
r1717 test_email_body, test_email_html_body)
Added email sending test site
r1673 h.flash(_('Email task created'), category='success')
renamed project to rhodecode
r547 return redirect(url('admin_settings'))
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 @HasPermissionAllDecorator('hg.admin')
def delete(self, setting_id):
"""DELETE /admin/settings/setting_id: Delete an existing item"""
# Forms posted to this method should contain a hidden field:
# <input type="hidden" name="_method" value="DELETE" />
# Or using helpers:
# h.form(url('admin_setting', setting_id=ID),
# method='delete')
# url('admin_setting', setting_id=ID)
Added more advanced hook management into rhodecode admin settings
r1460 if setting_id == 'hooks':
hook_id = request.POST.get('hook_id')
RhodeCodeUi.delete(hook_id)
sqlalchemy sessions cleanup in admin...
r2662 Session().commit()
Added email sending test site
r1673
renamed project to rhodecode
r547 @HasPermissionAllDecorator('hg.admin')
def show(self, setting_id, format='html'):
PEP8ify - controllers
r1245 """
GET /admin/settings/setting_id: Show a specific item"""
renamed project to rhodecode
r547 # url('admin_setting', setting_id=ID)
Code refactoring,models renames...
r629
@HasPermissionAllDecorator('hg.admin')
renamed project to rhodecode
r547 def edit(self, setting_id, format='html'):
PEP8ify - controllers
r1245 """
GET /admin/settings/setting_id/edit: Form to
edit an existing item"""
renamed project to rhodecode
r547 # url('admin_edit_setting', setting_id=ID)
Added more advanced hook management into rhodecode admin settings
r1460 c.hooks = RhodeCodeUi.get_builtin_hooks()
c.custom_hooks = RhodeCodeUi.get_custom_hooks()
return htmlfill.render(
render('admin/settings/hooks.html'),
defaults={},
encoding="UTF-8",
force_defaults=False
)
fixes issue #658, my account edit was missing this functionality
r3159 def _load_my_repos_data(self):
repos_list = Session().query(Repository)\
.filter(Repository.user_id ==
self.rhodecode_user.user_id)\
.order_by(func.lower(Repository.repo_name)).all()
repos_data = RepoModel().get_repos_as_dict(repos_list=repos_list,
admin=True)
#json used to render the grid
return json.dumps(repos_data)
Added isanonymous decorator for checking permissions for anonymous access
r779 @NotAnonymous()
renamed project to rhodecode
r547 def my_account(self):
"""
source code cleanup: remove trailing white space, normalize file endings
r1203 GET /_admin/my_account Displays info about my account
renamed project to rhodecode
r547 """
Added isanonymous decorator for checking permissions for anonymous access
r779 # url('admin_settings_my_account')
Moved out reposcan into hg Model....
r665
Deprecated UserModel removals...
r1501 c.user = User.get(self.rhodecode_user.user_id)
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
r3455 c.perm_user = AuthUser(user_id=self.rhodecode_user.user_id,
ip_addr=self.ip_addr)
fixes issue #658, my account edit was missing this functionality
r3159 c.ldap_dn = c.user.ldap_dn
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 if c.user.username == 'default':
Code refactoring,models renames...
r629 h.flash(_("You can't edit this user since it's"
renamed project to rhodecode
r547 " crucial for entire application"), category='warning')
return redirect(url('users'))
Code refactoring,models renames...
r629
Use common function for generation of grid data...
r3154 #json used to render the grid
fixes issue #658, my account edit was missing this functionality
r3159 c.data = self._load_my_repos_data()
Use common function for generation of grid data...
r3154
new improved models with helper functions for easier data fetching
r832 defaults = c.user.get_dict()
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
r2353
c.form = htmlfill.render(
render('admin/users/user_edit_my_account_form.html'),
renamed project to rhodecode
r547 defaults=defaults,
encoding="UTF-8",
force_defaults=False
Code refactoring,models renames...
r629 )
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
r2353 return render('admin/users/user_edit_my_account.html')
renamed project to rhodecode
r547
My account pages shouldn't be accessible by anonymous users
r2626 @NotAnonymous()
renamed project to rhodecode
r547 def my_account_update(self):
"""PUT /_admin/my_account_update: Update an existing item"""
# Forms posted to this method should contain a hidden field:
# <input type="hidden" name="_method" value="PUT" />
# Or using helpers:
# h.form(url('admin_settings_my_account_update'),
# method='put')
# url('admin_settings_my_account_update', id=ID)
replaced all global calls to template context (rhodecode_user), into instance attributes
r1121 uid = self.rhodecode_user.user_id
fixes issue #658, my account edit was missing this functionality
r3159 c.user = User.get(self.rhodecode_user.user_id)
show ip for my account, and only in editing your user, showing in all users next to API key is misleading
r3455 c.perm_user = AuthUser(user_id=self.rhodecode_user.user_id,
ip_addr=self.ip_addr)
fixes issue #658, my account edit was missing this functionality
r3159 c.ldap_dn = c.user.ldap_dn
Renamed name to firstname in forms...
r2544 email = self.rhodecode_user.email
PEP8ify - controllers
r1245 _form = UserForm(edit=True,
Renamed name to firstname in forms...
r2544 old_data={'user_id': uid, 'email': email})()
renamed project to rhodecode
r547 form_result = {}
try:
form_result = _form.to_python(dict(request.POST))
fixes issue #658, my account edit was missing this functionality
r3159 skip_attrs = ['admin', 'active'] # skip attr for my account
if c.ldap_dn:
#forbid updating username for ldap accounts
skip_attrs.append('username')
UserModel().update(uid, form_result, skip_attrs=skip_attrs)
Added isanonymous decorator for checking permissions for anonymous access
r779 h.flash(_('Your account was updated successfully'),
renamed project to rhodecode
r547 category='success')
sqlalchemy sessions cleanup in admin...
r2662 Session().commit()
refactor codes and setup for python 2.5...
r564 except formencode.Invalid, errors:
fixes issue #658, my account edit was missing this functionality
r3159 #json used to render the grid
c.data = self._load_my_repos_data()
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
r2353 c.form = htmlfill.render(
render('admin/users/user_edit_my_account_form.html'),
renamed project to rhodecode
r547 defaults=errors.value,
errors=errors.error_dict or {},
prefix_error=False,
encoding="UTF-8")
highly improved performance of my_account page by removing super heavy htmlfill call on whole page
r2353 return render('admin/users/user_edit_my_account.html')
renamed project to rhodecode
r547 except Exception:
log.error(traceback.format_exc())
Mads Kiilerich
consistently capitalize initial letter in flash messages
r3565 h.flash(_('Error occurred during update of user %s') \
renamed project to rhodecode
r547 % form_result.get('username'), category='error')
Code refactoring,models renames...
r629
renamed project to rhodecode
r547 return redirect(url('my_account'))
sqlalchemy sessions cleanup in admin...
r2662
My account pages shouldn't be accessible by anonymous users
r2626 @NotAnonymous()
Added views for new ajax functions, got somehow lost in previos commit
r2625 def my_account_my_pullrequests(self):
Hide closed pull requests on my page.
r3404 c.show_closed = request.GET.get('pr_show_closed')
def _filter(pr):
s = sorted(pr, key=lambda o: o.created_on, reverse=True)
if not c.show_closed:
s = filter(lambda p: p.status != PullRequest.STATUS_CLOSED, s)
return s
c.my_pull_requests = _filter(PullRequest.query()\
Use common function for generation of grid data...
r3154 .filter(PullRequest.user_id ==
Added views for new ajax functions, got somehow lost in previos commit
r2625 self.rhodecode_user.user_id)\
Hide closed pull requests on my page.
r3404 .all())
show flags, and desc sort pull request based on created_date ref #765
r3389
Hide closed pull requests on my page.
r3404 c.participate_in_pull_requests = _filter([
x.pull_request for x in PullRequestReviewers.query()\
.filter(PullRequestReviewers.user_id ==
self.rhodecode_user.user_id).all()])
show flags, and desc sort pull request based on created_date ref #765
r3389
Added views for new ajax functions, got somehow lost in previos commit
r2625 return render('admin/users/user_edit_my_account_pullrequests.html')
Added isanonymous decorator for checking permissions for anonymous access
r779 @NotAnonymous()
renamed project to rhodecode
r547 def create_repository(self):
"""GET /_admin/create_repository: Form to create a new item"""
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder....
r3333 new_repo = request.GET.get('repo', '')
parent_group = request.GET.get('parent_group')
if not HasPermissionAny('hg.admin', 'hg.create.repository')():
#you're not super admin nor have global create permissions,
#but maybe you have at least write permission to a parent group ?
_gr = RepoGroup.get(parent_group)
gr_name = _gr.group_name if _gr else None
if not HasReposGroupPermissionAny('group.admin', 'group.write')(group_name=gr_name):
raise HTTPForbidden
added proper groups names in add repo from settings
r1161
filter out repo groups choices to only ones that you have write+ access to. Before it was read+ access and you got proper...
r3239 acl_groups = GroupList(RepoGroup.query().all(),
perm_set=['group.write', 'group.admin'])
c.repo_groups = RepoGroup.groups_choices(groups=acl_groups)
added proper groups names in add repo from settings
r1161 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
fixed typo in repo create
r2484 choices, c.landing_revs = ScmModel().get_repo_landing_revs()
added proper groups names in add repo from settings
r1161
Code refactor number 2
r1022 c.new_repo = repo_name_slug(new_repo)
added proper groups names in add repo from settings
r1161
Implemented #379 defaults settings page for creation of repositories...
r3056 ## apply the defaults from defaults page
defaults = RhodeCodeSetting.get_default_repo_settings(strip_prefix=True)
use the GET parent_group param to pre-fill the group choice
r3233 if parent_group:
defaults.update({'repo_group': parent_group})
Implemented #379 defaults settings page for creation of repositories...
r3056 return htmlfill.render(
Implemented #738 Giving a user WRITE+ permissions on folder should not allow repo creation in root folder....
r3333 render('admin/repos/repo_add.html'),
Implemented #379 defaults settings page for creation of repositories...
r3056 defaults=defaults,
errors={},
prefix_error=False,
encoding="UTF-8"
)
Code refactoring,models renames...
r629
Added form for controlling mercurial extensions...
r2708 def _get_hg_ui_settings(self):
sqlalchemy sessions cleanup in admin...
r2662 ret = RhodeCodeUi.query().all()
project refactoring, cleaned up lib.utils from rarly used functions, and place them...
r756
if not ret:
raise Exception('Could not get application ui settings !')
settings = {}
for each in ret:
k = each.ui_key
v = each.ui_value
if k == '/':
k = 'root_path'
fixed issue #560 require push ssl checkbox wasn't shown when option was enabled
r2821 if k == 'push_ssl':
v = str2bool(v)
project refactoring, cleaned up lib.utils from rarly used functions, and place them...
r756 if k.find('.') != -1:
k = k.replace('.', '_')
Added form for controlling mercurial extensions...
r2708 if each.ui_section in ['hooks', 'extensions']:
project refactoring, cleaned up lib.utils from rarly used functions, and place them...
r756 v = each.ui_active
settings[each.ui_section + '_' + k] = v
return settings