Changeset - 6f524697f79d
[Not reviewed]
default
0 2 0
Marcin Kuzminski - 16 years ago 2010-04-17 19:07:29
marcin@python-blog.com
Implemented paging to admin user acion log
2 files changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/admin.py
Show inline comments
 
@@ -11,12 +11,13 @@ from ConfigParser import ConfigParser
 
from pylons_app.lib import auth
 
from pylons_app.model.forms import LoginForm
 
import formencode
 
import formencode.htmlfill as htmlfill
 
from pylons_app.model import meta
 
from pylons_app.model.db import Users, UserLogs
 
from webhelpers.paginate import Page
 
log = logging.getLogger(__name__)
 

	
 
class AdminController(BaseController):
 

	
 
    def __before__(self):
 
        c.staticurl = g.statics
 
@@ -50,14 +51,17 @@ class AdminController(BaseController):
 
                    html,
 
                    defaults=c.form_result,
 
                    encoding="UTF-8"
 
                )
 
        if c.admin_user:
 
            sa = meta.Session
 
            c.users_log = sa.query(UserLogs)\
 
                .order_by(UserLogs.action_date.desc()).limit(10).all()
 
                             
 
            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)
 
        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
 
@@ -48,12 +48,15 @@
 
					<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>
0 comments (0 inline, 0 general)