Exemplo n.º 1
0
class BadTournament(Model):
    id = fields.IntegerField(primary_key=True)
    name = fields.TextField()
    created = fields.DateTimeField(auto_now_add=True, db_index=True)

    def __str__(self):
        return self.name
Exemplo n.º 2
0
class Question(models.Model):
    question_text = fields.CharField(max_length=200)
    pub_date = fields.DateTimeField('date published')

    def was_published_recently(self):
        return self.pub_date >= datetime.datetime.now() - datetime.timedelta(
            days=1)
Exemplo n.º 3
0
class Tournament(Model):
    tid = fields.SmallIntegerField(primary_key=True)
    name = fields.CharField(max_length=100,
                            description="Tournament name",
                            db_index=True)
    created = fields.DateTimeField(auto_now_add=True,
                                   description="Created */'`/* datetime")

    class Meta:
        table_description = "What Tournaments */'`/* we have"
Exemplo n.º 4
0
class Event(Model):
    id = fields.IntegerField(primary_key=True)
    name = fields.TextField()
    datetime = fields.DateTimeField(null=True)

    class Meta:
        db_table = "event"

    def __str__(self):
        return self.name
Exemplo n.º 5
0
class Tournament(Model):
    id = fields.IntegerField(primary_key=True)
    name = fields.CharField(max_length=255,
                            description="Tournament name",
                            db_index=True)
    created = fields.DateTimeField(auto_now_add=True,
                                   description="Created datetime")

    events: fields.ReverseRelation["Event"]

    class Meta:
        table_description = "What Tournaments we have"
Exemplo n.º 6
0
class Event(Model):
    id = fields.IntegerField(primary_key=True)
    name = fields.TextField(
        description="Name of the event that corresponds to an action")
    datetime = fields.DateTimeField(
        null=True, description="Datetime of when the event was generated")

    class Meta:
        db_table = "event"
        table_description = "This table contains a list of all the example events"

    def __str__(self):
        return self.name
Exemplo n.º 7
0
class Event(Model):
    id = fields.BigIntegerField(primary_key=True)
    name = fields.TextField()
    tournament: fields.ForeignKeyRelation["Tournament"] = fields.ForeignKey(
        "models.Tournament", related_name="events")
    reporter: fields.ForeignKeyNullableRelation[Reporter] = fields.ForeignKey(
        "models.Reporter", null=True)
    participants: fields.ManyToManyRelation["Team"] = fields.ManyToManyField(
        "models.Team",
        related_name="events",
        through="event_team",
        backward_key="idEvent")
    modified = fields.DateTimeField(auto_now=True)
    token = fields.TextField(default=generate_token)
    alias = fields.IntegerField(null=True)

    def __str__(self):
        return self.name
Exemplo n.º 8
0
class Tournament(Model):
    class Meta:
        ordering = [
            '-created',
        ]

    id = fields.SmallIntegerField(primary_key=True)
    name = fields.CharField(max_length=255)
    desc = fields.TextField(null=True)
    created = fields.DateTimeField(auto_now_add=True, db_index=True)

    events: fields.ReverseRelation["Event"]
    minrelations: fields.ReverseRelation["MinRelation"]
    uniquetogetherfieldswithfks: fields.ReverseRelation[
        "UniqueTogetherFieldsWithFK"]

    def __str__(self):
        return self.name
Exemplo n.º 9
0
class Event(Model):
    id = fields.IntegerField(primary_key=True, description="Event ID")
    name = fields.CharField(max_length=255, unique=True)
    tournament: fields.ForeignKeyRelation[Tournament] = fields.ForeignKey(
        "models.Tournament",
        related_name="events",
        description="FK to tournament")
    participants: fields.ManyToManyRelation["Team"] = fields.ManyToManyField(
        "models.Team",
        related_name="events",
        through="event_team",
        description="How participants relate",
    )
    modified = fields.DateTimeField(auto_now=True)
    prize = fields.DecimalField(max_digits=10, decimal_places=2, null=True)
    token = fields.CharField(max_length=100,
                             description="Unique token",
                             unique=True)

    class Meta:
        table_description = "This table contains a list of all the events"
Exemplo n.º 10
0
class Event(Model):
    id = fields.BigIntegerField(primary_key=True, description="Event ID")
    name = fields.TextField()
    tournament = fields.ForeignKey("models.Tournament",
                                   related_name="events",
                                   description="FK to tournament")
    participants = fields.ManyToManyField(
        "models.Team",
        related_name="events",
        through="teamevents",
        description="How participants relate",
    )
    modified = fields.DateTimeField(auto_now=True)
    prize = fields.DecimalField(max_digits=10, decimal_places=2, null=True)
    token = fields.CharField(max_length=100,
                             description="Unique token",
                             unique=True)
    key = fields.CharField(max_length=100)

    class Meta:
        table_description = "This table contains a list of all the events"
        unique_together = [("name", "prize"), ["tournament", "key"]]
Exemplo n.º 11
0
class DatetimeFields(Model):
    id = fields.IntegerField(primary_key=True)
    datetime = fields.DateTimeField()
    datetime_null = fields.DateTimeField(null=True)
    datetime_auto = fields.DateTimeField(auto_now=True)
    datetime_add = fields.DateTimeField(auto_now_add=True)
Exemplo n.º 12
0
class TimestampMixin:
    created_at = fields.DateTimeField(null=True, auto_now_add=True)
    modified_at = fields.DateTimeField(null=True, auto_now=True)
Exemplo n.º 13
0
 def test_both_auto_bad(self):
     with self.assertRaisesRegex(
         ConfigurationError, "You can choose only 'auto_now' or 'auto_now_add'"
     ):
         fields.DateTimeField(auto_now=True, auto_now_add=True)