X-Git-Url: https://git.llucax.com/software/sercom.git/blobdiff_plain/206d6cd5f26a563166199329735818db9345828b..c56ec835331caae162a76f914cb4e7b2be4ab9e7:/sercom/subcontrollers/alumno/__init__.py?ds=sidebyside diff --git a/sercom/subcontrollers/alumno/__init__.py b/sercom/subcontrollers/alumno/__init__.py index 3d2c11a..7dd7f01 100644 --- a/sercom/subcontrollers/alumno/__init__.py +++ b/sercom/subcontrollers/alumno/__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 Alumno +from sercom.model import Alumno, Rol from sqlobject import * #}}} @@ -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') @@ -157,16 +158,18 @@ class AlumnoController(controllers.Controller, identity.SecureResource): lines = archivo.file.read().split('\n') ok = [] fail = [] + entregador = Rol.get(2) for line in lines: for row in csv.reader([line]): 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.contrasenia = row[0] + u.password = row[0] u.activo = True + u.add_rol(entregador) ok.append(row) except Exception, e: row.append(str(e)) @@ -182,7 +185,7 @@ class AlumnoController(controllers.Controller, identity.SecureResource): alumno = Alumno.byPadron(padron=padron) msg = {} msg['id'] = alumno.id - msg['value'] = alumno.nombre + msg['value'] = alumno.shortrepr() except SQLObjectNotFound: msg = 'No existe el alumno con padron: %s.' % padron error=True