Skip to content

Commit

Permalink
Add new model TournamentInstitution.
Browse files Browse the repository at this point in the history
  • Loading branch information
teymour-aldridge authored and tienne-B committed Sep 27, 2024
1 parent 517d3c3 commit c72b4a0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tabbycat/participants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
from venues.admin import VenueConstraintInline

from .emoji import pick_unused_emoji, populate_code_names_from_emoji, set_emoji
from .models import Adjudicator, Institution, Region, Speaker, SpeakerCategory, Team
from .models import (
Adjudicator,
Institution,
Region,
Speaker,
SpeakerCategory,
Team,
TournamentInstitution,
)


# ==============================================================================
Expand All @@ -39,6 +47,24 @@ class InstitutionAdmin(ModelAdmin):
ordering = ('name', )
search_fields = ('name', )

# ==============================================================================
# Tournament institution
# ==============================================================================


@admin.register(TournamentInstitution)
class TournamentInstitutionAdmin(ModelAdmin):
list_filter = ('institution', 'tournament')
list_display = (
'institution',
'tournament',
'teams_requested',
'teams_allocated',
'adjudicators_requested',
'adjudicators_allocated',
)
search_fields = ('institution__name', 'tournament__name')


# ==============================================================================
# Speaker
Expand Down
27 changes: 27 additions & 0 deletions tabbycat/participants/migrations/0024_tournamentinstitution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.0.4 on 2024-09-12 20:16

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('participants', '0023_alter_unique_together_and_team_emoji'),
('tournaments', '0013_scheduleevent'),
]

operations = [
migrations.CreateModel(
name='TournamentInstitution',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('teams_requested', models.PositiveIntegerField(verbose_name='Team slots requested')),
('teams_allocated', models.PositiveIntegerField(verbose_name='Team slots allocatd')),
('adjudicators_requested', models.PositiveIntegerField(verbose_name='Adjudicator slots requested')),
('adjudicators_allocated', models.PositiveIntegerField(verbose_name='Adjudicator slots allocated')),
('institution', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='participants.institution', verbose_name='institution')),
('tournament', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tournaments.tournament', verbose_name='tournament')),
],
),
]
19 changes: 19 additions & 0 deletions tabbycat/participants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ def __str__(self):
return str(self.name)


class TournamentInstitution(models.Model):
tournament = models.ForeignKey(
"tournaments.Tournament", models.CASCADE, verbose_name=_("tournament"),
)
institution = models.ForeignKey(
Institution, models.CASCADE, verbose_name=_("institution"),
)
teams_requested = models.PositiveIntegerField(
verbose_name=_("Team slots requested"),
)
teams_allocated = models.PositiveIntegerField(verbose_name=_("Team slots allocated"))
adjudicators_requested = models.PositiveIntegerField(
verbose_name=_("Adjudicator slots requested"),
)
adjudicators_allocated = models.PositiveIntegerField(
verbose_name=_("Adjudicator slots allocated"),
)


class SpeakerCategory(models.Model):
tournament = models.ForeignKey('tournaments.Tournament', models.CASCADE,
verbose_name=_("tournament"))
Expand Down

0 comments on commit c72b4a0

Please sign in to comment.