"""
byceps.services.tourney.models.tourney
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2020 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from ....database import db, generate_uuid

from ....util.instances import ReprBuilder

from .tourney_category import TourneyCategory


class Tourney(db.Model):
    """A tournament."""

    __tablename__ = 'tourneys'
    __table_args__ = (
        db.UniqueConstraint('category_id', 'title'),
    )

    id = db.Column(db.Uuid, default=generate_uuid, primary_key=True)
    category_id = db.Column(db.Uuid, db.ForeignKey('tourney_categories.id'), index=True, nullable=False)
    category = db.relationship(TourneyCategory)
    title = db.Column(db.UnicodeText, nullable=False)

    def __init__(self, category: TourneyCategory, title: str) -> None:
        self.category = category
        self.title = title

    def __repr__(self) -> str:
        return ReprBuilder(self) \
            .add_with_lookup('category') \
            .add_with_lookup('title') \
            .build()

@@ -173,16 +173,47 @@
 s.%0A%22%22%22%0A%0A
+from datetime import datetime%0A%0A
 from ...
@@ -601,24 +601,41 @@
 .Column(
-db.Uuid,
+%0A        db.Uuid,%0A       
  db.Fore
@@ -666,16 +666,24 @@
 es.id'),
+%0A       
  index=T
@@ -686,16 +686,24 @@
 ex=True,
+%0A       
  nullabl
@@ -709,16 +709,22 @@
 le=False
+,%0A    
 )%0A    ca
@@ -818,16 +818,249 @@
 e=False)
+%0A    subtitle = db.Column(db.UnicodeText, nullable=True)%0A    logo_url = db.Column(db.UnicodeText, nullable=True)%0A    max_participant_count = db.Column(db.Integer, nullable=False)%0A    starts_at = db.Column(db.DateTime, nullable=False)
 %0A%0A    de
@@ -1113,16 +1113,66 @@
 tle: str
+, max_participant_count: bool, starts_at: datetime
 ) -%3E Non
@@ -1233,16 +1233,110 @@
  = title
+%0A        self.max_participant_count = max_participant_count%0A        self.starts_at = starts_at
 %0A%0A    de
@@ -1399,51 +1399,8 @@
 ) %5C%0A
-            .add_with_lookup('category') %5C%0A
     

Extend tourney database model