From 55e22977ea91eb5ecfef0f88e867d163ff4e2552 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Fri, 2 Mar 2007 23:00:04 +0000 Subject: [PATCH] =?utf8?q?Mejorar=20y=20arreglar=20dashboard.=20-=20Hace?= =?utf8?q?=20que=20el=20dashboard=20pida=20que=20se=20est=C3=A9=20logueado?= =?utf8?q?=20en=20el=20sistema.=20-=20Reporta=20todas=20las=20instancias?= =?utf8?q?=20de=20entrega=20en=20curso,=20diciendo=20cuando=20vencen=20=20?= =?utf8?q?=20(contando=20cuantos=20d=C3=ADas=20faltan=20al=20estilo=20CRON?= =?utf8?q?ICA=20=3DP).=20Para=20esto=20se=20arregla=20el=20=20=20query.=20?= =?utf8?q?-=20Se=20pasan=20las=20variables=20por=20separado=20(no=20se=20u?= =?utf8?q?sa=20el=20dict=20"records").?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- sercom/controllers.py | 30 ++++++++++++++---------------- sercom/templates/welcome.kid | 24 ++++++++++++------------ 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/sercom/controllers.py b/sercom/controllers.py index 48b0086..3e96564 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 InstanciaDeEntrega, Correccion +from model import InstanciaDeEntrega, Correccion, AND, DateTimeCol # from sercom import json from subcontrollers import * @@ -27,24 +27,22 @@ class Root(controllers.RootController): @expose() def index(self): - raise redirect('/dashboard') + raise redirect(url('/dashboard')) @expose(template='.templates.welcome') - @identity.require(identity.has_permission('entregar')) + @identity.require(identity.not_anonymous()) 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(), record=record) + correcciones = Correccion.selectBy(corrector=identity.current.user, + nota=None).count() + now = DateTimeCol.now() + instancias = list(InstanciaDeEntrega.select( + AND(InstanciaDeEntrega.q.inicio <= now, + InstanciaDeEntrega.q.fin > now)) + .orderBy(InstanciaDeEntrega.q.fin)) + return dict(a_corregir=correcciones, + instancias_activas=instancias, now=now) @expose(template='.templates.login') def login(self, forward_url=None, previous_url=None, tg_errors=None, *args, @@ -89,7 +87,7 @@ class Root(controllers.RootController): @expose() def logout(self): identity.current.logout() - raise redirect('/') + raise redirect(url('/')) docente = DocenteController() @@ -104,7 +102,7 @@ class Root(controllers.RootController): caso_de_prueba = CasoDePruebaController() curso = CursoController() - + docente_inscripto = DocenteInscriptoController() correccion = CorreccionController() diff --git a/sercom/templates/welcome.kid b/sercom/templates/welcome.kid index 606fe95..233c168 100644 --- a/sercom/templates/welcome.kid +++ b/sercom/templates/welcome.kid @@ -10,19 +10,19 @@

Dashboard

-

Correcciones

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

Correcciones

+ En este momento tenes ${a_corregir} entregas para corregir.
-

Instancias de Entrega

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

Instancias de Entrega

+
    +
  • + La entrega ${instancia.numero} del ejercicio ${instancia.ejercicio.numero} + vence el ${instancia.fin.strftime(r'%A %d de %B a las %R')} + (falta ${instancia.fin - now}). +
  • +
-- 2.43.0