Changeset - df61378032f3
[Not reviewed]
beta
0 4 0
Marcin Kuzminski - 15 years ago 2010-11-05 22:36:51
marcin@python-works.com
#48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
4 files changed with 52 insertions and 9 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/admin/repos.py
Show inline comments
 
@@ -137,6 +137,9 @@ class ReposController(BaseController):
 
            h.flash(_('Repository %s updated succesfully' % repo_name),
 
                    category='success')
 
            changed_name = form_result['repo_name']
 
            action_logger(self.rhodecode_user, 'admin_updated_repo',
 
                              changed_name, '', self.sa)
 

	
 
        except formencode.Invalid, errors:
 
            c.repo_info = repo_model.get(repo_name)
 
            c.users_array = repo_model.get_users_js()
rhodecode/controllers/settings.py
Show inline comments
 
@@ -82,6 +82,8 @@ class SettingsController(BaseController)
 
            h.flash(_('Repository %s updated successfully' % repo_name),
 
                    category='success')
 
            changed_name = form_result['repo_name']
 
            action_logger(self.rhodecode_user, 'user_updated_repo',
 
                              changed_name, '', self.sa)
 
        except formencode.Invalid, errors:
 
            c.repo_info = repo_model.get(repo_name)
 
            c.users_array = repo_model.get_users_js()
rhodecode/lib/helpers.py
Show inline comments
 
@@ -357,6 +357,50 @@ email_or_none = lambda x: util.email(x) 
 
person = lambda x: _person(x)
 
short_id = lambda x: x[:12]
 

	
 

	
 
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
 
    cs_links = ''
 

	
 
    x = action.split(':')
 

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

	
 
    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))
 

	
 
    map = {'user_deleted_repo':_('User deleted repository'),
 
           'user_created_repo':_('User created repository'),
 
           'user_forked_repo':_('User forked repository'),
 
           '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') + literal(cs_links),
 
           'pull':_('Pulled'), }
 

	
 
    print action, action_params
 
    return map.get(action, action)
 

	
 

	
 
#==============================================================================
 
# PERMS
 
#==============================================================================
rhodecode/templates/admin/admin_log.html
Show inline comments
 
@@ -3,8 +3,8 @@
 
<table>
 
	<tr>
 
		<th class="left">${_('Username')}</th>
 
		<th class="left">${_('Action')}</th>
 
		<th class="left">${_('Repository')}</th>
 
		<th class="left">${_('Action')}</th>
 
		<th class="left">${_('Date')}</th>
 
		<th class="left">${_('From IP')}</th>
 
	</tr>
 
@@ -12,6 +12,7 @@
 
	%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))}
 
@@ -19,14 +20,7 @@
 
		  ${l.repository_name}
 
		%endif
 
		</td>
 
		<td>
 
		% if l.action == 'push' and l.revision:
 
		  ${h.link_to('%s - %s' % (l.action,l.revision),
 
		  h.url('changeset_home',repo_name=l.repository.repo_name,revision=l.revision))}
 
		%else:
 
		  ${l.action}
 
		%endif
 
		</td>
 
		
 
		<td>${l.action_date}</td>
 
		<td>${l.user_ip}</td>
 
	</tr>
0 comments (0 inline, 0 general)