Mercurial > kallithea
annotate rhodecode/controllers/journal.py @ 2587:c1c66976001a beta
added optional args to tox script, and fixed mysql commands
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 11 Jul 2012 01:37:11 +0200 |
parents | 9f37281195a2 |
children | 63e58ef80ef1 6b176c679896 |
rev | line source |
---|---|
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
1 # -*- coding: utf-8 -*- |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
2 """ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
3 rhodecode.controllers.journal |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
5 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
6 Journal controller for pylons |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1175
diff
changeset
|
7 |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
8 :created_on: Nov 21, 2010 |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
9 :author: marcink |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
12 """ |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
16 # (at your option) any later version. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1175
diff
changeset
|
17 # |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1175
diff
changeset
|
22 # |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
1206
a671db5bdd58
fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
25 import logging |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
26 from itertools import groupby |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
1041
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
28 from sqlalchemy import or_ |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
29 from sqlalchemy.orm import joinedload |
1041
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
30 from webhelpers.paginate import Page |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
31 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
32 |
2242
87e9718ab4a2
Use webob exception as often as possible
Marcin Kuzminski <marcin@python-works.com>
parents:
1976
diff
changeset
|
33 from webob.exc import HTTPBadRequest |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
34 from pylons import request, tmpl_context as c, response, url |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
35 from pylons.i18n.translation import _ |
995
d14723711d17
fixes for journal, added paging now it's possible to view whole journal
Marcin Kuzminski <marcin@python-works.com>
parents:
994
diff
changeset
|
36 |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
37 import rhodecode.lib.helpers as h |
793
3025b0f9475e
disabled journal for anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
738
diff
changeset
|
38 from rhodecode.lib.auth import LoginRequired, NotAnonymous |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 from rhodecode.lib.base import BaseController, render |
1741
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
40 from rhodecode.model.db import UserLog, UserFollowing, Repository, User |
1722
e7eef7a1db6a
#235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents:
1421
diff
changeset
|
41 from rhodecode.model.meta import Session |
1741
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
42 from sqlalchemy.sql.expression import func |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
43 from rhodecode.model.scm import ScmModel |
861
fd2ea6ceadc8
updated docs on every controller
Marcin Kuzminski <marcin@python-works.com>
parents:
793
diff
changeset
|
44 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 log = logging.getLogger(__name__) |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 |
1212 | 47 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 class JournalController(BaseController): |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 def __before__(self): |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 super(JournalController, self).__before__() |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
52 self.language = 'en-us' |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
53 self.ttl = "5" |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
54 self.feed_nr = 20 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 |
1120
a8d759613d8f
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal
Marcin Kuzminski <marcin@python-works.com>
parents:
1117
diff
changeset
|
56 @LoginRequired() |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
57 @NotAnonymous() |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 def index(self): |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 # Return a rendered template |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
60 p = int(request.params.get('page', 1)) |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
61 |
1741
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
62 c.user = User.get(self.rhodecode_user.user_id) |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
63 all_repos = self.sa.query(Repository)\ |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
64 .filter(Repository.user_id == c.user.user_id)\ |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
65 .order_by(func.lower(Repository.repo_name)).all() |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
66 |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
67 c.user_repos = ScmModel().get_repos(all_repos) |
fcbc35ecb024
personal Journal UI
Marcin Kuzminski <marcin@python-works.com>
parents:
1722
diff
changeset
|
68 |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 c.following = self.sa.query(UserFollowing)\ |
1117
6eb5bb24a948
Major rewrite of auth objects. Moved parts of filling user data into user model.
Marcin Kuzminski <marcin@python-works.com>
parents:
1088
diff
changeset
|
70 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ |
1000
229437211bef
Optimized queries on journal, and added quick stop following action button in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
995
diff
changeset
|
71 .options(joinedload(UserFollowing.follows_repository))\ |
229437211bef
Optimized queries on journal, and added quick stop following action button in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
995
diff
changeset
|
72 .all() |
793
3025b0f9475e
disabled journal for anonymous users
Marcin Kuzminski <marcin@python-works.com>
parents:
738
diff
changeset
|
73 |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
74 journal = self._get_journal_data(c.following) |
994
7f9d23f6a526
Added grouping by days in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
75 |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
76 c.journal_pager = Page(journal, page=p, items_per_page=20) |
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
77 |
995
d14723711d17
fixes for journal, added paging now it's possible to view whole journal
Marcin Kuzminski <marcin@python-works.com>
parents:
994
diff
changeset
|
78 c.journal_day_aggreagate = self._get_daily_aggregate(c.journal_pager) |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
79 |
995
d14723711d17
fixes for journal, added paging now it's possible to view whole journal
Marcin Kuzminski <marcin@python-works.com>
parents:
994
diff
changeset
|
80 c.journal_data = render('journal/journal_data.html') |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
81 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
995
d14723711d17
fixes for journal, added paging now it's possible to view whole journal
Marcin Kuzminski <marcin@python-works.com>
parents:
994
diff
changeset
|
82 return c.journal_data |
d14723711d17
fixes for journal, added paging now it's possible to view whole journal
Marcin Kuzminski <marcin@python-works.com>
parents:
994
diff
changeset
|
83 return render('journal/journal.html') |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 |
2397
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
85 @LoginRequired(api_access=True) |
2410
a1595b6e1445
Add API access to personal journal, and forbid anonymous access on them
Marcin Kuzminski <marcin@python-works.com>
parents:
2397
diff
changeset
|
86 @NotAnonymous() |
2397
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
87 def journal_atom(self): |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
88 """ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
89 Produce an atom-1.0 feed via feedgenerator module |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
90 """ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
91 following = self.sa.query(UserFollowing)\ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
92 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
93 .options(joinedload(UserFollowing.follows_repository))\ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
94 .all() |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
95 return self._atom_feed(following, public=False) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
96 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
97 @LoginRequired(api_access=True) |
2410
a1595b6e1445
Add API access to personal journal, and forbid anonymous access on them
Marcin Kuzminski <marcin@python-works.com>
parents:
2397
diff
changeset
|
98 @NotAnonymous() |
2397
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
99 def journal_rss(self): |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
100 """ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
101 Produce an rss feed via feedgenerator module |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
102 """ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
103 following = self.sa.query(UserFollowing)\ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
104 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
105 .options(joinedload(UserFollowing.follows_repository))\ |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
106 .all() |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
107 return self._rss_feed(following, public=False) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
108 |
994
7f9d23f6a526
Added grouping by days in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
109 def _get_daily_aggregate(self, journal): |
7f9d23f6a526
Added grouping by days in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
110 groups = [] |
1212 | 111 for k, g in groupby(journal, lambda x: x.action_as_day): |
1041
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
112 user_group = [] |
1212 | 113 for k2, g2 in groupby(list(g), lambda x: x.user.email): |
1041
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
114 l = list(g2) |
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
115 user_group.append((l[0].user, l)) |
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
116 |
98be43b888c4
Updated new Journal with users and dates aggregates
Marcin Kuzminski <marcin@python-works.com>
parents:
1019
diff
changeset
|
117 groups.append((k, user_group,)) |
994
7f9d23f6a526
Added grouping by days in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
118 |
7f9d23f6a526
Added grouping by days in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
119 return groups |
7f9d23f6a526
Added grouping by days in journal
Marcin Kuzminski <marcin@python-works.com>
parents:
902
diff
changeset
|
120 |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
121 def _get_journal_data(self, following_repos): |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
122 repo_ids = [x.follows_repository.repo_id for x in following_repos |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
123 if x.follows_repository is not None] |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
124 user_ids = [x.follows_user.user_id for x in following_repos |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
125 if x.follows_user is not None] |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
126 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
127 filtering_criterion = None |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
128 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
129 if repo_ids and user_ids: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
130 filtering_criterion = or_(UserLog.repository_id.in_(repo_ids), |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
131 UserLog.user_id.in_(user_ids)) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
132 if repo_ids and not user_ids: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
133 filtering_criterion = UserLog.repository_id.in_(repo_ids) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
134 if not repo_ids and user_ids: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
135 filtering_criterion = UserLog.user_id.in_(user_ids) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
136 if filtering_criterion is not None: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
137 journal = self.sa.query(UserLog)\ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
138 .options(joinedload(UserLog.user))\ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
139 .options(joinedload(UserLog.repository))\ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
140 .filter(filtering_criterion)\ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
141 .order_by(UserLog.action_date.desc()) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
142 else: |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
143 journal = [] |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
144 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
145 return journal |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
146 |
1120
a8d759613d8f
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal
Marcin Kuzminski <marcin@python-works.com>
parents:
1117
diff
changeset
|
147 @LoginRequired() |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
148 @NotAnonymous() |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 def toggle_following(self): |
875 | 150 cur_token = request.POST.get('auth_token') |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
151 token = h.get_token() |
875 | 152 if cur_token == token: |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
153 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
154 user_id = request.POST.get('follows_user_id') |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
155 if user_id: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
156 try: |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
157 self.scm_model.toggle_following_user(user_id, |
1212 | 158 self.rhodecode_user.user_id) |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1741
diff
changeset
|
159 Session.commit() |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 return 'ok' |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
161 except: |
1175
8c0a57a4b89b
Journal Should not return 500 errors on failure, rather better is to return bad request error
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
162 raise HTTPBadRequest() |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
163 |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
164 repo_id = request.POST.get('follows_repo_id') |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
165 if repo_id: |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
166 try: |
1045
3fc9183e05dd
another major codes rewrite:
Marcin Kuzminski <marcin@python-works.com>
parents:
1041
diff
changeset
|
167 self.scm_model.toggle_following_repo(repo_id, |
1212 | 168 self.rhodecode_user.user_id) |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1741
diff
changeset
|
169 Session.commit() |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
170 return 'ok' |
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
171 except: |
1175
8c0a57a4b89b
Journal Should not return 500 errors on failure, rather better is to return bad request error
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
172 raise HTTPBadRequest() |
734
49eb69d78988
implemented user dashboards, and following system.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
173 |
1976 | 174 log.debug('token mismatch %s vs %s' % (cur_token, token)) |
1175
8c0a57a4b89b
Journal Should not return 500 errors on failure, rather better is to return bad request error
Marcin Kuzminski <marcin@python-works.com>
parents:
1121
diff
changeset
|
175 raise HTTPBadRequest() |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
176 |
1120
a8d759613d8f
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal
Marcin Kuzminski <marcin@python-works.com>
parents:
1117
diff
changeset
|
177 @LoginRequired() |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
178 def public_journal(self): |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
179 # Return a rendered template |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
180 p = int(request.params.get('page', 1)) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
181 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
182 c.following = self.sa.query(UserFollowing)\ |
1117
6eb5bb24a948
Major rewrite of auth objects. Moved parts of filling user data into user model.
Marcin Kuzminski <marcin@python-works.com>
parents:
1088
diff
changeset
|
183 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
184 .options(joinedload(UserFollowing.follows_repository))\ |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
185 .all() |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
186 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
187 journal = self._get_journal_data(c.following) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
188 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
189 c.journal_pager = Page(journal, page=p, items_per_page=20) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
190 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
191 c.journal_day_aggreagate = self._get_daily_aggregate(c.journal_pager) |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
192 |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
193 c.journal_data = render('journal/journal_data.html') |
1421
c6b811f11c94
Javascripts rewrite: updated yui to latest 2.9, simplified ajax loading for multiple pages. Removed YUI dev package
Marcin Kuzminski <marcin@python-works.com>
parents:
1212
diff
changeset
|
194 if request.environ.get('HTTP_X_PARTIAL_XHR'): |
1085
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
195 return c.journal_data |
3fe3285868d1
implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents:
1045
diff
changeset
|
196 return render('journal/public_journal.html') |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
197 |
2397
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
198 def _atom_feed(self, repos, public=True): |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
199 journal = self._get_journal_data(repos) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
200 if public: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
201 _link = url('public_journal_atom', qualified=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
202 _desc = '%s %s %s' % (c.rhodecode_name, _('public journal'), |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
203 'atom feed') |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
204 else: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
205 _link = url('journal_atom', qualified=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
206 _desc = '%s %s %s' % (c.rhodecode_name, _('journal'), 'atom feed') |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
207 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
208 feed = Atom1Feed(title=_desc, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
209 link=_link, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
210 description=_desc, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
211 language=self.language, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
212 ttl=self.ttl) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
213 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
214 for entry in journal[:self.feed_nr]: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
215 action, action_extra, ico = h.action_parser(entry, feed=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
216 title = "%s - %s %s" % (entry.user.short_contact, action(), |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
217 entry.repository.repo_name) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
218 desc = action_extra() |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
219 _url = None |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
220 if entry.repository is not None: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
221 _url = url('changelog_home', |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
222 repo_name=entry.repository.repo_name, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
223 qualified=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
224 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
225 feed.add_item(title=title, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
226 pubdate=entry.action_date, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
227 link=_url or url('', qualified=True), |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
228 author_email=entry.user.email, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
229 author_name=entry.user.full_contact, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
230 description=desc) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
231 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
232 response.content_type = feed.mime_type |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
233 return feed.writeString('utf-8') |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
234 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
235 def _rss_feed(self, repos, public=True): |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
236 journal = self._get_journal_data(repos) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
237 if public: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
238 _link = url('public_journal_atom', qualified=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
239 _desc = '%s %s %s' % (c.rhodecode_name, _('public journal'), |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
240 'rss feed') |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
241 else: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
242 _link = url('journal_atom', qualified=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
243 _desc = '%s %s %s' % (c.rhodecode_name, _('journal'), 'rss feed') |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
244 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
245 feed = Rss201rev2Feed(title=_desc, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
246 link=_link, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
247 description=_desc, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
248 language=self.language, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
249 ttl=self.ttl) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
250 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
251 for entry in journal[:self.feed_nr]: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
252 action, action_extra, ico = h.action_parser(entry, feed=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
253 title = "%s - %s %s" % (entry.user.short_contact, action(), |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
254 entry.repository.repo_name) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
255 desc = action_extra() |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
256 _url = None |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
257 if entry.repository is not None: |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
258 _url = url('changelog_home', |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
259 repo_name=entry.repository.repo_name, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
260 qualified=True) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
261 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
262 feed.add_item(title=title, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
263 pubdate=entry.action_date, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
264 link=_url or url('', qualified=True), |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
265 author_email=entry.user.email, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
266 author_name=entry.user.full_contact, |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
267 description=desc) |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
268 |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
269 response.content_type = feed.mime_type |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
270 return feed.writeString('utf-8') |
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
271 |
1120
a8d759613d8f
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal
Marcin Kuzminski <marcin@python-works.com>
parents:
1117
diff
changeset
|
272 @LoginRequired(api_access=True) |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
273 def public_journal_atom(self): |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
274 """ |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
275 Produce an atom-1.0 feed via feedgenerator module |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
276 """ |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
277 c.following = self.sa.query(UserFollowing)\ |
1117
6eb5bb24a948
Major rewrite of auth objects. Moved parts of filling user data into user model.
Marcin Kuzminski <marcin@python-works.com>
parents:
1088
diff
changeset
|
278 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
279 .options(joinedload(UserFollowing.follows_repository))\ |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
280 .all() |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
281 |
2397
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
282 return self._atom_feed(c.following) |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
283 |
1120
a8d759613d8f
fixed some bugs in api key auth, added access by api key into rss/atom feeds in global journal
Marcin Kuzminski <marcin@python-works.com>
parents:
1117
diff
changeset
|
284 @LoginRequired(api_access=True) |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
285 def public_journal_rss(self): |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
286 """ |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
287 Produce an rss2 feed via feedgenerator module |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
288 """ |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
289 c.following = self.sa.query(UserFollowing)\ |
1117
6eb5bb24a948
Major rewrite of auth objects. Moved parts of filling user data into user model.
Marcin Kuzminski <marcin@python-works.com>
parents:
1088
diff
changeset
|
290 .filter(UserFollowing.user_id == self.rhodecode_user.user_id)\ |
1088
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
291 .options(joinedload(UserFollowing.follows_repository))\ |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
292 .all() |
fee472613dfa
made simple global rss and atom feed
Marcin Kuzminski <marcin@python-works.com>
parents:
1085
diff
changeset
|
293 |
2397
d815d617eb5e
added rss/atom feeds into personalized journal
Marcin Kuzminski <marcin@python-works.com>
parents:
2390
diff
changeset
|
294 return self._rss_feed(c.following) |