From f8e0f8df0b9169f34109c752c63d67851c319ff7 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 15 Mar 2007 20:11:49 +0000 Subject: [PATCH 1/1] Agregar rol a Alumno cuando se crea. --- sercom/subcontrollers/alumno/__init__.py | 3 ++- sercom/subcontrollers/curso/__init__.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sercom/subcontrollers/alumno/__init__.py b/sercom/subcontrollers/alumno/__init__.py index 2eb418f..7dd7f01 100644 --- a/sercom/subcontrollers/alumno/__init__.py +++ b/sercom/subcontrollers/alumno/__init__.py @@ -107,6 +107,7 @@ class AlumnoController(controllers.Controller, identity.SecureResource): @expose() def create(self, **kw): """Save or create record to model""" + kw['roles'] = [Rol.by_nombre('alumno')] validate_new(kw) flash(_(u'Se creó un nuevo %s.') % name) raise redirect('list') @@ -163,7 +164,7 @@ class AlumnoController(controllers.Controller, identity.SecureResource): if row == []: continue try: - u = Alumno(row[0], nombre=row[1]) + u = Alumno(row[0], nombre=row[1], roles=[Rol.by_nombre('alumno')]) u.email = row[2] u.telefono = row[3] u.password = row[0] diff --git a/sercom/subcontrollers/curso/__init__.py b/sercom/subcontrollers/curso/__init__.py index d73b01b..fe63512 100644 --- a/sercom/subcontrollers/curso/__init__.py +++ b/sercom/subcontrollers/curso/__init__.py @@ -10,7 +10,7 @@ from turbogears import identity from turbogears import paginate from docutils.core import publish_parts from sercom.subcontrollers import validate as val -from sercom.model import Curso, Correccion, Ejercicio, Alumno, Docente, Grupo, DocenteInscripto +from sercom.model import Curso, Correccion, Ejercicio, Alumno, Docente, Grupo, DocenteInscripto, Rol from curso_alumno import * from sqlobject import * from sqlobject.dberrors import * @@ -298,7 +298,7 @@ class CursoController(controllers.Controller, identity.SecureResource): if row == []: continue try: - u = Alumno(row[0], nombre=row[1]) + u = Alumno(row[0], nombre=row[1], roles=[Rol.by_nombre('alumno')]) except: u = Alumno.byPadron(row[0]) try: -- 2.43.0