##// END OF EJS Templates
fixed wrong order of changes in feeds...
fixed wrong order of changes in feeds added some extra info into rss and atom feed ie. changed/modified/deleted files

File last commit:

r1136:93b980eb default
r1162:76c5b69c beta
Show More
journal.py
248 lines | 8.6 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
fixed copyright year to 2011
r902 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
updated docs on every controller
r861 :license: GPLv3, see COPYING for more details.
"""
implemented user dashboards, and following system.
r734 # 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; version 2
# of the License or (at your opinion) any later version of the license.
#
# 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 General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
updated docs on every controller
r861 import logging
implemented user dashboards, and following system.
r734
Updated new Journal with users and dates aggregates
r1041 from sqlalchemy import or_
from sqlalchemy.orm import joinedload, make_transient
from webhelpers.paginate import Page
another major codes rewrite:...
r1045 from itertools import groupby
updated docs on every controller
r861
Updated new Journal with users and dates aggregates
r1041 from paste.httpexceptions import HTTPInternalServerError
made simple global rss and atom feed
r1088 from pylons import request, tmpl_context as c, response, url
from pylons.i18n.translation import _
from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
fixes for journal, added paging now it's possible to view whole journal...
r995
made simple global rss and atom feed
r1088 import rhodecode.lib.helpers as h
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.model.db import UserLog, UserFollowing
updated docs on every controller
r861
implemented user dashboards, and following system.
r734 log = logging.getLogger(__name__)
class JournalController(BaseController):
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal...
r1120
implemented user dashboards, and following system.
r734 def __before__(self):
super(JournalController, self).__before__()
replaced all global calls to template context (rhodecode_user), into instance attributes
r1121 self.rhodecode_user = self.rhodecode_user
made simple global rss and atom feed
r1088 self.title = _('%s public journal %s feed') % (c.rhodecode_name, '%s')
self.language = 'en-us'
self.ttl = "5"
self.feed_nr = 20
implemented user dashboards, and following system.
r734
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal...
r1120 @LoginRequired()
implemented public journal for anonymous users, admin can control which repositories...
r1085 @NotAnonymous()
implemented user dashboards, and following system.
r734 def index(self):
# Return a rendered template
implemented public journal for anonymous users, admin can control which repositories...
r1085 p = int(request.params.get('page', 1))
another major codes rewrite:...
r1045
implemented user dashboards, and following system.
r734 c.following = self.sa.query(UserFollowing)\
Major rewrite of auth objects. Moved parts of filling user data into user model....
r1117 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
Optimized queries on journal, and added quick stop following action button in journal
r1000 .options(joinedload(UserFollowing.follows_repository))\
.all()
disabled journal for anonymous users
r793
implemented public journal for anonymous users, admin can control which repositories...
r1085 journal = self._get_journal_data(c.following)
Added grouping by days in journal
r994
another major codes rewrite:...
r1045 c.journal_pager = Page(journal, page=p, items_per_page=20)
fixes for journal, added paging now it's possible to view whole journal...
r995 c.journal_day_aggreagate = self._get_daily_aggregate(c.journal_pager)
another major codes rewrite:...
r1045
fixes for journal, added paging now it's possible to view whole journal...
r995 c.journal_data = render('journal/journal_data.html')
if request.params.get('partial'):
return c.journal_data
return render('journal/journal.html')
implemented user dashboards, and following system.
r734
Added grouping by days in journal
r994
def _get_daily_aggregate(self, journal):
groups = []
for k, g in groupby(journal, lambda x:x.action_as_day):
Updated new Journal with users and dates aggregates
r1041 user_group = []
for k2, g2 in groupby(list(g), lambda x:x.user.email):
l = list(g2)
user_group.append((l[0].user, l))
groups.append((k, user_group,))
Added grouping by days in journal
r994
return groups
implemented public journal for anonymous users, admin can control which repositories...
r1085 def _get_journal_data(self, following_repos):
repo_ids = [x.follows_repository.repo_id for x in following_repos
if x.follows_repository is not None]
user_ids = [x.follows_user.user_id for x in following_repos
if x.follows_user is not None]
filtering_criterion = None
if repo_ids and user_ids:
filtering_criterion = or_(UserLog.repository_id.in_(repo_ids),
UserLog.user_id.in_(user_ids))
if repo_ids and not user_ids:
filtering_criterion = UserLog.repository_id.in_(repo_ids)
if not repo_ids and user_ids:
filtering_criterion = UserLog.user_id.in_(user_ids)
if filtering_criterion is not None:
journal = self.sa.query(UserLog)\
.options(joinedload(UserLog.user))\
.options(joinedload(UserLog.repository))\
.filter(filtering_criterion)\
.order_by(UserLog.action_date.desc())
else:
journal = []
return journal
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal...
r1120 @LoginRequired()
implemented public journal for anonymous users, admin can control which repositories...
r1085 @NotAnonymous()
implemented user dashboards, and following system.
r734 def toggle_following(self):
tests update
r875 cur_token = request.POST.get('auth_token')
made simple global rss and atom feed
r1088 token = h.get_token()
tests update
r875 if cur_token == token:
implemented user dashboards, and following system.
r734
user_id = request.POST.get('follows_user_id')
if user_id:
try:
another major codes rewrite:...
r1045 self.scm_model.toggle_following_user(user_id,
Major rewrite of auth objects. Moved parts of filling user data into user model....
r1117 self.rhodecode_user.user_id)
implemented user dashboards, and following system.
r734 return 'ok'
except:
raise HTTPInternalServerError()
repo_id = request.POST.get('follows_repo_id')
if repo_id:
try:
another major codes rewrite:...
r1045 self.scm_model.toggle_following_repo(repo_id,
Major rewrite of auth objects. Moved parts of filling user data into user model....
r1117 self.rhodecode_user.user_id)
implemented user dashboards, and following system.
r734 return 'ok'
except:
raise HTTPInternalServerError()
tests update
r875 log.debug('token mismatch %s vs %s', cur_token, token)
implemented user dashboards, and following system.
r734 raise HTTPInternalServerError()
implemented public journal for anonymous users, admin can control which repositories...
r1085
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal...
r1120 @LoginRequired()
implemented public journal for anonymous users, admin can control which repositories...
r1085 def public_journal(self):
# Return a rendered template
p = int(request.params.get('page', 1))
c.following = self.sa.query(UserFollowing)\
Major rewrite of auth objects. Moved parts of filling user data into user model....
r1117 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
implemented public journal for anonymous users, admin can control which repositories...
r1085 .options(joinedload(UserFollowing.follows_repository))\
.all()
journal = self._get_journal_data(c.following)
c.journal_pager = Page(journal, page=p, items_per_page=20)
c.journal_day_aggreagate = self._get_daily_aggregate(c.journal_pager)
c.journal_data = render('journal/journal_data.html')
if request.params.get('partial'):
return c.journal_data
return render('journal/public_journal.html')
made simple global rss and atom feed
r1088
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal...
r1120 @LoginRequired(api_access=True)
made simple global rss and atom feed
r1088 def public_journal_atom(self):
"""
Produce an atom-1.0 feed via feedgenerator module
"""
c.following = self.sa.query(UserFollowing)\
Major rewrite of auth objects. Moved parts of filling user data into user model....
r1117 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
made simple global rss and atom feed
r1088 .options(joinedload(UserFollowing.follows_repository))\
.all()
journal = self._get_journal_data(c.following)
feed = Atom1Feed(title=self.title % 'atom',
link=url('public_journal_atom', qualified=True),
description=_('Public journal'),
language=self.language,
ttl=self.ttl)
for entry in journal[:self.feed_nr]:
#tmpl = h.action_parser(entry)[0]
action, action_extra = h.action_parser(entry, feed=True)
title = "%s - %s %s" % (entry.user.short_contact, action,
entry.repository.repo_name)
desc = action_extra()
feed.add_item(title=title,
pubdate=entry.action_date,
link=url('', qualified=True),
author_email=entry.user.email,
author_name=entry.user.full_contact,
description=desc)
response.content_type = feed.mime_type
return feed.writeString('utf-8')
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal...
r1120 @LoginRequired(api_access=True)
made simple global rss and atom feed
r1088 def public_journal_rss(self):
"""
Produce an rss2 feed via feedgenerator module
"""
c.following = self.sa.query(UserFollowing)\
Major rewrite of auth objects. Moved parts of filling user data into user model....
r1117 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\
made simple global rss and atom feed
r1088 .options(joinedload(UserFollowing.follows_repository))\
.all()
journal = self._get_journal_data(c.following)
feed = Rss201rev2Feed(title=self.title % 'rss',
link=url('public_journal_rss', qualified=True),
description=_('Public journal'),
language=self.language,
ttl=self.ttl)
for entry in journal[:self.feed_nr]:
#tmpl = h.action_parser(entry)[0]
action, action_extra = h.action_parser(entry, feed=True)
title = "%s - %s %s" % (entry.user.short_contact, action,
entry.repository.repo_name)
desc = action_extra()
feed.add_item(title=title,
pubdate=entry.action_date,
link=url('', qualified=True),
author_email=entry.user.email,
author_name=entry.user.full_contact,
description=desc)
response.content_type = feed.mime_type
return feed.writeString('utf-8')