コード例 #1
0
ファイル: models.py プロジェクト: deadcity/DCMS-django-dev
## @module chronicls.models
#  Provides models for the `chronicles` application.


from sqlalchemy.orm import backref, relationship
from sqlalchemy.schema import Column, ForeignKey, Table, UniqueConstraint
from sqlalchemy.types import Boolean, Date, Integer, String, Text

from DCMS.model_base import BaseModel
from DCMS.sequence_tools import find

from dsqla.models import app_label


AppLabel = app_label('chronicles')


class ChronicleBase (AppLabel, BaseModel):
    def __repr__ (self):
        return "<{}({})>".format(type(self).__name__, self.name)

    id = Column(Integer, primary_key = True)
    chronicle_type = Column(String, nullable = False)

    enabled     = Column(Boolean, nullable = False, default = True)
    name        = Column(String, nullable = False, default = '', unique = True)
    description = Column(Text, nullable = False, default = '')

    __mapper_args__ = {
        'polymorphic_on': chronicle_type,
    }
コード例 #2
0
ファイル: models.py プロジェクト: deadcity/DCMS-django-dev
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import backref, relationship
from sqlalchemy.schema import (
    Column, ForeignKey,
    CheckConstraint, PrimaryKeyConstraint, UniqueConstraint
)
from sqlalchemy.sql.expression import or_
from sqlalchemy.types import Boolean, Integer, String

from DCMS.model_base import BaseModel

from dsqla.models import app_label


AppLabel = app_label('traits')


class TraitType (AppLabel, BaseModel):
    __abstract__ = True

    def __repr__ (self):
        return "<{}({})>".format(type(self).__name__, self.name)

    def __str__ (self):
        return self.name

    def __unicode__ (self):
        return unicode(str(self))

    id = Column(Integer, primary_key = True)
コード例 #3
0
ファイル: models.py プロジェクト: deadcity/DCMS-django-dev
from datetime import datetime
from enum import Enum

from sqlalchemy.orm import backref, relationship
from sqlalchemy.schema import CheckConstraint, Column, ForeignKey, UniqueConstraint
from sqlalchemy.sql.expression import or_
from sqlalchemy.types import Boolean, DateTime, Integer, SmallInteger, String, Text

from DCMS.model_base import BaseModel

from dsqla.column_types import EnumColumn
from dsqla.models import app_label


AppLabel = app_label("characters")


class Character(AppLabel, BaseModel):
    class Status(Enum):
        EDITING = 1
        SUBMITTED = 2
        APPROVED = 3
        ACTIVE = 4
        DECEASED = 5
        INACTIVE = 6

    id = Column(Integer, primary_key=True)

    enabled = Column(Boolean, nullable=False, default=True)
    user_id = Column(Integer, ForeignKey("auth_user.id"), nullable=False)