changeset 1041:98be43b888c4 beta

Updated new Journal with users and dates aggregates
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 13 Feb 2011 03:39:28 +0100
parents 8e49b6ceffe1
children ab0a2b69d082
files rhodecode/controllers/journal.py rhodecode/lib/helpers.py rhodecode/public/css/style.css rhodecode/templates/journal/journal_data.html
diffstat 4 files changed, 54 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/journal.py	Sun Feb 13 02:48:02 2011 +0100
+++ b/rhodecode/controllers/journal.py	Sun Feb 13 03:39:28 2011 +0100
@@ -24,13 +24,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
-
 import logging
-from sqlalchemy import or_
 
-from pylons import request, response, session, tmpl_context as c, url
+from sqlalchemy import or_
+from sqlalchemy.orm import joinedload, make_transient
+from webhelpers.paginate import Page
 
-from webhelpers.paginate import Page
+from paste.httpexceptions import HTTPInternalServerError
+from pylons import request, response, session, tmpl_context as c, url
 
 from rhodecode.lib.auth import LoginRequired, NotAnonymous
 from rhodecode.lib.base import BaseController, render
@@ -38,9 +39,6 @@
 from rhodecode.model.db import UserLog, UserFollowing
 from rhodecode.model.scm import ScmModel
 
-from paste.httpexceptions import HTTPInternalServerError
-from sqlalchemy.orm import joinedload
-
 log = logging.getLogger(__name__)
 
 class JournalController(BaseController):
@@ -53,12 +51,12 @@
 
     def index(self):
         # Return a rendered template
-
         c.following = self.sa.query(UserFollowing)\
             .filter(UserFollowing.user_id == c.rhodecode_user.user_id)\
             .options(joinedload(UserFollowing.follows_repository))\
             .all()
 
+
         repo_ids = [x.follows_repository.repo_id for x in c.following
                     if x.follows_repository is not None]
         user_ids = [x.follows_user.user_id for x in c.following
@@ -76,6 +74,8 @@
 
         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:
@@ -95,7 +95,12 @@
         from itertools import groupby
         groups = []
         for k, g in groupby(journal, lambda x:x.action_as_day):
-            groups.append((k, list(g),))      # Store group iterator as a list
+            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,))
 
         return groups
 
--- a/rhodecode/lib/helpers.py	Sun Feb 13 02:48:02 2011 +0100
+++ b/rhodecode/lib/helpers.py	Sun Feb 13 03:39:28 2011 +0100
@@ -475,6 +475,7 @@
                 repo_name=repo_name, revision=rev),
                 title=message(rev), class_='tooltip')
                 for rev in revs[revs_limit:revs_top_limit]]))
+        cs_links += _(' into')
         if len(revs) > 1:
             cs_links += compare_view
         return cs_links
@@ -489,18 +490,18 @@
                                           repo_name=repo.name,),
                                           title=dbrepo.description)
 
-    map = {'user_deleted_repo':(_('User [deleted] repository'), None),
-           'user_created_repo':(_('User [created] repository'), None),
-           'user_forked_repo':(_('User [forked] repository as:'), get_fork_name),
-           'user_updated_repo':(_('User [updated] repository'), None),
-           'admin_deleted_repo':(_('Admin [delete] repository'), None),
-           'admin_created_repo':(_('Admin [created] repository'), None),
-           'admin_forked_repo':(_('Admin [forked] repository'), None),
-           'admin_updated_repo':(_('Admin [updated] repository'), None),
-           'push':(_('[Pushed]'), get_cs_links),
-           'pull':(_('[Pulled]'), None),
-           'started_following_repo':(_('User [started following] repository'), None),
-           'stopped_following_repo':(_('User [stopped following] repository'), None),
+    map = {'user_deleted_repo':(_('[deleted] repository'), None),
+           'user_created_repo':(_('[created] repository'), None),
+           'user_forked_repo':(_('[forked] repository as:'), get_fork_name),
+           'user_updated_repo':(_('[updated] repository'), None),
+           'admin_deleted_repo':(_('[delete] repository'), None),
+           'admin_created_repo':(_('[created] repository'), None),
+           'admin_forked_repo':(_('[forked] repository'), None),
+           'admin_updated_repo':(_('[updated] repository'), None),
+           'push':(_('[pushed]'), get_cs_links),
+           'pull':(_('[pulled]'), None),
+           'started_following_repo':(_('[started following] repository'), None),
+           'stopped_following_repo':(_('[stopped following] repository'), None),
             }
 
     action_str = map.get(action, action)
--- a/rhodecode/public/css/style.css	Sun Feb 13 02:48:02 2011 +0100
+++ b/rhodecode/public/css/style.css	Sun Feb 13 03:39:28 2011 +0100
@@ -1413,20 +1413,28 @@
 margin-right:10px;
 }
 
-#journal .journal_action{
-padding-top:4px;
-min-height:15px;
+#journal .journal_user{
+color: #747474;
+font-size: 14px;
+font-weight: bold;
+height: 30px;
 }
-
 #journal .journal_icon{
 float: left;
 padding-top: 4px;
 padding-left:12px;
+padding-right: 4px;
+clear: both;
 }
-
+#journal .journal_action{
+padding-top:4px;
+min-height:2px;
+float:left
+}
 #journal .journal_repo{
-margin-left: 38px;
-padding-top: 5px;
+float: left;
+margin-left: 6px;
+padding-top: 3px;
 }
 
 #journal .journal_repo .journal_repo_name{
@@ -1434,9 +1442,14 @@
 font-size: 1.1em;
 }
 #journal .compare_view{
-padding: 5px 0px 5px 38px;
+padding: 5px 0px 5px 3px;
 width: 95px;
 }
+.journal_highlight{
+font-weight: bold;
+padding: 0 2px;
+vertical-align: bottom;
+}
 .trending_language_tbl,.trending_language_tbl td {
 border:0 !important;
 margin:0 !important;
@@ -1901,11 +1914,6 @@
 padding-bottom:5px;
 }
 
-.journal_highlight{
-font-weight: bold;
-text-decoration: underline;
-}
-
 .add_icon {
 background:url("../images/icons/add.png") no-repeat scroll 3px;
 height:16px;
--- a/rhodecode/templates/journal/journal_data.html	Sun Feb 13 02:48:02 2011 +0100
+++ b/rhodecode/templates/journal/journal_data.html	Sun Feb 13 03:39:28 2011 +0100
@@ -3,14 +3,15 @@
 %if c.journal_day_aggreagate:
     %for day,items in c.journal_day_aggreagate:
     <div class="journal_day">${day}</div>
-        % for entry in items:
+        % for user,entries in items:
         <div style="padding:10px">
             <div class="gravatar">
-                <img alt="gravatar" src="${h.gravatar_url(entry.user.email,24)}"/>
+                <img alt="gravatar" src="${h.gravatar_url(user.email,24)}"/>
             </div>
-            <div>${entry.user.name} ${entry.user.lastname}</div>
+            <div class="journal_user">${user.name} ${user.lastname}</div>
+            % for entry in entries:
+            <div class="journal_icon"> ${h.action_parser_icon(entry)}</div>
             <div class="journal_action">${h.action_parser(entry)}</div>
-            <div class="journal_icon">${h.action_parser_icon(entry)}</div>
             <div class="journal_repo">
                 <span class="journal_repo_name">
                 %if entry.repository:
@@ -21,6 +22,7 @@
                 %endif             
                 </span> - <span title="${entry.action_date}">${h.age(entry.action_date)}</span>
             </div>
+            %endfor
         </div>
         <div style="clear:both;border-bottom:1px dashed #DDD;padding:3px 3px;margin:0px 10px 0px 10px"></div>
         %endfor