Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions assets/js/outround.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ function assignTeam(e) {
$container.find(".outround-tabcard").attr("team-id", result.team.id);
populateTabCards();
} else {
window.alert(alertMsg);
window.alert(result.message || alertMsg);
}
},
failure() {
error() {
window.alert(alertMsg);
},
});
Expand Down Expand Up @@ -125,6 +125,7 @@ function assignJudge(e) {
const url = `/outround/${roundId}/assign_judge/${judgeId}/${
curJudgeId || ""
}`;
const alertMsg = "Unable to assign that judge. Refresh and try again.";

let $buttonWrapper;
if (curJudgeId) {
Expand All @@ -139,6 +140,10 @@ function assignJudge(e) {
url,
success(result) {
$button.removeClass("disabled");
if (!result.success) {
window.alert(result.message || alertMsg);
return;
}
$buttonWrapper.removeClass("unassigned");
$buttonWrapper.attr("judge-id", result.judge_id);

Expand All @@ -148,6 +153,10 @@ function assignJudge(e) {
$(`.judges span[round-id=${roundId}][judge-id=${result.chair_id}]
.judge-toggle`).addClass("chair");
},
error() {
$button.removeClass("disabled");
window.alert(alertMsg);
},
});
}

Expand Down
13 changes: 11 additions & 2 deletions assets/js/pairing.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ function assignTeam(e) {

populateTabCards();
} else {
window.alert(alertMsg);
window.alert(result.message || alertMsg);
}
},
failure() {
error() {
window.alert(alertMsg);
},
});
Expand Down Expand Up @@ -191,6 +191,7 @@ function assignJudge(e) {
const judgeId = $(e.target).attr("judge-id");
const curJudgeId = $(e.target).attr("current-judge-id");
const url = `/round/${roundId}/assign_judge/${judgeId}/${curJudgeId || ""}`;
const alertMsg = "Unable to assign that judge. Refresh and try again.";

let $buttonWrapper;
if (curJudgeId) {
Expand All @@ -205,6 +206,10 @@ function assignJudge(e) {
url,
success(result) {
$button.removeClass("disabled");
if (!result.success) {
window.alert(result.message || alertMsg);
return;
}
$buttonWrapper.removeClass("unassigned");
$buttonWrapper.addClass("judge-assignment manual-lay");
$buttonWrapper.attr("judge-id", result.judge_id);
Expand All @@ -217,6 +222,10 @@ function assignJudge(e) {
$(`.judges span[round-id=${roundId}][judge-id=${result.chair_id}]
.judge-toggle`).addClass("chair");
},
error() {
$button.removeClass("disabled");
window.alert(alertMsg);
},
});
}

Expand Down
14 changes: 12 additions & 2 deletions mittab/apps/tab/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,21 @@ class TeamAdmin(admin.ModelAdmin):


class MotionAdmin(admin.ModelAdmin):
list_display = ("round_display", "motion_text_truncated", "is_published", "updated_at")
list_display = (
"round_display",
"motion_text_truncated",
"is_published",
"updated_at",
)
list_filter = ("is_published", "outround_type")
search_fields = ("motion_text", "info_slide")
ordering = ("round_number", "outround_type", "-num_teams")

def motion_text_truncated(self, obj):
return obj.motion_text[:100] + "..." if len(obj.motion_text) > 100 else obj.motion_text
if len(obj.motion_text) > 100:
return obj.motion_text[:100] + "..."
return obj.motion_text

motion_text_truncated.short_description = "Motion Text"


Expand All @@ -62,4 +70,6 @@ def motion_text_truncated(self, obj):
admin.site.register(models.NoShow)
admin.site.register(models.BreakingTeam)
admin.site.register(models.Outround, OutroundAdmin)
admin.site.register(models.JudgeJudgeScratch)
admin.site.register(models.TeamTeamScratch)
admin.site.register(models.Motion, MotionAdmin)
40 changes: 40 additions & 0 deletions mittab/apps/tab/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,46 @@ class Meta:
exclude = ["team", "judge"]


class JudgeJudgeScratchForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
judge_queryset = kwargs.pop("judge_queryset", Judge.objects.all())
super().__init__(*args, **kwargs)
self.fields["judge_one"].queryset = judge_queryset
self.fields["judge_two"].queryset = judge_queryset

def clean(self):
cleaned_data = super().clean()
judge_one = cleaned_data.get("judge_one")
judge_two = cleaned_data.get("judge_two")
if judge_one and judge_two and judge_one == judge_two:
raise forms.ValidationError("Pick two different judges")
return cleaned_data

class Meta:
model = JudgeJudgeScratch
fields = "__all__"


class TeamTeamScratchForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
team_queryset = kwargs.pop("team_queryset", Team.objects.all())
super().__init__(*args, **kwargs)
self.fields["team_one"].queryset = team_queryset
self.fields["team_two"].queryset = team_queryset

def clean(self):
cleaned_data = super().clean()
team_one = cleaned_data.get("team_one")
team_two = cleaned_data.get("team_two")
if team_one and team_two and team_one == team_two:
raise forms.ValidationError("Pick two different teams")
return cleaned_data

class Meta:
model = TeamTeamScratch
fields = "__all__"


class DebaterForm(forms.ModelForm):
class Meta:
model = Debater
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# pylint: disable=invalid-name,line-too-long
# Generated by Django 3.2.25 on 2025-11-05 23:59

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


class Migration(migrations.Migration):

dependencies = [
('tab', '0031_remove_noshow_lenient_late'),
]

operations = [
migrations.CreateModel(
name='TeamTeamScratch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('team_one', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='team_scratch_primary', to='tab.team')),
('team_two', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='team_scratch_secondary', to='tab.team')),
],
options={
'verbose_name_plural': 'team scratches',
'unique_together': {('team_one', 'team_two')},
},
),
migrations.CreateModel(
name='JudgeJudgeScratch',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('judge_one', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='judge_scratch_primary', to='tab.judge')),
('judge_two', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='judge_scratch_secondary', to='tab.judge')),
],
options={
'verbose_name_plural': 'judge scratches',
'unique_together': {('judge_one', 'judge_two')},
},
),
]
15 changes: 15 additions & 0 deletions mittab/apps/tab/migrations/0037_merge_20260326_0343.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pylint: disable=invalid-name
# Generated by Django 3.2.25 on 2026-03-26 03:43

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('tab', '0032_judgejudgescratch_teamteamscratch'),
('tab', '0036_alter_outround_room_nullable'),
]

operations = [
]
Loading
Loading