changeset 79:9fe23fdab9e9

Implemented AJAH paging
author Marcin Kuzminski <marcin@python-blog.com>
date Sat, 17 Apr 2010 19:59:06 +0200
parents 6f524697f79d
children 928416088790
files pylons_app/controllers/admin.py pylons_app/templates/admin.html pylons_app/templates/admin_log.html pylons_app/templates/base/base.html
diffstat 4 files changed, 42 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/pylons_app/controllers/admin.py	Sat Apr 17 19:07:29 2010 +0200
+++ b/pylons_app/controllers/admin.py	Sat Apr 17 19:59:06 2010 +0200
@@ -59,6 +59,9 @@
                 .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):
--- a/pylons_app/templates/admin.html	Sat Apr 17 19:07:29 2010 +0200
+++ b/pylons_app/templates/admin.html	Sat Apr 17 19:59:06 2010 +0200
@@ -34,31 +34,9 @@
     <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>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pylons_app/templates/admin_log.html	Sat Apr 17 19:59:06 2010 +0200
@@ -0,0 +1,29 @@
+%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
--- a/pylons_app/templates/base/base.html	Sat Apr 17 19:07:29 2010 +0200
+++ b/pylons_app/templates/base/base.html	Sat Apr 17 19:59:06 2010 +0200
@@ -9,6 +9,7 @@
     <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>
@@ -40,4 +41,9 @@
 
 </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