##// END OF EJS Templates
fixes for stable
fixes for stable

File last commit:

r1217:a3b2b4b4 default
r1231:9f656066 default
Show More
journal.py
98 lines | 3.3 KiB | text/x-python | PythonLexer
updated docs on every controller
r861 # -*- coding: utf-8 -*-
"""
rhodecode.controllers.journal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Journal controller for pylons
:created_on: Nov 21, 2010
:author: marcink
:copyright: (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
:license: GPLv3, see COPYING for more details.
"""
fixes for issue #149
r1217 # 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.
#
implemented user dashboards, and following system.
r734 # 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.
fixes for issue #149
r1217 #
implemented user dashboards, and following system.
r734 # You should have received a copy of the GNU General Public License
fixes for issue #149
r1217 # along with this program. If not, see <http://www.gnu.org/licenses/>.
updated docs on every controller
r861
import logging
changes for release 1.1.5
r1136 import traceback
implemented user dashboards, and following system.
r734
from pylons import request, response, session, tmpl_context as c, url
changes for release 1.1.5
r1136 from paste.httpexceptions import HTTPInternalServerError, HTTPBadRequest
from sqlalchemy import or_
updated docs on every controller
r861
disabled journal for anonymous users
r793 from rhodecode.lib.auth import LoginRequired, NotAnonymous
implemented user dashboards, and following system.
r734 from rhodecode.lib.base import BaseController, render
from rhodecode.lib.helpers import get_token
from rhodecode.model.db import UserLog, UserFollowing
from rhodecode.model.scm import ScmModel
updated docs on every controller
r861
implemented user dashboards, and following system.
r734 log = logging.getLogger(__name__)
class JournalController(BaseController):
@LoginRequired()
disabled journal for anonymous users
r793 @NotAnonymous()
implemented user dashboards, and following system.
r734 def __before__(self):
super(JournalController, self).__before__()
def index(self):
# Return a rendered template
c.following = self.sa.query(UserFollowing)\
.filter(UserFollowing.user_id == c.rhodecode_user.user_id).all()
disabled journal for anonymous users
r793
repo_ids = [x.follows_repository.repo_id for x in c.following
activated filters for user journal for following users/repos only
r736 if x.follows_repository is not None]
disabled journal for anonymous users
r793 user_ids = [x.follows_user.user_id for x in c.following
activated filters for user journal for following users/repos only
r736 if x.follows_user is not None]
disabled journal for anonymous users
r793
implemented user dashboards, and following system.
r734 c.journal = self.sa.query(UserLog)\
activated filters for user journal for following users/repos only
r736 .filter(or_(
UserLog.repository_id.in_(repo_ids),
UserLog.user_id.in_(user_ids),
))\
implemented user dashboards, and following system.
r734 .order_by(UserLog.action_date.desc())\
added limit for user journal
r738 .limit(20)\
implemented user dashboards, and following system.
r734 .all()
return render('/journal.html')
def toggle_following(self):
if request.POST.get('auth_token') == get_token():
scm_model = ScmModel()
user_id = request.POST.get('follows_user_id')
if user_id:
try:
scm_model.toggle_following_user(user_id,
c.rhodecode_user.user_id)
return 'ok'
except:
changes for release 1.1.5
r1136 log.error(traceback.format_exc())
implemented user dashboards, and following system.
r734 raise HTTPInternalServerError()
repo_id = request.POST.get('follows_repo_id')
if repo_id:
try:
scm_model.toggle_following_repo(repo_id,
c.rhodecode_user.user_id)
return 'ok'
except:
changes for release 1.1.5
r1136 log.error(traceback.format_exc())
implemented user dashboards, and following system.
r734 raise HTTPInternalServerError()
changes for release 1.1.5
r1136 raise HTTPBadRequest()