Example #1
0
class Mod(db.Model, Base):
    __tablename__ = "mod"

    title = db.Column(db.Unicode(64), unique=True)
    generalized_title = db.Column(db.Unicode(),
                                  unique=True,
                                  default=create_generalized_title,
                                  onupdate=create_generalized_title)
    icon = db.Column(db.Unicode())
    banner = db.Column(db.Unicode())
    tagline = db.Column(db.Unicode(100))
    description = db.Column(db.Unicode(10000))
    website = db.Column(db.Unicode())
    is_private_beta = db.Column(db.Boolean(), default=False)
    category = db.Column(db.Enum(ModCategory), default=ModCategory.unassigned)
    nsfw = db.Column(db.Boolean(), default=False)
    theme_color = db.Column(db.Enum(ModColor))
    released_at = db.Column(db.Date(), nullable=True)
    last_updated = db.Column(db.DateTime(),
                             default=datetime.utcnow,
                             onupdate=datetime.utcnow)
    status = db.Column(db.Enum(ModStatus))
    # TODO: probably turn this into a table and have better metrics for determining DLs
    downloads = db.Column(db.BigInteger(), default=0)
    download_url = db.Column(db.Unicode(), nullable=True)
    verified = db.Column(db.Boolean(), default=False)

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self._authors = []
        self._owner = None

    @property
    def authors(self):
        return self._authors

    @authors.setter
    def authors(self, value: "User"):
        if hasattr(value, "role"):
            # TODO: try to figure this out in the loader query.

            if value.role.role == AuthorRole.owner:
                self._owner = value
                return

        self._authors.append(value)

    @property
    def owner(self):
        return self._owner

    def to_dict(self):
        return {
            **{
                k: v
                for k, v in super().to_dict().items() if k not in ("generalized_title", )
            }, "authors": self._authors,
            "owner": self._owner
        }
Example #2
0
class Report(db.Model, Base):
    __tablename__ = "report"

    content = db.Column(db.Unicode(1000))
    author_id = db.Column(None, db.ForeignKey("user.id", ondelete="CASCADE"))
    mod_id = db.Column(None, db.ForeignKey("mod.id", ondelete="CASCADE"))
    type = db.Column(db.Enum(ReportType))
Example #3
0
class UserReport(db.Model, Base):
    __tablename__ = "userreport"  # No underscore, as its not a many-many relationship.

    content = db.Column(db.Unicode(1000))
    author_id = db.Column(None, db.ForeignKey("user.id"))
    user_id = db.Column(None, db.ForeignKey("user.id"))
    type = db.Column(db.Enum(UserReportType))
Example #4
0
class Media(db.Model, Base):
    __tablename__ = "media"

    id = db.Column(db.Unicode(), primary_key=True)
    type = db.Column(db.Enum(MediaType))
    url = db.Column(db.Unicode())
    mod_id = db.Column(None, db.ForeignKey("mods.id"))
Example #5
0
class Mod(db.Model, Base):
    __tablename__ = "mods"

    title = db.Column(db.Unicode(64), unique=True)
    icon = db.Column(db.Unicode(), nullable=True)
    tagline = db.Column(db.Unicode(100))
    description = db.Column(db.Unicode(10000))
    website = db.Column(db.Unicode())
    category = db.Column(db.Enum(ModCategory), default=ModCategory.Unassigned)
    nsfw = db.Column(db.Boolean(), default=False)
    released_at = db.Column(db.Date(), nullable=True)
    last_updated = db.Column(db.DateTime(),
                             default=datetime.utcnow,
                             onupdate=datetime.utcnow)
    status = db.Column(db.Enum(ModStatus))
    downloads = db.Column(db.BigInteger(), default=0)
    download_url = db.Column(db.Unicode(), nullable=True)
    verified = db.Column(db.Boolean(), default=False)
Example #6
0
class Connection(db.Model, Base):
    __tablename__ = "connections"

    name = db.Column(db.Unicode())
    type = db.Column(db.Enum(ConnectionType))
    user = db.Column(None, db.ForeignKey("users.id"))
Example #7
0
class ModAuthor(db.Model, Base):
    __tablename__ = "user_mod"

    role = db.Column(db.Enum(AuthorRole), default=AuthorRole.unassigned)
    user_id = db.Column(None, db.ForeignKey("user.id", ondelete="CASCADE"))
    mod_id = db.Column(None, db.ForeignKey("mod.id", ondelete="CASCADE"))
Example #8
0
class ReviewReaction(db.Model, Base):
    __tablename__ = "review_reaction"

    review_id = db.Column(None, db.ForeignKey("review.id", ondelete="CASCADE"))
    user_id = db.Column(None, db.ForeignKey("user.id", ondelete="CASCADE"))
    reaction = db.Column(db.Enum(ReactionType), nullable=False)
Example #9
0
class Media(db.Model, Base):
    __tablename__ = "media"

    type = db.Column(db.Enum(MediaType))
    url = db.Column(db.Unicode())
    mod_id = db.Column(None, db.ForeignKey("mod.id", ondelete="CASCADE"))
Example #10
0
class ModAuthors(db.Model):
    __tablename__ = "user_mods"

    role = db.Column(db.Enum(AuthorRole), default=AuthorRole.Unassigned)
    user_id = db.Column(None, db.ForeignKey("users.id"))
    mod_id = db.Column(None, db.ForeignKey("mods.id"))
Example #11
0
class Connection(db.Model, Base):
    __tablename__ = "connection"

    name = db.Column(db.Unicode())
    type = db.Column(db.Enum(ConnectionType))
    user = db.Column(None, db.ForeignKey("user.id", ondelete="CASCADE"))