# Path: cmsocial/db/base.py
# class Base(CMSBase):
#     __abstract__ = True
#     _created = Column(DateTime, default=func.now())
#     _updated = Column(DateTime, default=func.now(), onupdate=func.now())
#     #TODO: maybe add the id field here and remove it elsewhere?
# 
#     def fieldnames(self, *args):
#         all_fields = map(lambda c: str(c).split('.')[-1], self.__table__.columns)
#         real_fields = filter(lambda c: not c.startswith('_'), all_fields)
# 
#         return real_fields


from sqlalchemy.schema import Column, ForeignKey, PrimaryKeyConstraint
from sqlalchemy.types import Integer, Unicode, String
from sqlalchemy.orm import relationship, backref
from cmsocial.db.base import Base
from cms.db import Participation, Contest
    def __init__(self):
        pass


class QuestionFile(Base):
    """Class to store a question's files
    """
    __tablename__ = 'questionfiles'

    # Auto increment primary key.
    id = Column(Integer, primary_key=True)

    # Question (id and object) owning the file.
    question_id = Column(
        Integer,
        ForeignKey(TestQuestion.id,
                   onupdate="CASCADE", ondelete="CASCADE"),
        nullable=False,
        index=True)
    question = relationship(
        TestQuestion,
        backref=backref('files',
                        cascade="all, delete-orphan",
                        passive_deletes=True))

    # Filename and digest of the file.
    filename = Column(Unicode, nullable=False)
    digest = Column(String, nullable=False)



# Path: cmsocial/db/base.py
# class Base(CMSBase):
#     __abstract__ = True
#     _created = Column(DateTime, default=func.now())
#     _updated = Column(DateTime, default=func.now(), onupdate=func.now())
#     #TODO: maybe add the id field here and remove it elsewhere?
# 
#     def fieldnames(self, *args):
#         all_fields = map(lambda c: str(c).split('.')[-1], self.__table__.columns)
#         real_fields = filter(lambda c: not c.startswith('_'), all_fields)
# 
#         return real_fields


# Path: cmsocial/db/test.py
from sqlalchemy.schema import Column, ForeignKey, PrimaryKeyConstraint
from sqlalchemy.types import Integer, Unicode, String
from sqlalchemy.orm import relationship, backref
from cmsocial.db.base import Base
from cms.db import Participation, Contest

    def __init__(self):
        pass


class QuestionFile(Base):
    """Class to store a question's files
    """
    __tablename__ = 'questionfiles'

    # Auto increment primary key.
    id = Column(Integer, primary_key=True)

    # Question (id and object) owning the file.
    question_id = Column(
        Integer,
        ForeignKey(TestQuestion.id,
                   onupdate="CASCADE", ondelete="CASCADE"),
        nullable=False,
        index=True)
    question = relationship(
        TestQuestion,
        backref=backref('files',
                        cascade="all, delete-orphan",
                        passive_deletes=True))

    # Filename and digest of the file.
    filename = Column(Unicode, nullable=False)
    digest = Column(String, nullable=False)



class TestScore(Base):