Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 271 #272

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dabdaf7
Resolves issue
roddajohn Oct 21, 2019
ff9c4de
Formatting
roddajohn Feb 26, 2023
36bb64f
Revert "Formatting"
roddajohn Feb 26, 2023
cb9e1dc
Resolves (#273)
roddajohn Oct 21, 2019
117bac8
Replace Sqlite with MySQL (#277)
BenMusch Nov 4, 2019
1c9e3af
Fix backup/restore
Nov 11, 2019
33d54f9
Add team codes to DebateXML export (#278)
tienne-B Nov 12, 2019
c6f6176
Initial setup
Nov 22, 2019
0754ce1
Get it working
Nov 22, 2019
0f20010
Disable ATOMIC_REQUESTS (#281)
BenMusch Nov 22, 2019
5af2f35
Redirect traffic to a page w/o db access during backup write/restore …
BenMusch Nov 29, 2019
df2559f
Use mysqldump for backups (#287)
BenMusch Dec 1, 2019
0e356fc
Switch to pipenv for package management (#291)
BenMusch May 16, 2020
7348aa9
Finalizing outrounds implementation (#292)
roddajohn May 16, 2020
c32af01
Some debugging
BenMusch Sep 10, 2020
3367328
Some fixing
Sep 10, 2020
93bf709
Update setup
BenMusch Mar 24, 2021
4478e4f
Update settings.py
BenMusch Mar 24, 2021
3a95a54
Bump node version
Sep 2, 2021
60fd7a6
Tab-Policy: fix typo regarding byes (#320)
DanielS6 Oct 19, 2021
5630590
updated
roddajohn Feb 26, 2023
ee43049
Update docker to include the settings.yaml file
Feb 10, 2022
f718ade
Fix bug with bye speaks (#328)
BenMusch Mar 1, 2022
02e3356
Fix bug displaying stats in pairings (#329)
BenMusch Mar 1, 2022
9f93a54
Formatting
roddajohn Feb 26, 2023
b1c63bf
Revert "Formatting"
roddajohn Feb 26, 2023
4d3e74e
updated
roddajohn Feb 26, 2023
37c7a7c
Judge scratches are now updated whenever a judge is updated
roddajohn Feb 26, 2023
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
142 changes: 81 additions & 61 deletions mittab/apps/tab/judge_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from mittab.apps.tab.helpers import redirect_and_flash_error, redirect_and_flash_success
from mittab.apps.tab.models import *
from mittab.libs.errors import *
from mittab.libs.tab_logic import TabFlags
from mittab.libs.tab_logic import (
TabFlags,
add_scratches_for_single_judge_for_school_affiliation,
)


def public_view_judges(request):
Expand All @@ -19,14 +22,14 @@ def public_view_judges(request):
rounds = [num for num in range(1, num_rounds + 1)]

return render(
request, "public/judges.html", {
"judges": Judge.objects.order_by("name").all(),
"rounds": rounds
})
request,
"public/judges.html",
{"judges": Judge.objects.order_by("name").all(), "rounds": rounds},
)


def view_judges(request):
#Get a list of (id,school_name) tuples
# Get a list of (id,school_name) tuples
current_round = TabSettings.objects.get(key="cur_round").value - 1
checkins = CheckIn.objects.filter(round_number=current_round)
checkins_next = CheckIn.objects.filter(round_number=(current_round + 1))
Expand All @@ -52,25 +55,35 @@ def flags(judge):
result |= TabFlags.HIGH_RANKED_JUDGE
return result

c_judge = [(judge.pk, judge.name, flags(judge), "(%s)" % judge.ballot_code)
for judge in Judge.objects.all()]

all_flags = [[
TabFlags.JUDGE_CHECKED_IN_CUR, TabFlags.JUDGE_NOT_CHECKED_IN_CUR,
TabFlags.JUDGE_CHECKED_IN_NEXT, TabFlags.JUDGE_NOT_CHECKED_IN_NEXT
],
[
TabFlags.LOW_RANKED_JUDGE, TabFlags.MID_RANKED_JUDGE,
TabFlags.HIGH_RANKED_JUDGE
]]
c_judge = [
(judge.pk, judge.name, flags(judge), "(%s)" % judge.ballot_code)
for judge in Judge.objects.all()
]

all_flags = [
[
TabFlags.JUDGE_CHECKED_IN_CUR,
TabFlags.JUDGE_NOT_CHECKED_IN_CUR,
TabFlags.JUDGE_CHECKED_IN_NEXT,
TabFlags.JUDGE_NOT_CHECKED_IN_NEXT,
],
[
TabFlags.LOW_RANKED_JUDGE,
TabFlags.MID_RANKED_JUDGE,
TabFlags.HIGH_RANKED_JUDGE,
],
]
filters, _symbol_text = TabFlags.get_filters_and_symbols(all_flags)
return render(
request, "common/list_data.html", {
request,
"common/list_data.html",
{
"item_type": "judge",
"title": "Viewing All Judges",
"item_list": c_judge,
"filters": filters,
})
},
)


def view_judge(request, judge_id):
Expand All @@ -86,43 +99,50 @@ def view_judge(request, judge_id):
form.save()
except ValueError:
return redirect_and_flash_error(
request, "Judge information cannot be validated")
request, "Judge information cannot be validated"
)
return redirect_and_flash_success(
request, "Judge {} updated successfully".format(
form.cleaned_data["name"]))
request,
"Judge {} updated successfully".format(form.cleaned_data["name"]),
)
else:
form = JudgeForm(instance=judge)
base_url = "/judge/" + str(judge_id) + "/"
scratch_url = base_url + "scratches/view/"
links = [(scratch_url, "Scratches for {}".format(judge.name))]
return render(
request, "common/data_entry.html", {
"form": form,
"links": links,
"title": "Viewing Judge: {}".format(judge.name)
})
request,
"common/data_entry.html",
{"form": form, "links": links, "title": "Viewing Judge: {}".format(judge.name)},
)


def enter_judge(request):
if request.method == "POST":
form = JudgeForm(request.POST)
if form.is_valid():
try:
form.save()
judge = form.save()

teams = Team.objects.all().prefetch_related("school", "hybrid_school")

scratches = add_scratches_for_single_judge_for_school_affiliation(
judge, teams
)
Scratch.objects.bulk_create(scratches)

except ValueError:
return redirect_and_flash_error(request,
"Judge cannot be validated")
return redirect_and_flash_error(request, "Judge cannot be validated")
return redirect_and_flash_success(
request,
"Judge {} created successfully".format(
form.cleaned_data["name"]),
path="/")
"Judge {} created successfully".format(form.cleaned_data["name"]),
path="/",
)
else:
form = JudgeForm(first_entry=True)
return render(request, "common/data_entry.html", {
"form": form,
"title": "Create Judge"
})
return render(
request, "common/data_entry.html", {"form": form, "title": "Create Judge"}
)


def add_scratches(request, judge_id, number_scratches):
Expand All @@ -146,22 +166,21 @@ def add_scratches(request, judge_id, number_scratches):
if all_good:
for form in forms:
form.save()
return redirect_and_flash_success(
request, "Scratches created successfully")
return redirect_and_flash_success(request, "Scratches created successfully")
else:
forms = [
ScratchForm(prefix=str(i),
initial={
"judge": judge_id,
"scratch_type": 0
}) for i in range(1, number_scratches + 1)
ScratchForm(prefix=str(i), initial={"judge": judge_id, "scratch_type": 0})
for i in range(1, number_scratches + 1)
]
return render(
request, "common/data_entry_multiple.html", {
request,
"common/data_entry_multiple.html",
{
"forms": list(zip(forms, [None] * len(forms))),
"data_type": "Scratch",
"title": "Adding Scratch(es) for %s" % (judge.name)
})
"title": "Adding Scratch(es) for %s" % (judge.name),
},
)


def view_scratches(request, judge_id):
Expand All @@ -183,13 +202,11 @@ def view_scratches(request, judge_id):
if all_good:
for form in forms:
form.save()
return redirect_and_flash_success(
request, "Scratches created successfully")
return redirect_and_flash_success(request, "Scratches created successfully")
else:
forms = [
ScratchForm(prefix=str(i), instance=scratches[i - 1])
for i in range(1,
len(scratches) + 1)
for i in range(1, len(scratches) + 1)
]
delete_links = [
"/judge/" + str(judge_id) + "/scratches/delete/" + str(scratches[i].id)
Expand All @@ -198,12 +215,15 @@ def view_scratches(request, judge_id):
links = [("/judge/" + str(judge_id) + "/scratches/add/1/", "Add Scratch")]

return render(
request, "common/data_entry_multiple.html", {
request,
"common/data_entry_multiple.html",
{
"forms": list(zip(forms, delete_links)),
"data_type": "Scratch",
"links": links,
"title": "Viewing Scratch Information for %s" % (judge.name)
})
"title": "Viewing Scratch Information for %s" % (judge.name),
},
)


def batch_checkin(request):
Expand All @@ -212,14 +232,15 @@ def batch_checkin(request):
round_numbers = list([i + 1 for i in range(TabSettings.get("tot_rounds"))])
for judge in Judge.objects.all():
checkins = []
for round_number in [0] + round_numbers: # 0 is for outrounds
for round_number in [0] + round_numbers: # 0 is for outrounds
checkins.append(judge.is_checked_in_for_round(round_number))
judges_and_checkins.append((judge, checkins))

return render(request, "tab/batch_checkin.html", {
"judges_and_checkins": judges_and_checkins,
"round_numbers": round_numbers
})
return render(
request,
"tab/batch_checkin.html",
{"judges_and_checkins": judges_and_checkins, "round_numbers": round_numbers},
)


@permission_required("tab.tab_settings.can_change", login_url="/403")
Expand All @@ -237,8 +258,7 @@ def judge_check_in(request, judge_id, round_number):
check_in.save()
elif request.method == "DELETE":
if judge.is_checked_in_for_round(round_number):
check_ins = CheckIn.objects.filter(judge=judge,
round_number=round_number)
check_ins = CheckIn.objects.filter(judge=judge, round_number=round_number)
check_ins.delete()
else:
raise Http404("Must be POST or DELETE")
Expand Down
18 changes: 18 additions & 0 deletions mittab/apps/tab/migrations/0013_auto_20191021_2136.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-10-21 21:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('tab', '0012_merge_20191017_0109'),
]

operations = [
migrations.AlterField(
model_name='scratch',
name='scratch_type',
field=models.IntegerField(choices=[(0, 'Discretionary Scratch'), (1, 'Tab Scratch'), (2, 'School Scratch')]),
),
]
Loading