# -*- coding: utf-8 -*-
import logging

from pylons import tmpl_context as c

from {{package}}.lib.base import BaseController, render

log = logging.getLogger(__name__)

from pylons.i18n import get_lang, set_lang, _, ungettext, N_
from {{package}} import model as model
from {{package}}.lib.helpers import dcmeta
from {{package}}.lib.decorators import authorize
from {{package}}.lib.auth.permissions import SignedIn

class DashboardController(BaseController):

    def __before__(self):
        import pylons
        c.version = pylons.__version__
        c.dcmeta = dcmeta(title="Dashboard")
    
    @authorize(SignedIn())
    def index(self):
        c.item_map = dict(user=u'user', page=u'page')
        c.title = _('Dashboard')
        q = model.Session.query(model.Page)
        c.pages = q.count()
        q = model.Session.query(model.User)
        c.users = q.count()
        q = model.Session.query(model.ChangelogItem)
        c.changes = q.order_by(model.ChangelogItem.date.desc()).limit(15)
        return render('dashboard/index.mak')
    
    def show(self, id):
        pass
    
