Changeset - 9fe23fdab9e9
[Not reviewed]
default
0 3 1
Marcin Kuzminski - 16 years ago 2010-04-17 19:59:06
marcin@python-blog.com
Implemented AJAH paging
4 files changed with 42 insertions and 26 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/admin.py
Show inline comments
 
@@ -56,12 +56,15 @@ class AdminController(BaseController):
 
            sa = meta.Session
 
                             
 
            users_log = sa.query(UserLogs)\
 
                .order_by(UserLogs.action_date.desc())
 
            p = int(request.params.get('page', 1))
 
            c.users_log = Page(users_log, page=p, items_per_page=10)
 
            c.log_data = render('admin_log.html')
 
            if request.params.get('partial'):
 
                return c.log_data
 
        return render('/admin.html')
 

	
 
    def hgrc(self, dirname):
 
        filename = os.path.join(dirname, '.hg', 'hgrc')
 
        return filename
 

	
pylons_app/templates/admin.html
Show inline comments
 
@@ -31,37 +31,15 @@
 
            ${h.link_to(u'Users',h.url('users'))}
 
        </li>
 
    </ul>
 
    <br/>
 
    <div>
 
        <h2>Welcome ${c.admin_username}</h2>
 
        <div>${_('Last 10 user actions')}</div>
 
        %if c.users_log:
 
	        <table>
 
	        <tr>
 
	        	<td>${_('Username')}</td>
 
	        	<td>${_('Repository')}</td>
 
	        	<td>${_('Action')}</td>
 
	        	<td>${_('Date')}</td>
 
	        </tr>
 
	        %for cnt,l in enumerate(c.users_log):
 
				<tr class="parity${cnt%2}">
 
					<td>${l.user.username}</td>
 
					<td>${l.repository}</td>
 
					<td>${l.action}</td>
 
					<td>${l.action_date}</td>
 
				</tr>
 
			%endfor
 
			<tr>
 
				<td>${c.users_log.pager('$link_previous ~2~ $link_next')}</td>
 
			</tr>
 
			</table>        
 
		%else:
 
			${_('No actions yet')}
 
		%endif
 

	
 
		    <div id="user_log">
 
				${c.log_data}
 
			</div>
 
    </div>
 
    %else:
 
        <div>
 
        <br />
 
        <h2>${_('Login')}</h2>
 
        ${h.form(h.url.current())}
pylons_app/templates/admin_log.html
Show inline comments
 
new file 100644
 
%if c.users_log:
 
<table>
 
	<tr>
 
		<td>${_('Username')}</td>
 
		<td>${_('Repository')}</td>
 
		<td>${_('Action')}</td>
 
		<td>${_('Date')}</td>
 
	</tr>
 

	
 
	%for cnt,l in enumerate(c.users_log):
 
	<tr class="parity${cnt%2}">
 
		<td>${l.user.username}</td>
 
		<td>${l.repository}</td>
 
		<td>${l.action}</td>
 
		<td>${l.action_date}</td>
 
	</tr>
 
	%endfor
 

	
 
	<tr>
 
		<td>${c.users_log.pager('$link_previous ~2~ $link_next',
 
		onclick="""YAHOO.util.Connect.asyncRequest('GET','$partial_url',{
 
		success:function(o){YAHOO.util.Dom.get('user_log').innerHTML=o.responseText;}
 
		},null); return false;""")}</td>
 
	</tr>
 
</table>
 

	
 
%else: 
 
	${_('No actions yet')} 
 
%endif
pylons_app/templates/base/base.html
Show inline comments
 
@@ -6,12 +6,13 @@
 
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
 
    <link rel="icon" href="${c.staticurl}hgicon.png" type="image/png" />
 
    <meta name="robots" content="index, nofollow"/>
 
    <link rel="stylesheet" href="${c.staticurl}style-monoblue.css" type="text/css" />
 
       <title>${next.title()}</title>
 
    ${self.js()}
 
</head>
 

	
 
<body>
 
<div id="container">
 
    <div class="page-header">
 
        <h1>
 
@@ -37,7 +38,12 @@
 
    <div id="corner-top-right"></div>
 
    <div id="corner-bottom-left"></div>
 
    <div id="corner-bottom-right"></div>
 

	
 
</div>
 
</body>
 
</html>
 
\ No newline at end of file
 
</html>
 

	
 

	
 
<%def name="js()">
 
<script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
 
</%def>
 
\ No newline at end of file
0 comments (0 inline, 0 general)