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
24 changes: 0 additions & 24 deletions Dockerfile.web

This file was deleted.

41 changes: 0 additions & 41 deletions bin/setup_pythonanywhere.sh

This file was deleted.

15 changes: 5 additions & 10 deletions mittab/apps/tab/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from decimal import Decimal
import os
import itertools
import pprint
import logging

from django.db import transaction
from django import forms
Expand All @@ -12,6 +12,9 @@
from mittab import settings


logger = logging.getLogger('mittab')


class UploadBackupForm(forms.Form):
file = forms.FileField(label="Your Backup File")

Expand Down Expand Up @@ -458,7 +461,7 @@ def clean(self):
self._errors[key] = self.error_class([msg])

except Exception as e:
print(("Caught error %s" % e))
logger.error("Error validating eballot form", exc_info=True)
self._errors["winner"] = self.error_class(
["Non handled error, preventing data contamination"])

Expand Down Expand Up @@ -565,9 +568,6 @@ def score_panel(result, discard_minority):
ranked = [(deb, role, speak, rank + 1)
for (rank, (deb, role, speak, _)) in enumerate(ranked)]

print("Ranked Debaters")
pprint.pprint(ranked)

# Break any ties by taking the average of the tied ranks
ties = {}
for (score_i, score) in enumerate(ranked):
Expand All @@ -580,9 +580,6 @@ def score_panel(result, discard_minority):
else:
ties[tie_key] = [(score_i, score[3])]

print("Ties")
pprint.pprint(ties)

# Average over the tied ranks
for val in ties.values():
if len(val) > 1:
Expand All @@ -592,8 +589,6 @@ def score_panel(result, discard_minority):
final_score = ranked[i]
ranked[i] = (final_score[0], final_score[1], final_score[2],
avg)
print("Final scores")
pprint.pprint(ranked)

return ranked, final_winner

Expand Down
3 changes: 0 additions & 3 deletions mittab/apps/tab/management/commands/export_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def handle(self, *args, **kwargs):
if not os.path.exists(kwargs["root"]):
os.makedirs(kwargs["root"])

print("Calculating ranks")
teams = [
self.make_team_row(team_score.team)
for team_score in tab_logic.rankings.rank_teams()
Expand All @@ -84,7 +83,6 @@ def is_novice_team(team):
if deb_score.debater.novice_status == Debater.NOVICE
]

print("Writing to csv")
self.write_to_csv(os.path.join(kwargs["root"], kwargs["team_file"]),
self.TEAM_ROWS, teams)
self.write_to_csv(
Expand All @@ -95,4 +93,3 @@ def is_novice_team(team):
self.write_to_csv(
os.path.join(kwargs["root"], kwargs["nov_debater_file"]),
self.DEBATER_ROWS, nov_debaters)
print("Done!")
138 changes: 0 additions & 138 deletions mittab/apps/tab/management/commands/load_test.py

This file was deleted.

10 changes: 6 additions & 4 deletions mittab/apps/tab/pairing_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
import time
import datetime
import logging

from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
Expand All @@ -21,6 +22,9 @@
import mittab.libs.backup as backup


logger = logging.getLogger('mittab')


@permission_required("tab.tab_settings.can_change", login_url="/403/")
def pair_round(request):
cache_logic.clear_cache()
Expand Down Expand Up @@ -120,7 +124,7 @@ def view_backup(request, filename):

@permission_required("tab.tab_settings.can_change", login_url="/403/")
def download_backup(request, key):
print("Trying to download {}".format(key))
logger.info(f"Trying to download {key}")
data = backup.get_backup_content(key)
response = HttpResponse(data, content_type="text/plain")
response["Content-Disposition"] = "attachment; filename=%s" % key
Expand Down Expand Up @@ -409,11 +413,10 @@ def pretty_pair(request, printable=False):
for present_team in Team.objects.filter(checked_in=True):
if present_team not in paired_teams:
if present_team not in byes:
print("got error for", present_team)
logger.error(f"got error for {present_team}")
errors.append(present_team)

pairing_exists = TabSettings.get("pairing_released", 0) == 1
printable = printable
return render(request, "pairing/pairing_display.html", locals())


Expand Down Expand Up @@ -591,7 +594,6 @@ def enter_multiple_results(request, round_id, num_entered):
if all_good:
final_scores, final_winner = score_panel(
result, "discard_minority" in request.POST)
print(final_scores)
for (debater, role, speaks, ranks) in final_scores:
RoundStats.objects.create(debater=debater,
round=round_obj,
Expand Down
50 changes: 35 additions & 15 deletions mittab/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,40 @@
}
}

if os.environ.get("MITTAB_LOG_QUERIES"):
LOGGING = {
"version": 1,
"handlers": {
"console": {
"class": "logging.StreamHandler",
},
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
'style': '{',
},
"loggers": {
"django.db.backends": {
"level": "DEBUG",
},
'simple': {
'format': '{levelname} {message}',
'style': '{',
},
"root": {
"handlers": ["console"],
}
}
},
'handlers': {
'console': {
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.environ.get('DJANGO_LOG_LEVEL', 'INFO'),
'propagate': True,
},
'mittab': {
'handlers': ['console'],
'level': os.environ.get('MITTAB_LOG_LEVEL', 'INFO'),
'propagate': True,
},
'django.db.backends': {
'handlers': ['console'],
'level': 'INFO',
'propagate': False,
},
},
}