X-Git-Url: https://git.llucax.com/software/sercom-old.git/blobdiff_plain/e8abee9ba294fb9900e0d057945b286886e117e1..296cd152457559e262fcb64c429ca83f8a0c6b0c:/src/sercom/dbo.py?ds=inline diff --git a/src/sercom/dbo.py b/src/sercom/dbo.py index 32aa492..7a09f81 100644 --- a/src/sercom/dbo.py +++ b/src/sercom/dbo.py @@ -6,13 +6,12 @@ __all__ = ('Curso', 'Inscripto', 'Docente', 'Ejercicio', 'Entrega', class BaseSQLObject(SQLObject): - #@classmethod + @classmethod def by(cls, connection = None, **kw): try: return cls.selectBy(connection = connection, **kw)[0] except IndexError: raise SQLObjectNotFound, "The object %s with columns %s does not exist" % (cls.__name__, kw) - by = classmethod(by) class Curso(BaseSQLObject): # Clave @@ -56,7 +55,7 @@ class Ejercicio(BaseSQLObject): numero = Col() docente = ForeignKey('Docente') # Joins - casosDePrueba = MultipleJoin('CasoDePrueba') + casosDePrueba = MultipleJoin('CasoDePrueba', joinMethodName='casosDePrueba') # XXX hack entregas = MultipleJoin('Entrega') cursos = RelatedJoin('Curso', intermediateTable = 'entrega') @@ -105,24 +104,21 @@ class Intento(BaseSQLObject): # Joins pruebas = MultipleJoin('Prueba') - _dir_base = 'intentos' - - #@classmethod - def getProximoAProbar(cls, connection = None): + @classmethod + def getProximoAProbar(cls, connection=None): try: - return cls.select(cls.q.inicioPruebas == None, limit=1, + return cls.select(None == cls.q.compila, limit=1, orderBy=cls.q.llegada, connection=connection)[0] except IndexError: return None - getProximoAProbar = classmethod(getProximoAProbar) def path(self, dir_base): - import os.path + from os.path import join curso = self.inscripto.curso entrega = self.entrega - return os.path.join(dir_base, curso.anio, curso.cuatrimestre, - curso.curso, '%s.%s' % (entrega.nroEjercicio, entrega.entrega), - self.inscripto.padron, self.numero) + return join(dir_base, '%s.%s' % (curso.anio, curso.cuatrimestre), + '%s.%s.%s' % (curso.curso, entrega.nroEjercicio, entrega.entrega), + '%s.%s' % (self.inscripto.padron, self.numero)) class Correccion(BaseSQLObject): # Clave