From: Ricardo Markiewicz Date: Fri, 2 Mar 2007 04:16:17 +0000 (+0000) Subject: Un dashboard simplon para empezar a informar cosas utiles luego del loggin X-Git-Tag: pre-merge~14 X-Git-Url: https://git.llucax.com/z.facultad/75.52/sercom.git/commitdiff_plain/94b32d115d412a3baa90a96c9165d7f57a189ba0?ds=sidebyside Un dashboard simplon para empezar a informar cosas utiles luego del loggin --- diff --git a/sercom/controllers.py b/sercom/controllers.py index 079ee79..48b0086 100644 --- a/sercom/controllers.py +++ b/sercom/controllers.py @@ -4,7 +4,7 @@ from turbogears import controllers, expose, view, url from turbogears import widgets as W, validators as V from turbogears import identity, redirect from cherrypy import request, response -from model import * +from model import InstanciaDeEntrega, Correccion # from sercom import json from subcontrollers import * @@ -25,12 +25,26 @@ class LoginForm(W.TableForm): class Root(controllers.RootController): + @expose() + def index(self): + raise redirect('/dashboard') + @expose(template='.templates.welcome') @identity.require(identity.has_permission('entregar')) - def index(self): + def dashboard(self): import time + record = {} + if 'admin' in identity.current.permissions: + from sqlobject import DateTimeCol + # TODO : Fijar el curso !! + record['entregas_para_corregir'] = Correccion.selectBy(corrector=identity.current.user, nota=None).count() + try: + record['proxima_entrega'] = InstanciaDeEntrega.select(InstanciaDeEntrega.q.inicio >= DateTimeCol.now() and InstanciaDeEntrega.q.fin > DateTimeCol.now()).getOne() + record['proxima_entrega'] = record['proxima_entrega'][0] + except: + record['proxima_entrega'] = None log.debug('Happy TurboGears Controller Responding For Duty') - return dict(now=time.ctime()) + return dict(now=time.ctime(), record=record) @expose(template='.templates.login') def login(self, forward_url=None, previous_url=None, tg_errors=None, *args, diff --git a/sercom/menu.py b/sercom/menu.py index 59c527f..a72d6a2 100644 --- a/sercom/menu.py +++ b/sercom/menu.py @@ -8,6 +8,7 @@ class Menu: self.base = base self.items = filter(lambda i: isinstance(getattr(base, i), Controller), base.__dict__) self.items.sort() + self.items = ['dashboard'] + self.items def _check(self, c): return c.require.eval_with_object(identity.current) @@ -24,7 +25,7 @@ class Menu: """ s = option % ('', '-----') for i in self.items: - if self._check(getattr(self.base, i)): + if i == 'dashboard' or self._check(getattr(self.base, i)): s += option % (url('/' + i), i.capitalize().replace('_', ' ')) return template % s diff --git a/sercom/templates/welcome.kid b/sercom/templates/welcome.kid index 9a86f7c..07c22f0 100644 --- a/sercom/templates/welcome.kid +++ b/sercom/templates/welcome.kid @@ -9,7 +9,21 @@
-

Soy admin

+

Dashboard

+

Correcciones

+
+ + En este momento tenes ${record['entregas_para_corregir']} entregas para corregir. + + + No hay entregas que corregir. + +
+

Instancias de Entrega

+
+ La proxima Entrega vence el ${record['proxima_entrega']}. + En este momento no hay ninguna Entrega en curso. +