Changeset - 1af15d66838f
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 15 years ago 2010-12-05 03:00:08
marcin@python-works.com
added icons to journal, extend show more to actually show more pushed revisions,
3 files changed with 77 insertions and 15 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -410,83 +410,117 @@ def bool2icon(value):
 
def action_parser(user_log):
 
    """
 
    This helper will map the specified string action into translated
 
    fancy names with icons and links
 
    
 
    @param action:
 
    """
 
    action = user_log.action
 
    action_params = None
 

	
 
    x = action.split(':')
 

	
 
    if len(x) > 1:
 
        action, action_params = x
 

	
 
    def get_cs_links():
 
        if action == 'push':
 
            revs_limit = 5
 
            revs = action_params.split(',')
 
            cs_links = " " + ', '.join ([link(rev,
 
                    url('changeset_home',
 
                    repo_name=user_log.repository.repo_name,
 
                    revision=rev)) for rev in revs[:revs_limit] ])
 
            if len(revs) > revs_limit:
 
                html_tmpl = '<span title="%s"> %s </span>'
 
                cs_links += html_tmpl % (', '.join(r for r in revs[revs_limit:]),
 
                                         _('and %s more revisions') \
 
                                            % (len(revs) - revs_limit))
 
                uniq_id = revs[0]
 
                html_tmpl = ('<span> %s '
 
                '<a class="show_more" id="_%s" href="#">%s</a> '
 
                '%s</span>')
 
                cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
 
                                            % (len(revs) - revs_limit),
 
                                            _('revisions'))
 

	
 
                html_tmpl = '<span id="%s" style="display:none"> %s </span>'
 
                cs_links += html_tmpl % (uniq_id, ', '.join([link(rev,
 
                    url('changeset_home',
 
                    repo_name=user_log.repository.repo_name,
 
                    revision=rev)) for rev in revs[:revs_limit] ]))
 

	
 
            return cs_links
 
        return ''
 

	
 
    def get_fork_name():
 
        if action == 'user_forked_repo':
 
            from rhodecode.model.scm import ScmModel
 
            repo_name = action_params
 
            repo = ScmModel().get(repo_name)
 
            if repo is None:
 
                return repo_name
 
            return link_to(action_params, url('summary_home',
 
                                              repo_name=repo.name,),
 
                                              title=repo.dbrepo.description)
 
        return ''
 
    map = {'user_deleted_repo':_('User [deleted] repository'),
 
           'user_created_repo':_('User [created] repository'),
 
           'user_forked_repo':_('User [forked] repository as: %s') % get_fork_name(),
 
           'user_updated_repo':_('User [updated] repository'),
 
           'admin_deleted_repo':_('Admin [delete] repository'),
 
           'admin_created_repo':_('Admin [created] repository'),
 
           'admin_forked_repo':_('Admin [forked] repository'),
 
           'admin_updated_repo':_('Admin [updated] repository'),
 
           'push':_('[Pushed] %s') % get_cs_links(),
 
           'pull':_('[Pulled]'),
 
           'started_following_repo':_('User [started following] repository'),
 
           'stopped_following_repo':_('User [stopped following] repository'),
 
            }
 

	
 
    action_str = map.get(action, action)
 
    return literal(action_str.replace('[', '<span class="journal_highlight">').replace(']', '</span>'))
 
    return literal(action_str.replace('[', '<span class="journal_highlight">')\
 
                   .replace(']', '</span>'))
 

	
 
def action_parser_icon(user_log):
 
    action = user_log.action
 
    action_params = None
 
    x = action.split(':')
 

	
 
    if len(x) > 1:
 
        action, action_params = x
 

	
 
    tmpl = """<img src="/images/icons/%s">"""
 
    map = {'user_deleted_repo':'database_delete.png',
 
           'user_created_repo':'database_add.png',
 
           'user_forked_repo':'arrow_divide.png',
 
           'user_updated_repo':'database_edit.png',
 
           'admin_deleted_repo':'database_delete.png',
 
           'admin_created_repo':'database_ddd.png',
 
           'admin_forked_repo':'arrow_divide.png',
 
           'admin_updated_repo':'database_edit.png',
 
           'push':'script_add.png',
 
           'pull':'down_16.png',
 
           'started_following_repo':'heart_add.png',
 
           'stopped_following_repo':'heart_delete.png',
 
            }
 
    return literal(tmpl % map.get(action, action))
 

	
 

	
 
#==============================================================================
 
# PERMS
 
#==============================================================================
 
from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
 
HasRepoPermissionAny, HasRepoPermissionAll
 

	
 
#==============================================================================
 
# GRAVATAR URL
 
#==============================================================================
 
import hashlib
 
import urllib
 
from pylons import request
 

	
 
def gravatar_url(email_address, size=30):
 
    ssl_enabled = 'https' == request.environ.get('HTTP_X_URL_SCHEME')
 
    default = 'identicon'
 
    baseurl_nossl = "http://www.gravatar.com/avatar/"
 
    baseurl_ssl = "https://secure.gravatar.com/avatar/"
 
    baseurl = baseurl_ssl if ssl_enabled else baseurl_nossl
 

	
 

	
 
    # construct the url
rhodecode/templates/admin/admin_log.html
Show inline comments
 
@@ -8,41 +8,56 @@
 
		<th class="left">${_('Date')}</th>
 
		<th class="left">${_('From IP')}</th>
 
	</tr>
 

	
 
	%for cnt,l in enumerate(c.users_log):
 
	<tr class="parity${cnt%2}">
 
		<td>${h.link_to(l.user.username,h.url('edit_user', id=l.user.user_id))}</td>
 
		<td>${h.action_parser(l)}</td>
 
		<td>
 
		%if l.repository:
 
		  ${h.link_to(l.repository.repo_name,h.url('summary_home',repo_name=l.repository.repo_name))}
 
		%else:
 
		  ${l.repository_name}
 
		%endif
 
		</td>
 
		
 
		<td>${l.action_date}</td>
 
		<td>${l.user_ip}</td>
 
	</tr>
 
	%endfor
 
</table>
 

	
 
<script type="text/javascript">
 
  var data_div = 'user_log';
 
  YAHOO.util.Event.onDOMReady(function(){
 
	YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
 
			YAHOO.util.Dom.setStyle('shortlog_data','opacity','0.3');});});
 
  YUE.onDOMReady(function(){
 
	YUE.on(YUD.getElementsByClassName('pager_link'),"click",function(){
 
			YUD.setStyle(data_div,'opacity','0.3');});
 
	YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
 
	      var el = e.target;
 
	      YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
 
	      YUD.setStyle(el.parentNode,'display','none');
 
	  });
 
  });
 
</script>
 
		
 
		
 
<div class="pagination-wh pagination-left">
 
${c.users_log.pager('$link_previous ~2~ $link_next',
 
onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{
 
success:function(o){YAHOO.util.Dom.get(data_div).innerHTML=o.responseText;
 
YAHOO.util.Event.addListener(YAHOO.util.Dom.getElementsByClassName('pager_link'),"click",function(){
 
		YAHOO.util.Dom.setStyle(data_div,'opacity','0.3');});		
 
YAHOO.util.Dom.setStyle(data_div,'opacity','1');}},null); return false;""")}
 
success:function(o){
 
    YUD.get(data_div).innerHTML=o.responseText;
 
    YUE.on(YUD.getElementsByClassName('pager_link'),"click",function(){
 
        YUD.setStyle(data_div,'opacity','0.3');
 
    });		
 
    YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
 
      var el = e.target;
 
      YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
 
      YUD.setStyle(el.parentNode,'display','none');
 
    });
 
    YUD.setStyle(data_div,'opacity','1');}    
 

	
 
},null); return false;""")}
 
</div>
 
%else: 
 
	${_('No actions yet')} 
 
%endif
rhodecode/templates/journal.html
Show inline comments
 
@@ -3,77 +3,90 @@
 
<%def name="title()">
 
    ${_('Journal')} - ${c.rhodecode_name}
 
</%def>
 
<%def name="breadcrumbs()">
 
	${c.rhodecode_name}
 
</%def>
 
<%def name="page_nav()">
 
	${self.menu('home')}
 
</%def>
 
<%def name="main()">
 
	
 
    <div class="box box-left">
 
	    <!-- box / title -->
 
	    <div class="title">
 
	        <h5>${_('Journal')}</h5>
 
	    </div>
 
	    <div>
 
	    %if c.journal:
 
            %for entry in c.journal:
 
            <div style="padding:10px">
 
                <div class="gravatar">
 
                    <img alt="gravatar" src="${h.gravatar_url(entry.user.email)}"/>
 
                </div>
 
                <div>${entry.user.name} ${entry.user.lastname}</div>
 
                <div style="padding-left: 45px;padding-top:5px">${h.action_parser(entry)} <br/>
 
                <b>
 
                <div style="padding-left: 45px;padding-top:5px;min-height:20px">${h.action_parser(entry)}</div>
 
                <div style="float: left; padding-top: 8px;padding-left:18px">
 
                ${h.action_parser_icon(entry)}
 
                </div>
 
                <div style="margin-left: 45px;padding-top: 10px">
 
                <span style="font-weight: bold;font-size: 1.1em">
 
		        %if entry.repository:
 
		          ${h.link_to(entry.repository.repo_name,
 
		                      h.url('summary_home',repo_name=entry.repository.repo_name))}
 
		        %else:
 
		          ${entry.repository_name}
 
		        %endif             
 
                </b> - <span title="${entry.action_date}">${h.age(entry.action_date)}</span>
 
                </span> - <span title="${entry.action_date}">${h.age(entry.action_date)}</span>
 
                </div>
 
            </div>
 
            <div style="clear:both;border-bottom:1px dashed #DDD;padding:3px 3px;margin:0px 10px 0px 10px"></div>
 
            %endfor
 
        %else:
 
            ${_('No entries yet')}
 
        %endif   
 
	    </div>
 
    </div>
 
    
 
    <div class="box box-right">
 
        <!-- box / title -->
 
        <div class="title">
 
            <h5>${_('Following')}</h5>
 
        </div>
 
        <div>
 
        %if c.following:
 
            %for entry in c.following:
 
                <div class="currently_following">
 
                    %if entry.follows_user_id:
 
                      <img title="${_('following user')}" alt="${_('user')}" src="/images/icons/user.png"/>
 
                      ${entry.follows_user.full_contact}
 
                    %endif
 
                    
 
                    %if entry.follows_repo_id:
 
                    
 
                      %if entry.follows_repository.private:
 
                        <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="/images/icons/lock.png"/>
 
                      %else:
 
                        <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="/images/icons/lock_open.png"/>
 
                      %endif
 
                      
 
                      ${h.link_to(entry.follows_repository.repo_name,h.url('summary_home',
 
                        repo_name=entry.follows_repository.repo_name))}
 
                      
 
                    %endif
 
                </div>
 
            %endfor
 
        %else:
 
            ${_('You are not following any users or repositories')}
 
        %endif               
 
        </div>
 
    </div>
 
    
 
    <script type="text/javascript">
 
    YUE.on(YUD.getElementsByClassName('show_more'),'click',function(e){
 
        var el = e.target;
 
        YUD.setStyle(YUD.get(el.id.substring(1)),'display','');
 
        YUD.setStyle(el.parentNode,'display','none');
 
    });    
 
    </script>
 
    
 
</%def>    
0 comments (0 inline, 0 general)