Show More
@@ -33,6 +33,7 b' from pylons import request, response, se' | |||||
33 | from rhodecode.lib.auth import LoginRequired, NotAnonymous |
|
33 | from rhodecode.lib.auth import LoginRequired, NotAnonymous | |
34 | from rhodecode.lib.base import BaseController, render |
|
34 | from rhodecode.lib.base import BaseController, render | |
35 | from rhodecode.lib.helpers import get_token |
|
35 | from rhodecode.lib.helpers import get_token | |
|
36 | from rhodecode.lib.utils import OrderedDict | |||
36 | from rhodecode.model.db import UserLog, UserFollowing |
|
37 | from rhodecode.model.db import UserLog, UserFollowing | |
37 | from rhodecode.model.scm import ScmModel |
|
38 | from rhodecode.model.scm import ScmModel | |
38 |
|
39 | |||
@@ -59,16 +60,29 b' class JournalController(BaseController):' | |||||
59 | user_ids = [x.follows_user.user_id for x in c.following |
|
60 | user_ids = [x.follows_user.user_id for x in c.following | |
60 | if x.follows_user is not None] |
|
61 | if x.follows_user is not None] | |
61 |
|
62 | |||
62 |
|
|
63 | journal = self.sa.query(UserLog)\ | |
63 | .filter(or_( |
|
64 | .filter(or_( | |
64 | UserLog.repository_id.in_(repo_ids), |
|
65 | UserLog.repository_id.in_(repo_ids), | |
65 | UserLog.user_id.in_(user_ids), |
|
66 | UserLog.user_id.in_(user_ids), | |
66 | ))\ |
|
67 | ))\ | |
67 | .order_by(UserLog.action_date.desc())\ |
|
68 | .order_by(UserLog.action_date.desc())\ | |
68 |
.limit( |
|
69 | .limit(30)\ | |
69 | .all() |
|
70 | .all() | |
|
71 | ||||
|
72 | c.journal_day_aggreagate = self._get_daily_aggregate(journal) | |||
|
73 | ||||
70 | return render('/journal.html') |
|
74 | return render('/journal.html') | |
71 |
|
75 | |||
|
76 | ||||
|
77 | def _get_daily_aggregate(self, journal): | |||
|
78 | from itertools import groupby | |||
|
79 | groups = [] | |||
|
80 | for k, g in groupby(journal, lambda x:x.action_as_day): | |||
|
81 | groups.append((k, list(g),)) # Store group iterator as a list | |||
|
82 | ||||
|
83 | return groups | |||
|
84 | ||||
|
85 | ||||
72 | def toggle_following(self): |
|
86 | def toggle_following(self): | |
73 | cur_token = request.POST.get('auth_token') |
|
87 | cur_token = request.POST.get('auth_token') | |
74 | token = get_token() |
|
88 | token = get_token() |
@@ -26,6 +26,7 b'' | |||||
26 | # MA 02110-1301, USA. |
|
26 | # MA 02110-1301, USA. | |
27 | import logging |
|
27 | import logging | |
28 | import datetime |
|
28 | import datetime | |
|
29 | from datetime import date | |||
29 |
|
30 | |||
30 | from sqlalchemy import * |
|
31 | from sqlalchemy import * | |
31 | from sqlalchemy.exc import DatabaseError |
|
32 | from sqlalchemy.exc import DatabaseError | |
@@ -150,6 +151,10 b' class UserLog(Base, BaseModel):' | |||||
150 | action = Column("action", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) |
|
151 | action = Column("action", String(length=None, convert_unicode=False, assert_unicode=None), nullable=True, unique=None, default=None) | |
151 | action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None) |
|
152 | action_date = Column("action_date", DateTime(timezone=False), nullable=True, unique=None, default=None) | |
152 |
|
153 | |||
|
154 | @property | |||
|
155 | def action_as_day(self): | |||
|
156 | return date(*self.action_date.timetuple()[:3]) | |||
|
157 | ||||
153 | user = relationship('User') |
|
158 | user = relationship('User') | |
154 | repository = relationship('Repository') |
|
159 | repository = relationship('Repository') | |
155 |
|
160 |
@@ -17,29 +17,32 b'' | |||||
17 | <h5>${_('Journal')}</h5> |
|
17 | <h5>${_('Journal')}</h5> | |
18 | </div> |
|
18 | </div> | |
19 | <div> |
|
19 | <div> | |
20 | %if c.journal: |
|
20 | %if c.journal_day_aggreagate: | |
21 |
%for |
|
21 | %for day,items in c.journal_day_aggreagate: | |
22 | <div style="padding:10px"> |
|
22 | <div style="font-size:20px;padding:10px 5px">${day}</div> | |
23 | <div class="gravatar"> |
|
23 | % for entry in items: | |
24 | <img alt="gravatar" src="${h.gravatar_url(entry.user.email)}"/> |
|
24 | <div style="padding:10px"> | |
25 |
< |
|
25 | <div class="gravatar"> | |
26 | <div>${entry.user.name} ${entry.user.lastname}</div> |
|
26 | <img alt="gravatar" src="${h.gravatar_url(entry.user.email)}"/> | |
27 | <div style="padding-left: 45px;padding-top:5px;min-height:20px">${h.action_parser(entry)}</div> |
|
27 | </div> | |
28 | <div style="float: left; padding-top: 8px;padding-left:18px"> |
|
28 | <div>${entry.user.name} ${entry.user.lastname}</div> | |
29 | ${h.action_parser_icon(entry)} |
|
29 | <div style="padding-left: 45px;padding-top:5px;min-height:20px">${h.action_parser(entry)}</div> | |
30 | </div> |
|
30 | <div style="float: left; padding-top: 8px;padding-left:18px"> | |
31 | <div style="margin-left: 45px;padding-top: 10px"> |
|
31 | ${h.action_parser_icon(entry)} | |
32 | <span style="font-weight: bold;font-size: 1.1em"> |
|
32 | </div> | |
33 | %if entry.repository: |
|
33 | <div style="margin-left: 45px;padding-top: 10px"> | |
34 | ${h.link_to(entry.repository.repo_name, |
|
34 | <span style="font-weight: bold;font-size: 1.1em"> | |
35 | h.url('summary_home',repo_name=entry.repository.repo_name))} |
|
35 | %if entry.repository: | |
36 | %else: |
|
36 | ${h.link_to(entry.repository.repo_name, | |
37 | ${entry.repository_name} |
|
37 | h.url('summary_home',repo_name=entry.repository.repo_name))} | |
38 | %endif |
|
38 | %else: | |
39 | </span> - <span title="${entry.action_date}">${h.age(entry.action_date)}</span> |
|
39 | ${entry.repository_name} | |
40 | </div> |
|
40 | %endif | |
41 | </div> |
|
41 | </span> - <span title="${entry.action_date}">${h.age(entry.action_date)}</span> | |
42 | <div style="clear:both;border-bottom:1px dashed #DDD;padding:3px 3px;margin:0px 10px 0px 10px"></div> |
|
42 | </div> | |
|
43 | </div> | |||
|
44 | <div style="clear:both;border-bottom:1px dashed #DDD;padding:3px 3px;margin:0px 10px 0px 10px"></div> | |||
|
45 | %endfor | |||
43 | %endfor |
|
46 | %endfor | |
44 | %else: |
|
47 | %else: | |
45 | ${_('No entries yet')} |
|
48 | ${_('No entries yet')} |
General Comments 0
You need to be logged in to leave comments.
Login now