Changeset - 98be43b888c4
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 15 years ago 2011-02-13 03:39:28
marcin@python-works.com
Updated new Journal with users and dates aggregates
4 files changed with 54 insertions and 38 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/journal.py
Show inline comments
 
@@ -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.lib.helpers import get_to
 
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 @@ class JournalController(BaseController):
 

	
 
    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 @@ class JournalController(BaseController):
 

	
 
        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 @@ class JournalController(BaseController):
 
        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
 

	
rhodecode/lib/helpers.py
Show inline comments
 
@@ -475,6 +475,7 @@ def action_parser(user_log):
 
                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 @@ def action_parser(user_log):
 
                                          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)
rhodecode/public/css/style.css
Show inline comments
 
@@ -1413,20 +1413,28 @@ margin-left:10px;
 
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-weight: bold;
 
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-left: 10px;
 
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;
rhodecode/templates/journal/journal_data.html
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)