##// END OF EJS Templates
repo-reviewers: expose a default placeholder on CE edition....
repo-reviewers: expose a default placeholder on CE edition. - shows the menu consistent - adds preview of prominent EE feature

File last commit:

r1696:089e4a01 default
r1725:d7c1b491 default
Show More
admin.py
89 lines | 2.9 KiB | text/x-python | PythonLexer
project: added all source files and assets
r1 # -*- coding: utf-8 -*-
license: updated copyright year to 2017
r1271 # Copyright (C) 2010-2017 RhodeCode GmbH
project: added all source files and assets
r1 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# 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.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
"""
Controller for Admin panel of RhodeCode Enterprise
"""
import logging
from pylons import request, tmpl_context as c, url
from pylons.controllers.util import redirect
from sqlalchemy.orm import joinedload
from rhodecode.model.db import UserLog, PullRequest
admin-users: add audit page to allow showing user actions in RhodeCode....
r1559 from rhodecode.lib.user_log_filter import user_log_filter
project: added all source files and assets
r1 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator
from rhodecode.lib.base import BaseController, render
admin-users: add audit page to allow showing user actions in RhodeCode....
r1559 from rhodecode.lib.utils2 import safe_int
project: added all source files and assets
r1 from rhodecode.lib.helpers import Page
log = logging.getLogger(__name__)
class AdminController(BaseController):
@LoginRequired()
def __before__(self):
super(AdminController, self).__before__()
@HasPermissionAllDecorator('hg.admin')
def index(self):
users_log = UserLog.query()\
.options(joinedload(UserLog.user))\
.options(joinedload(UserLog.repository))
# FILTERING
c.search_term = request.GET.get('filter')
try:
admin-users: add audit page to allow showing user actions in RhodeCode....
r1559 users_log = user_log_filter(users_log, c.search_term)
project: added all source files and assets
r1 except Exception:
# we want this to crash for now
raise
users_log = users_log.order_by(UserLog.action_date.desc())
p = safe_int(request.GET.get('page', 1), 1)
def url_generator(**kw):
return url.current(filter=c.search_term, **kw)
user-audit: share same template for rendering audit logs between user and admin views.
r1696 c.audit_logs = Page(users_log, page=p, items_per_page=10,
project: added all source files and assets
r1 url=url_generator)
templating: use .mako as extensions for template files.
r1282 c.log_data = render('admin/admin_log.mako')
project: added all source files and assets
r1
if request.is_xhr:
return c.log_data
templating: use .mako as extensions for template files.
r1282 return render('admin/admin.mako')
project: added all source files and assets
r1
# global redirect doesn't need permissions
def pull_requests(self, pull_request_id):
"""
Global redirect for Pull Requests
:param pull_request_id: id of pull requests in the system
"""
pull_request = PullRequest.get_or_404(pull_request_id)
repo_name = pull_request.target_repo.repo_name
return redirect(url(
'pullrequest_show', repo_name=repo_name,
pull_request_id=pull_request_id))