# 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
from sqlalchemy.types import Integer, Unicode
from sqlalchemy.orm import relationship, backref
from cmsocial.db.base import Base
        ForeignKey(Region.id,
                   onupdate="CASCADE", ondelete="CASCADE"),
        nullable=False,
        index=True)
    region = relationship(
        Region,
        backref=backref("provinces",
                        cascade="all, delete-orphan",
                        passive_deletes=True))


class City(Base):
    __tablename__ = 'cities'

    id = Column(Integer, primary_key=True, unique=True)
    name = Column(Unicode)

    province_id = Column(
        Integer,
        ForeignKey(Province.id,
                   onupdate="CASCADE", ondelete="CASCADE"),
        nullable=False,
        index=True)
    province = relationship(
        Province,
        backref=backref("cities",
                        cascade="all, delete-orphan",
                        passive_deletes=True))



# 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/location.py
from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.types import Integer, Unicode
from sqlalchemy.orm import relationship, backref
from cmsocial.db.base import Base

        ForeignKey(Region.id,
                   onupdate="CASCADE", ondelete="CASCADE"),
        nullable=False,
        index=True)
    region = relationship(
        Region,
        backref=backref("provinces",
                        cascade="all, delete-orphan",
                        passive_deletes=True))


class City(Base):
    __tablename__ = 'cities'

    id = Column(Integer, primary_key=True, unique=True)
    name = Column(Unicode)

    province_id = Column(
        Integer,
        ForeignKey(Province.id,
                   onupdate="CASCADE", ondelete="CASCADE"),
        nullable=False,
        index=True)
    province = relationship(
        Province,
        backref=backref("cities",
                        cascade="all, delete-orphan",
                        passive_deletes=True))



class Institute(Base):