From 280c26d639e7f80ac9e70ad105ae4c84ec287529 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sat, 17 Oct 2020 23:11:19 +0000 Subject: [PATCH 01/18] Initial commit for S08-Judging --- hackathon/templates/hackathon/judging.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 hackathon/templates/hackathon/judging.html diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html new file mode 100644 index 00000000..838aa183 --- /dev/null +++ b/hackathon/templates/hackathon/judging.html @@ -0,0 +1 @@ +{% extends 'base.html' %} \ No newline at end of file From 2d5539bfc68ca867fc65466be8a7b4f360f4d6f6 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 18 Oct 2020 11:48:01 +0000 Subject: [PATCH 02/18] Add highest_score field to HPScoreCategory model --- ...8_hackprojectscorecategory_highest_score.py | 18 ++++++++++++++++++ hackathon/models.py | 3 +++ hackathon/tests/test_models.py | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 hackathon/migrations/0008_hackprojectscorecategory_highest_score.py diff --git a/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py b/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py new file mode 100644 index 00000000..a6b14d9e --- /dev/null +++ b/hackathon/migrations/0008_hackprojectscorecategory_highest_score.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2020-10-18 11:43 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hackathon', '0007_auto_20201017_1148'), + ] + + operations = [ + migrations.AddField( + model_name='hackprojectscorecategory', + name='highest_score', + field=models.IntegerField(default=10), + ), + ] diff --git a/hackathon/models.py b/hackathon/models.py index cc1f1b11..23d767f8 100644 --- a/hackathon/models.py +++ b/hackathon/models.py @@ -166,6 +166,9 @@ class HackProjectScoreCategory(models.Model): on_delete=models.CASCADE, related_name="hackprojectscorecategories") category = models.CharField(default="", max_length=255) + # Score Categories can have different score range (e.g. 1-10, 1-15) + # this field sets the upper end of the scale + highest_score = models.IntegerField(default=10) def __str__(self): return self.category diff --git a/hackathon/tests/test_models.py b/hackathon/tests/test_models.py index 0c2c3b23..0bef2536 100644 --- a/hackathon/tests/test_models.py +++ b/hackathon/tests/test_models.py @@ -49,7 +49,8 @@ def setUp(self): score_category = HackProjectScoreCategory.objects.create( created_by=user, - category="testcategory") + category="testcategory", + highest_score=15) score_category.save() score = HackProjectScore.objects.create( From 6df7c730715bc1c00b7cd7829ec990b57a85bfef Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 18 Oct 2020 13:38:18 +0000 Subject: [PATCH 03/18] Set up basic urls - views - template for Judging landing page --- hackathon/templates/hackathon/judging.html | 8 +++++++- hackathon/urls.py | 3 ++- hackathon/views.py | 12 ++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index 838aa183..fc9a27db 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -1 +1,7 @@ -{% extends 'base.html' %} \ No newline at end of file +{% extends 'base.html' %} + + +{% block content %} +

FOO

+ +{% endblock %} \ No newline at end of file diff --git a/hackathon/urls.py b/hackathon/urls.py index 96f8167f..a42ce292 100644 --- a/hackathon/urls.py +++ b/hackathon/urls.py @@ -1,5 +1,6 @@ from django.urls import path +from . import views urlpatterns = [ - + path("", views.judging, name="judging") ] diff --git a/hackathon/views.py b/hackathon/views.py index 91ea44a2..c2b8a5b1 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -1,3 +1,15 @@ from django.shortcuts import render +from django.contrib.auth.decorators import login_required +from .models import Hackathon, HackTeam, HackProject, HackProjectScore, HackProjectScoreCategory # Create your views here. + +@login_required +def judging(request): + """Displays the judging landing page for the judge to save their scores + for each submitted project""" + + + template = 'hackathon/judging.html' + context = {} + return render(request, template, context) \ No newline at end of file From fd26d6b457737802da8fb875d540025e0f9cc55b Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 18 Oct 2020 15:01:42 +0000 Subject: [PATCH 04/18] prepare context for judging landing page --- hackathon/urls.py | 2 +- hackathon/views.py | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/hackathon/urls.py b/hackathon/urls.py index a42ce292..a27e361a 100644 --- a/hackathon/urls.py +++ b/hackathon/urls.py @@ -2,5 +2,5 @@ from . import views urlpatterns = [ - path("", views.judging, name="judging") + path("judging/", views.judging, name="judging") ] diff --git a/hackathon/views.py b/hackathon/views.py index c2b8a5b1..b6f64f1c 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -1,3 +1,5 @@ +import datetime +from django.utils import timezone from django.shortcuts import render from django.contrib.auth.decorators import login_required from .models import Hackathon, HackTeam, HackProject, HackProjectScore, HackProjectScoreCategory @@ -9,7 +11,28 @@ def judging(request): """Displays the judging landing page for the judge to save their scores for each submitted project""" - + # Only "open" Hackathons can be judged, theoretically there can be + # more than one event at a time, filter events by start_date - end_date + events = Hackathon.objects.all() + open_events = [] + for hackathon in events: + start = hackathon.start_date + finish = hackathon.end_date + now = timezone.now() + if start < now and now < finish: + open_events.append(hackathon) + number_of_open_events = len(open_events) + print(f"There is/are {number_of_open_events} open event(s) atm, \nthey are: {open_events}") + + # Users can see this page, but only judges should be able to start the judging process + judging_events = Hackathon.objects.filter(judges=request.user) + print(f"hackathons filterd for the user as judge: {judging_events}") + template = 'hackathon/judging.html' - context = {} + context = { + 'number_of_open_events': number_of_open_events, + 'open_events': open_events, + 'judging_events': judging_events, + 'number_of_events_to_judge': len(judging_events), + } return render(request, template, context) \ No newline at end of file From 70a6d3350cdfa8d9539ede6706c10df68a1a20d2 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Mon, 19 Oct 2020 21:11:21 +0000 Subject: [PATCH 05/18] Add verifications to judging view --- .../hackathon/includes/hackathon_card.html | 2 +- hackathon/urls.py | 2 +- hackathon/views.py | 62 ++++++++++++++----- 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/hackathon/templates/hackathon/includes/hackathon_card.html b/hackathon/templates/hackathon/includes/hackathon_card.html index 4c957158..09482646 100644 --- a/hackathon/templates/hackathon/includes/hackathon_card.html +++ b/hackathon/templates/hackathon/includes/hackathon_card.html @@ -13,7 +13,7 @@
{{ hackathon.start_date }} - {{ hackat {% if user in hackathon.judges.all %} - Scores + Scores {% endif %} diff --git a/hackathon/urls.py b/hackathon/urls.py index 1cbb495e..1f2ada44 100644 --- a/hackathon/urls.py +++ b/hackathon/urls.py @@ -4,5 +4,5 @@ urlpatterns = [ path('', HackathonListView.as_view(), name="hackathon-list"), - path("judging/", views.judging, name="judging"), + path("/team//judging/", views.judging, name="judging"), ] diff --git a/hackathon/views.py b/hackathon/views.py index f9c1fcfc..4eca737b 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -1,9 +1,10 @@ import datetime from django.utils import timezone -from django.shortcuts import render +from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth.decorators import login_required from .models import Hackathon, HackTeam, HackProject, HackProjectScore, HackProjectScoreCategory from django.views.generic import ListView +from django.contrib import messages # Create your views here. @@ -22,16 +23,47 @@ def judging(request, hack_id, team_id): # Becomes available only after a Hackathon End Date/Time - events = Hackathon.objects.all() - open_events = [] - for hackathon in events: - start = hackathon.start_date - finish = hackathon.end_date - now = timezone.now() - if start < now and now < finish: - open_events.append(hackathon) - number_of_open_events = len(open_events) - print(f"There is/are {number_of_open_events} open event(s) atm, \nthey are: {open_events}") + event = Hackathon.objects.filter(pk=hack_id) + team = HackTeam.objects.filter(pk=team_id) + + # verify whether user is judge for the event + user_is_judge = False + for judge in event.values('judges'): + if judge['judges'] == request.user.id: + print("judge there") + user_is_judge = True + if not user_is_judge: + messages.error(request, "You are not a judge for that event!") + template = 'hackathon/hackathon_list.html' + return render(request, template) + + # verify if event is ready to be judged (finished) + finish = event.values('end_date')[0]['end_date'] + now = timezone.now() + if finish > now: + messages.error(request, f"The event has not finished yet, check back after {finish}!") + template = 'hackathon/hackathon_list.html' + return render(request, template) + print("the event has finished") + + # verify that the selected team belongs to the selected event + team_belongs_to_event = False + for team in event.values('teams'): + if team['teams'] == int(team_id): + team_belongs_to_event = True + print("team is in event") + if not team_belongs_to_event: + messages.error(request, f"Nice try! That team is not part of the event...") + template = 'hackathon/hackathon_list.html' + return render(request, template) + + # check if the judge has already scored the requested team's Project + # ******************************************************************** + project = team.values('project') + print(f"Team Project: {project[0]['project']}") + + bar = HackProject.objects.filter(pk=project[0]['project']) + print(f"the project from the HackProject model: {bar}") # Users can see this page, but only judges should be able to start the judging process judging_events = Hackathon.objects.filter(judges=request.user) @@ -39,9 +71,9 @@ def judging(request, hack_id, team_id): template = 'hackathon/judging.html' context = { - 'number_of_open_events': number_of_open_events, - 'open_events': open_events, - 'judging_events': judging_events, - 'number_of_events_to_judge': len(judging_events), + # 'number_of_open_events': number_of_open_events, + # 'open_events': open_events, + # 'judging_events': judging_events, + # 'number_of_events_to_judge': len(judging_events), } return render(request, template, context) From 7c7f0f92b46d3a98949710c418745fd2dbda7c4d Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Tue, 20 Oct 2020 21:33:52 +0000 Subject: [PATCH 06/18] Build the base for the template --- hackathon/templates/hackathon/judging.html | 43 +++++++++++++++++++++- hackathon/views.py | 36 ++++++++++++------ 2 files changed, 65 insertions(+), 14 deletions(-) diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index fc9a27db..ede948c4 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -2,6 +2,45 @@ {% block content %} -

FOO

+
+
+

Judging Team {{ selected_team }}

+ +
-{% endblock %} \ No newline at end of file +
+ {% for category in score_categories %} +
+
+
+ +
+
+
{{ category }}
+

there is no description field of the categories, that could be used here

+
+
+
+ {% endfor %} + +
+ + +
+{% endblock %} diff --git a/hackathon/views.py b/hackathon/views.py index 4eca737b..e17399fe 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -58,22 +58,34 @@ def judging(request, hack_id, team_id): return render(request, template) # check if the judge has already scored the requested team's Project - # ******************************************************************** - project = team.values('project') - print(f"Team Project: {project[0]['project']}") + + the_event = get_object_or_404(Hackathon, pk=hack_id) + team_ids_in_event = Hackathon.objects.filter(pk=hack_id).values_list('teams', flat=True) + print(f"teams_in_event = {team_ids_in_event}") + + # megse kene minden team-et a templatre kuldeni, mert nehezebb kezelni ott + + teams_in_event = [] + for team in team_ids_in_event: + teams_in_event.append(get_object_or_404(HackTeam, pk=team)) + print(f"team objects in list for the tempalte: {teams_in_event}") - bar = HackProject.objects.filter(pk=project[0]['project']) - print(f"the project from the HackProject model: {bar}") + # for project in team.values('project'): + # print(f"Team Project: {project['project']}") - # Users can see this page, but only judges should be able to start the judging process - judging_events = Hackathon.objects.filter(judges=request.user) - print(f"hackathons filterd for the user as judge: {judging_events}") + # bar = HackProject.objects.filter(pk=project[0]['project']) + # print(f"the project from the HackProject model: {bar}") + + # HackProjectScoreCategories for the template: + score_categories = HackProjectScoreCategory.objects.all() template = 'hackathon/judging.html' + # pass all the teams and their projects to the page, so the judge can swap context = { - # 'number_of_open_events': number_of_open_events, - # 'open_events': open_events, - # 'judging_events': judging_events, - # 'number_of_events_to_judge': len(judging_events), + 'hackathon': the_event, + 'teams': teams_in_event, #Project is part of the Team object + 'score_categories': score_categories, + 'selected_team': get_object_or_404(HackTeam, pk=team_id), + } return render(request, template, context) From 4e150fbe08c1b6b52b60725cce2bf6f65de15be2 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Wed, 21 Oct 2020 11:24:35 +0000 Subject: [PATCH 07/18] Add custom tag for creating score dropdowns --- .../hackathon/includes/hackathon_card.html | 3 ++- hackathon/templates/hackathon/judging.html | 17 +++++++----- hackathon/templatetags/__init__.py | 0 hackathon/templatetags/my_tags.py | 27 +++++++++++++++++++ hackathon/urls.py | 2 +- hackathon/views.py | 9 ++++++- 6 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 hackathon/templatetags/__init__.py create mode 100644 hackathon/templatetags/my_tags.py diff --git a/hackathon/templates/hackathon/includes/hackathon_card.html b/hackathon/templates/hackathon/includes/hackathon_card.html index 09482646..698acbc5 100644 --- a/hackathon/templates/hackathon/includes/hackathon_card.html +++ b/hackathon/templates/hackathon/includes/hackathon_card.html @@ -13,7 +13,8 @@
{{ hackathon.start_date }} - {{ hackat {% if user in hackathon.judges.all %} - Scores + Scores + {% endif %} diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index ede948c4..1c27f269 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -1,32 +1,35 @@ {% extends 'base.html' %} +{% load my_tags %} {% block content %}
-

Judging Team {{ selected_team }}

+

Judging Team {{ team }}

+ {% for category in score_categories %}
diff --git a/hackathon/templatetags/__init__.py b/hackathon/templatetags/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hackathon/templatetags/my_tags.py b/hackathon/templatetags/my_tags.py new file mode 100644 index 00000000..2a99c859 --- /dev/null +++ b/hackathon/templatetags/my_tags.py @@ -0,0 +1,27 @@ + +# range snippet from: https://www.djangosnippets.org/snippets/1357/ +# adjusted to current project needs based on https://docs.djangoproject.com/en/3.1/howto/custom-template-tags/ +from django.template import Library + +register = Library() + +@register.filter +def get_range(value, start): + """ + Filter - returns a list containing range made from given value + Usage (in template): + +
    {% for i in 3|get_range %} +
  • {{ i }}. Do something
  • + {% endfor %}
+ + Results with the HTML: +
    +
  • 0. Do something
  • +
  • 1. Do something
  • +
  • 2. Do something
  • +
+ + Instead of 3 one may use the variable set in the views + """ + return range(start, value+1, 1) diff --git a/hackathon/urls.py b/hackathon/urls.py index 1f2ada44..e6d71c6c 100644 --- a/hackathon/urls.py +++ b/hackathon/urls.py @@ -4,5 +4,5 @@ urlpatterns = [ path('', HackathonListView.as_view(), name="hackathon-list"), - path("/team//judging/", views.judging, name="judging"), + path("/team//judging/", views.judging, name="judging"), ] diff --git a/hackathon/views.py b/hackathon/views.py index e17399fe..5a253865 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -79,13 +79,20 @@ def judging(request, hack_id, team_id): # HackProjectScoreCategories for the template: score_categories = HackProjectScoreCategory.objects.all() + selected_team = get_object_or_404(HackTeam, pk=team_id) + selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) + template = 'hackathon/judging.html' # pass all the teams and their projects to the page, so the judge can swap context = { 'hackathon': the_event, 'teams': teams_in_event, #Project is part of the Team object 'score_categories': score_categories, - 'selected_team': get_object_or_404(HackTeam, pk=team_id), + 'team': selected_team, + 'project': selected_project, } + + print(f"XXXXXXXXXXXXXXXXXXXXX CONTEXT:\n{context}") + return render(request, template, context) From b816e10779d156c7421a8c08cd86d8b7c7fa9cc2 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 25 Oct 2020 11:30:18 +0000 Subject: [PATCH 08/18] Add my notes to .gitignore to avoid littering the repo --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 82ce8452..516b8da2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ env.py *.sqlite3 settings.json .gitpod.yml -setup.* \ No newline at end of file +setup.* +MYNOTES.md \ No newline at end of file From b1863b63cc0bc905951f3b67a30f95cfd9e2e30f Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 25 Oct 2020 12:48:43 +0000 Subject: [PATCH 09/18] Fix merge conflicts, delete sqlite and create a new, migrate --- .../migrations/0017_auto_20201025_1211.py | 26 +++++++++++++++++++ hackathon/templates/hackathon/judging.html | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 hackathon/migrations/0017_auto_20201025_1211.py diff --git a/hackathon/migrations/0017_auto_20201025_1211.py b/hackathon/migrations/0017_auto_20201025_1211.py new file mode 100644 index 00000000..89ce08e5 --- /dev/null +++ b/hackathon/migrations/0017_auto_20201025_1211.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.1 on 2020-10-25 12:11 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0016_merge_20201024_1240'), + ] + + operations = [ + migrations.AlterField( + model_name='hackproject', + name='created_by', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='hackproject', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='hackprojectscore', + name='created_by', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='hackprojectscores', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index 1c27f269..7c26b49e 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -8,10 +8,10 @@

Judging Team {{ team }}

From b6f3a237a23edca41ce8fec4d1f9e30eeef3434e Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 25 Oct 2020 14:53:13 +0000 Subject: [PATCH 10/18] Finalise page layout for scoring --- hackathon/static/hackathon/css/hackathon.css | 9 ++ hackathon/templates/hackathon/judging.html | 60 +++++--- hackathon/views.py | 146 ++++++++++--------- 3 files changed, 124 insertions(+), 91 deletions(-) create mode 100644 hackathon/static/hackathon/css/hackathon.css diff --git a/hackathon/static/hackathon/css/hackathon.css b/hackathon/static/hackathon/css/hackathon.css new file mode 100644 index 00000000..a1bb428f --- /dev/null +++ b/hackathon/static/hackathon/css/hackathon.css @@ -0,0 +1,9 @@ +.hack-score-form { + width: 100%; + margin-right: 0px; + margin-left: 0px; +} + +.hack-score-cat-name { + height: 60px; +} \ No newline at end of file diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index 7c26b49e..f02c4010 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -1,6 +1,10 @@ {% extends 'base.html' %} {% load my_tags %} +{% load static %} +{% block css %} + +{% endblock %} {% block content %}
@@ -16,29 +20,43 @@

Judging Team {{ team }}

-
- - {% for category in score_categories %} -
-
-
- -
-
-
{{ category }}
-

there is no description field of the categories, that could be used here

+
+ +
+ {% for category in score_categories %} +
+
+
+
+ +
+
+
{{ category }}
+
+
+
+
+

some description here... probably something one liner or max two

+

+ descr. field needed in ScoreCat model +

+
+
+ + +
-
- {% endfor %} + {% endfor %} +
diff --git a/hackathon/views.py b/hackathon/views.py index 013cb966..3d369123 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -20,78 +20,84 @@ class HackathonListView(ListView): def judging(request, hack_id, team_id): """Displays the judging page for the judge to save their scores for the selected project - determined by hackathon id and team id""" - - # Becomes available only after a Hackathon End Date/Time - - event = Hackathon.objects.filter(pk=hack_id) - team = HackTeam.objects.filter(pk=team_id) - - # verify whether user is judge for the event - user_is_judge = False - for judge in event.values('judges'): - if judge['judges'] == request.user.id: - print("judge there") - user_is_judge = True - if not user_is_judge: - messages.error(request, "You are not a judge for that event!") - template = 'hackathon/hackathon_list.html' - return render(request, template) - - # verify if event is ready to be judged (finished) - finish = event.values('end_date')[0]['end_date'] - now = timezone.now() - if finish > now: - messages.error(request, f"The event has not finished yet, check back after {finish}!") - template = 'hackathon/hackathon_list.html' - return render(request, template) - print("the event has finished") - - # verify that the selected team belongs to the selected event - team_belongs_to_event = False - for team in event.values('teams'): - if team['teams'] == int(team_id): - team_belongs_to_event = True - print("team is in event") - if not team_belongs_to_event: - messages.error(request, f"Nice try! That team is not part of the event...") - template = 'hackathon/hackathon_list.html' - return render(request, template) - - # check if the judge has already scored the requested team's Project - the_event = get_object_or_404(Hackathon, pk=hack_id) - team_ids_in_event = Hackathon.objects.filter(pk=hack_id).values_list('teams', flat=True) - print(f"teams_in_event = {team_ids_in_event}") - - # megse kene minden team-et a templatre kuldeni, mert nehezebb kezelni ott - - teams_in_event = [] - for team in team_ids_in_event: - teams_in_event.append(get_object_or_404(HackTeam, pk=team)) - print(f"team objects in list for the tempalte: {teams_in_event}") - - # for project in team.values('project'): - # print(f"Team Project: {project['project']}") + if request.method == 'POST': + # judge score submitted for a team + pass - # bar = HackProject.objects.filter(pk=project[0]['project']) - # print(f"the project from the HackProject model: {bar}") - - # HackProjectScoreCategories for the template: - score_categories = HackProjectScoreCategory.objects.all() - - selected_team = get_object_or_404(HackTeam, pk=team_id) - selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) - - template = 'hackathon/judging.html' - # pass all the teams and their projects to the page, so the judge can swap - context = { - 'hackathon': the_event, - 'teams': teams_in_event, #Project is part of the Team object - 'score_categories': score_categories, - 'team': selected_team, - 'project': selected_project, - - } + else: + # rendering the page for the judge to score a team + # Becomes available only after a Hackathon End Date/Time + + event = Hackathon.objects.filter(pk=hack_id) + team = HackTeam.objects.filter(pk=team_id) + + # verify whether user is judge for the event + user_is_judge = False + for judge in event.values('judges'): + if judge['judges'] == request.user.id: + print("judge there") + user_is_judge = True + if not user_is_judge: + messages.error(request, "You are not a judge for that event!") + template = 'hackathon/hackathon_list.html' + return render(request, template) + + # verify if event is ready to be judged (finished) + finish = event.values('end_date')[0]['end_date'] + now = timezone.now() + if finish > now: + messages.error(request, f"The event has not finished yet, check back after {finish}!") + template = 'hackathon/hackathon_list.html' + return render(request, template) + print("the event has finished") + + # verify that the selected team belongs to the selected event + team_belongs_to_event = False + for team in event.values('teams'): + if team['teams'] == int(team_id): + team_belongs_to_event = True + print("team is in event") + if not team_belongs_to_event: + messages.error(request, f"Nice try! That team is not part of the event...") + template = 'hackathon/hackathon_list.html' + return render(request, template) + + # check if the judge has already scored the requested team's Project + + the_event = get_object_or_404(Hackathon, pk=hack_id) + team_ids_in_event = Hackathon.objects.filter(pk=hack_id).values_list('teams', flat=True) + print(f"teams_in_event = {team_ids_in_event}") + + # megse kene minden team-et a templatre kuldeni, mert nehezebb kezelni ott + + teams_in_event = [] + for team in team_ids_in_event: + teams_in_event.append(get_object_or_404(HackTeam, pk=team)) + print(f"team objects in list for the tempalte: {teams_in_event}") + + # for project in team.values('project'): + # print(f"Team Project: {project['project']}") + + # bar = HackProject.objects.filter(pk=project[0]['project']) + # print(f"the project from the HackProject model: {bar}") + + # HackProjectScoreCategories for the template: + score_categories = HackProjectScoreCategory.objects.all() + + selected_team = get_object_or_404(HackTeam, pk=team_id) + selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) + + template = 'hackathon/judging.html' + # pass all the teams and their projects to the page, so the judge can swap + context = { + 'hackathon': the_event, + 'teams': teams_in_event, #Project is part of the Team object + 'score_categories': score_categories, + 'team': selected_team, + 'project': selected_project, + + } print(f"XXXXXXXXXXXXXXXXXXXXX CONTEXT:\n{context}") From b6666429b4f1ffd963f655fe8aecfbc7b66d9066 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 25 Oct 2020 20:36:08 +0000 Subject: [PATCH 11/18] Handle score submssion and save to model --- .../migrations/0018_auto_20201025_1933.py | 21 +++ hackathon/models.py | 4 +- hackathon/templates/hackathon/judging.html | 19 ++- hackathon/views.py | 159 ++++++++++-------- 4 files changed, 123 insertions(+), 80 deletions(-) create mode 100644 hackathon/migrations/0018_auto_20201025_1933.py diff --git a/hackathon/migrations/0018_auto_20201025_1933.py b/hackathon/migrations/0018_auto_20201025_1933.py new file mode 100644 index 00000000..bf6832da --- /dev/null +++ b/hackathon/migrations/0018_auto_20201025_1933.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.1 on 2020-10-25 19:33 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('hackathon', '0017_auto_20201025_1211'), + ] + + operations = [ + migrations.AlterField( + model_name='hackprojectscore', + name='judge', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/hackathon/models.py b/hackathon/models.py index bcbb7044..840145d5 100644 --- a/hackathon/models.py +++ b/hackathon/models.py @@ -148,8 +148,8 @@ class HackProjectScore(models.Model): created_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name="hackprojectscores") - # One Judge can give one score - One to One - judge = models.OneToOneField(User, on_delete=models.CASCADE) + # One Judge scores several scorecategories - One to Many + judge = models.ForeignKey(User, on_delete=models.CASCADE) # One score is for one project, a project has numerous scores: One to Many project = models.ForeignKey(HackProject, on_delete=models.CASCADE, diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index f02c4010..9260a172 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -22,14 +22,16 @@

Judging Team {{ team }}

-
+ + {% csrf_token %} +
{% for category in score_categories %}
- + {% for i in category.max_score|get_range:category.min_score %} @@ -56,12 +58,17 @@
{{ category }}
{% endfor %} +
+
+
+ +
+
+
- +
{% endblock %} diff --git a/hackathon/views.py b/hackathon/views.py index 3d369123..43c3f60e 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -20,84 +20,99 @@ class HackathonListView(ListView): def judging(request, hack_id, team_id): """Displays the judging page for the judge to save their scores for the selected project - determined by hackathon id and team id""" + + # HackProjectScoreCategories: + score_categories = HackProjectScoreCategory.objects.all() + + event = Hackathon.objects.filter(pk=hack_id) + team = HackTeam.objects.filter(pk=team_id) + + print(f"-----------------\n\n JUDGING START --------------------- \n\n") + + # verify whether user is judge for the event + user_is_judge = False + for judge in event.values('judges'): + if judge['judges'] == request.user.id: + print("1. user is verified to be judge for the event") + user_is_judge = True + if not user_is_judge: + messages.error(request, "You are not a judge for that event!") + template = 'hackathon/hackathon_list.html' + return render(request, template) + + # verify if event is ready to be judged (finished) + finish = event.values('end_date')[0]['end_date'] + now = timezone.now() + if finish > now: + messages.error(request, f"The event has not finished yet, check back after {finish}!") + template = 'hackathon/hackathon_list.html' + return render(request, template) + print("2. the event has finished - ready to be judged") + + # verify that the selected team belongs to the selected event + team_belongs_to_event = False + for team in event.values('teams'): + if team['teams'] == int(team_id): + team_belongs_to_event = True + print("3. team is verified to be part of the event") + if not team_belongs_to_event: + messages.error(request, f"Nice try! That team is not part of the event...") + template = 'hackathon/hackathon_list.html' + return render(request, template) + + # check if the judge has already scored the requested team's Project + the_event = get_object_or_404(Hackathon, pk=hack_id) + project = get_object_or_404(HackTeam, pk=team_id).project + judge_has_scored_this = False + print(f"4a project score {HackProjectScore.objects.filter(judge=request.user)}") + if HackProjectScore.objects.filter(judge=request.user, project=project): + messages.error(request, f"Oooops, sorry! Something went wrong, you have already scored that team...") + template = 'hackathon/hackathon_list.html' + return render(request, template) + print("4. Judge has not scored this project verified!") + + + # team_ids_in_event = Hackathon.objects.filter(pk=hack_id).values_list('teams', flat=True) + # print(f"teams_in_event = {team_ids_in_event}") + if request.method == 'POST': # judge score submitted for a team - pass + print(f"##############################\n POST \n") + for score_category in score_categories: + created_by = request.user + judge = request.user + project = get_object_or_404(HackTeam, pk=team_id).project + score_cat_id = f"score_{score_category.id}" + score = request.POST.get(score_cat_id) + hack_project_score_category = score_category + team_score = HackProjectScore( + created_by = request.user, + judge = request.user, + project = get_object_or_404(HackTeam, pk=team_id).project, + score = request.POST.get(score_cat_id), + hack_project_score_category = score_category, + ) + team_score.save() + + return redirect("hackathon:hackathon-list") - else: + # else: # rendering the page for the judge to score a team - # Becomes available only after a Hackathon End Date/Time - - event = Hackathon.objects.filter(pk=hack_id) - team = HackTeam.objects.filter(pk=team_id) - - # verify whether user is judge for the event - user_is_judge = False - for judge in event.values('judges'): - if judge['judges'] == request.user.id: - print("judge there") - user_is_judge = True - if not user_is_judge: - messages.error(request, "You are not a judge for that event!") - template = 'hackathon/hackathon_list.html' - return render(request, template) - - # verify if event is ready to be judged (finished) - finish = event.values('end_date')[0]['end_date'] - now = timezone.now() - if finish > now: - messages.error(request, f"The event has not finished yet, check back after {finish}!") - template = 'hackathon/hackathon_list.html' - return render(request, template) - print("the event has finished") - - # verify that the selected team belongs to the selected event - team_belongs_to_event = False - for team in event.values('teams'): - if team['teams'] == int(team_id): - team_belongs_to_event = True - print("team is in event") - if not team_belongs_to_event: - messages.error(request, f"Nice try! That team is not part of the event...") - template = 'hackathon/hackathon_list.html' - return render(request, template) - - # check if the judge has already scored the requested team's Project - the_event = get_object_or_404(Hackathon, pk=hack_id) - team_ids_in_event = Hackathon.objects.filter(pk=hack_id).values_list('teams', flat=True) - print(f"teams_in_event = {team_ids_in_event}") - - # megse kene minden team-et a templatre kuldeni, mert nehezebb kezelni ott - - teams_in_event = [] - for team in team_ids_in_event: - teams_in_event.append(get_object_or_404(HackTeam, pk=team)) - print(f"team objects in list for the tempalte: {teams_in_event}") - - # for project in team.values('project'): - # print(f"Team Project: {project['project']}") - - # bar = HackProject.objects.filter(pk=project[0]['project']) - # print(f"the project from the HackProject model: {bar}") - - # HackProjectScoreCategories for the template: - score_categories = HackProjectScoreCategory.objects.all() - - selected_team = get_object_or_404(HackTeam, pk=team_id) - selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) - - template = 'hackathon/judging.html' - # pass all the teams and their projects to the page, so the judge can swap - context = { - 'hackathon': the_event, - 'teams': teams_in_event, #Project is part of the Team object - 'score_categories': score_categories, - 'team': selected_team, - 'project': selected_project, - - } + selected_team = get_object_or_404(HackTeam, pk=team_id) + selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) + + template = 'hackathon/judging.html' + # to be decided whether to pass all the teams and their projects to the page, + # so the judge can swap without rerendering the page + context = { + 'hackathon': the_event, + 'score_categories': score_categories, + 'team': selected_team, + 'project': selected_project, + + } print(f"XXXXXXXXXXXXXXXXXXXXX CONTEXT:\n{context}") From 972e7187fb939d93b70bc4e78700baf4cee2d541 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Sun, 25 Oct 2020 22:15:34 +0000 Subject: [PATCH 12/18] Refactor code and finalise for PR --- hackathon/static/hackathon/css/hackathon.css | 13 +++++++- hackathon/templates/hackathon/judging.html | 18 +++++----- hackathon/views.py | 35 +++----------------- 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/hackathon/static/hackathon/css/hackathon.css b/hackathon/static/hackathon/css/hackathon.css index a1bb428f..437507d1 100644 --- a/hackathon/static/hackathon/css/hackathon.css +++ b/hackathon/static/hackathon/css/hackathon.css @@ -5,5 +5,16 @@ } .hack-score-cat-name { - height: 60px; + min-height: 60px; + margin-bottom: 0; +} + +@media screen and (max-width: 720px) { + .hack-score-cat-name { + min-height: 30px; + } + /* .hack-score-cat-name, h5 { + font-size: 1rem; + } */ + } \ No newline at end of file diff --git a/hackathon/templates/hackathon/judging.html b/hackathon/templates/hackathon/judging.html index 9260a172..c3bb62c8 100644 --- a/hackathon/templates/hackathon/judging.html +++ b/hackathon/templates/hackathon/judging.html @@ -9,13 +9,13 @@ {% block content %}
-

Judging Team {{ team }}

-
@@ -26,10 +26,10 @@

Judging Team {{ team }}

{% csrf_token %}
{% for category in score_categories %} -
+
-
+
-
+
{{ category }}
-
+

some description here... probably something one liner or max two

- descr. field needed in ScoreCat model + descr. field needed in ScoreCat model

diff --git a/hackathon/views.py b/hackathon/views.py index 43c3f60e..0a6f9904 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -27,17 +27,14 @@ def judging(request, hack_id, team_id): event = Hackathon.objects.filter(pk=hack_id) team = HackTeam.objects.filter(pk=team_id) - print(f"-----------------\n\n JUDGING START --------------------- \n\n") - # verify whether user is judge for the event user_is_judge = False for judge in event.values('judges'): if judge['judges'] == request.user.id: - print("1. user is verified to be judge for the event") user_is_judge = True if not user_is_judge: messages.error(request, "You are not a judge for that event!") - template = 'hackathon/hackathon_list.html' + template = 'home/index.html' return render(request, template) # verify if event is ready to be judged (finished) @@ -45,47 +42,32 @@ def judging(request, hack_id, team_id): now = timezone.now() if finish > now: messages.error(request, f"The event has not finished yet, check back after {finish}!") - template = 'hackathon/hackathon_list.html' + template = 'home/index.html' return render(request, template) - print("2. the event has finished - ready to be judged") # verify that the selected team belongs to the selected event team_belongs_to_event = False for team in event.values('teams'): if team['teams'] == int(team_id): team_belongs_to_event = True - print("3. team is verified to be part of the event") if not team_belongs_to_event: messages.error(request, f"Nice try! That team is not part of the event...") - template = 'hackathon/hackathon_list.html' + template = 'home/index.html' return render(request, template) # check if the judge has already scored the requested team's Project the_event = get_object_or_404(Hackathon, pk=hack_id) project = get_object_or_404(HackTeam, pk=team_id).project judge_has_scored_this = False - print(f"4a project score {HackProjectScore.objects.filter(judge=request.user)}") if HackProjectScore.objects.filter(judge=request.user, project=project): messages.error(request, f"Oooops, sorry! Something went wrong, you have already scored that team...") - template = 'hackathon/hackathon_list.html' + template = 'home/index.html' return render(request, template) - print("4. Judge has not scored this project verified!") - - - # team_ids_in_event = Hackathon.objects.filter(pk=hack_id).values_list('teams', flat=True) - # print(f"teams_in_event = {team_ids_in_event}") - if request.method == 'POST': # judge score submitted for a team - print(f"##############################\n POST \n") for score_category in score_categories: - created_by = request.user - judge = request.user - project = get_object_or_404(HackTeam, pk=team_id).project score_cat_id = f"score_{score_category.id}" - score = request.POST.get(score_cat_id) - hack_project_score_category = score_category team_score = HackProjectScore( created_by = request.user, judge = request.user, @@ -97,25 +79,16 @@ def judging(request, hack_id, team_id): return redirect("hackathon:hackathon-list") - # else: - # rendering the page for the judge to score a team - selected_team = get_object_or_404(HackTeam, pk=team_id) selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) template = 'hackathon/judging.html' - # to be decided whether to pass all the teams and their projects to the page, - # so the judge can swap without rerendering the page context = { 'hackathon': the_event, 'score_categories': score_categories, 'team': selected_team, 'project': selected_project, - } - - print(f"XXXXXXXXXXXXXXXXXXXXX CONTEXT:\n{context}") - return render(request, template, context) From e86250b41e12c86c7c1fdf48164123aaff9d25da Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Mon, 26 Oct 2020 20:50:50 +0000 Subject: [PATCH 13/18] Pull changes from upstream and update --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0b3983f9..4e24bc0b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ env.py settings.json .gitpod.yml venv/ -.idea/ \ No newline at end of file +.idea/ +MYNOTES.md \ No newline at end of file From 005fa9b1bdcca4641064b9756b1f20808fb6c54f Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Wed, 28 Oct 2020 11:41:51 +0000 Subject: [PATCH 14/18] Fix PR change requests, migrations not made... --- hackathon/lists.py | 6 ++++ hackathon/models.py | 9 +++++- hackathon/views.py | 67 ++++++++++++++++++++------------------------- 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/hackathon/lists.py b/hackathon/lists.py index db1a7bb6..bfafa2b3 100644 --- a/hackathon/lists.py +++ b/hackathon/lists.py @@ -7,3 +7,9 @@ ('published', 'Published'), ('deleted', 'Deleted'), ) + +JUDGING_STATUS_CHOICES = ( + ('not_yet_started', "Hasn't started"), + ('open', "Open"), + ('closed', "Closed"), +) \ No newline at end of file diff --git a/hackathon/models.py b/hackathon/models.py index 7a34b97c..42b0d77f 100644 --- a/hackathon/models.py +++ b/hackathon/models.py @@ -3,7 +3,7 @@ from accounts.models import CustomUser as User from accounts.models import Organisation -from .lists import STATUS_TYPES_CHOICES +from .lists import STATUS_TYPES_CHOICES, JUDGING_STATUS_CHOICES # Optional fields are ony set to deal with object deletion issues. # If this isn't a problem, they can all be changed to required fields. @@ -55,6 +55,13 @@ class Hackathon(models.Model): default='draft', choices=STATUS_TYPES_CHOICES ) + judging_status = models.CharField( + max_length=16, + blank=False, + default='not_yet_started', + choices=JUDGING_STATUS_CHOICES + ) + def __str__(self): return self.display_name diff --git a/hackathon/views.py b/hackathon/views.py index c53e28e5..be78face 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -36,46 +36,40 @@ def judging(request, hack_id, team_id): # HackProjectScoreCategories: score_categories = HackProjectScoreCategory.objects.all() + + hackathon = get_object_or_404(Hackathon, pk=hack_id) + team = get_object_or_404(HackTeam, pk=team_id) - event = Hackathon.objects.filter(pk=hack_id) - team = HackTeam.objects.filter(pk=team_id) - - # verify whether user is judge for the event - user_is_judge = False - for judge in event.values('judges'): - if judge['judges'] == request.user.id: - user_is_judge = True - if not user_is_judge: + # verify whether user is judge for the hackathon + if hackathon not in Hackathon.objects.filter(judges=request.user): messages.error(request, "You are not a judge for that event!") - template = 'home/index.html' - return render(request, template) - - # verify if event is ready to be judged (finished) - finish = event.values('end_date')[0]['end_date'] - now = timezone.now() - if finish > now: - messages.error(request, f"The event has not finished yet, check back after {finish}!") - template = 'home/index.html' - return render(request, template) - - # verify that the selected team belongs to the selected event - team_belongs_to_event = False - for team in event.values('teams'): - if team['teams'] == int(team_id): - team_belongs_to_event = True - if not team_belongs_to_event: + return render(request, 'home/index.html') + + # verify if hackathon is ready to be judged (judging_status == 'open') + if hackathon.judging_status != 'open': + messages.error(request, f"Judging is not open! {hackathon.judging_status}!") + return render(request, 'home/index.html') + + # finish = hackathon.values('end_date')[0]['end_date'] + # now = timezone.now() + # if finish > now: + # messages.error(request, f"The event has not finished yet, check back after {finish}!") + # return render(request, 'home/index.html') + + # verify that the selected team belongs to the selected hackathon + if team.hackathon != hackathon: messages.error(request, f"Nice try! That team is not part of the event...") - template = 'home/index.html' - return render(request, template) + return render(request, 'home/index.html') # check if the judge has already scored the requested team's Project - the_event = get_object_or_404(Hackathon, pk=hack_id) project = get_object_or_404(HackTeam, pk=team_id).project + if not project: + messages.error(request, f"The team doesn't have a project yet, check back later...") + return render(request, 'home/index.html') judge_has_scored_this = False if HackProjectScore.objects.filter(judge=request.user, project=project): messages.error(request, f"Oooops, sorry! Something went wrong, you have already scored that team...") - template = 'home/index.html' - return render(request, template) + return render(request, 'home/index.html') if request.method == 'POST': # judge score submitted for a team @@ -93,16 +87,15 @@ def judging(request, hack_id, team_id): return redirect("hackathon:hackathon-list") selected_team = get_object_or_404(HackTeam, pk=team_id) - selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) + # selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) - template = 'hackathon/judging.html' context = { - 'hackathon': the_event, + 'hackathon': hackathon, 'score_categories': score_categories, - 'team': selected_team, - 'project': selected_project, + 'team': team, + 'project': project, } - return render(request, template, context) + return render(request, 'hackathon/judging.html', context) def create_hackathon(request): From 2b31055efb14ca3b88cb1ee1f1824ddae1cc0bd3 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Wed, 28 Oct 2020 12:43:39 +0000 Subject: [PATCH 15/18] Delete commented out code --- hackathon/views.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hackathon/views.py b/hackathon/views.py index be78face..e4c0344e 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -50,12 +50,6 @@ def judging(request, hack_id, team_id): messages.error(request, f"Judging is not open! {hackathon.judging_status}!") return render(request, 'home/index.html') - # finish = hackathon.values('end_date')[0]['end_date'] - # now = timezone.now() - # if finish > now: - # messages.error(request, f"The event has not finished yet, check back after {finish}!") - # return render(request, 'home/index.html') - # verify that the selected team belongs to the selected hackathon if team.hackathon != hackathon: messages.error(request, f"Nice try! That team is not part of the event...") From 0b8fc804d3a33f453b9bac32cf0da13c7afc4d9a Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Wed, 28 Oct 2020 17:14:11 +0000 Subject: [PATCH 16/18] Solve the remaining two minor change requests for PR --- hackathon/urls.py | 5 ++--- hackathon/views.py | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hackathon/urls.py b/hackathon/urls.py index 56207b87..3e2e8890 100644 --- a/hackathon/urls.py +++ b/hackathon/urls.py @@ -1,10 +1,9 @@ from django.urls import path -from . import views -from .views import HackathonListView, create_hackathon, delete_hackathon +from .views import HackathonListView, create_hackathon, delete_hackathon, judging urlpatterns = [ path('', HackathonListView.as_view(), name="hackathon-list"), - path("/team//judging/", views.judging, name="judging"), + path("/team//judging/", judging, name="judging"), path("create_hackathon", create_hackathon, name='create_hackathon'), path("/delete_hackathon", delete_hackathon, name="delete_hackathon"), ] diff --git a/hackathon/views.py b/hackathon/views.py index e4c0344e..ef5947c9 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -80,9 +80,6 @@ def judging(request, hack_id, team_id): return redirect("hackathon:hackathon-list") - selected_team = get_object_or_404(HackTeam, pk=team_id) - # selected_project = get_object_or_404(HackProject, pk=selected_team.project.id) - context = { 'hackathon': hackathon, 'score_categories': score_categories, From c4a3ccfa2fb9bb180e4bd53657e447f1c37562a6 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Thu, 29 Oct 2020 17:50:19 +0000 Subject: [PATCH 17/18] Remove the admin from profiles.json and add accounts back to seed --- accounts/fixtures/profiles.json | 22 ---------------------- scripts/seed.sh | 1 + 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/accounts/fixtures/profiles.json b/accounts/fixtures/profiles.json index 94794ea4..a489e3e6 100644 --- a/accounts/fixtures/profiles.json +++ b/accounts/fixtures/profiles.json @@ -1,26 +1,4 @@ [ - { - "model": "accounts.customuser", - "pk": 1, - "fields": { - "password": "pbkdf2_sha256$216000$YaMMEj4FjnL4$YB1N7EJ4SdoaIeV8Fg/pIMj/gtBlVvwNBF3fAS5cPXE=", - "last_login": null, - "is_superuser": true, - "username": "admin", - "first_name": "", - "last_name": "", - "email": "admin@example.com", - "is_staff": true, - "is_active": true, - "date_joined": "2020-10-26T16:54:30.184Z", - "slack_display_name": "", - "user_type": "", - "current_lms_module": "", - "organisation": 1, - "groups": [], - "user_permissions": [] - } - }, { "model":"accounts.customuser", "pk":2, diff --git a/scripts/seed.sh b/scripts/seed.sh index 2f3b0fe4..ad36a4a2 100755 --- a/scripts/seed.sh +++ b/scripts/seed.sh @@ -2,6 +2,7 @@ echo "============================" echo "Seeding fixtures" echo "============================" python3 manage.py loaddata organisation +python3 manage.py loaddata accounts python3 manage.py loaddata resources python3 manage.py loaddata profiles python3 manage.py loaddata hackathons \ No newline at end of file From 98206df04da2992b67b05be41a4e1ee6c37377f3 Mon Sep 17 00:00:00 2001 From: Miklos Sarosi Date: Thu, 29 Oct 2020 17:55:31 +0000 Subject: [PATCH 18/18] Add blank line between 3rd party and local modules --- hackathon/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hackathon/views.py b/hackathon/views.py index 2a49f357..be28774f 100644 --- a/hackathon/views.py +++ b/hackathon/views.py @@ -4,6 +4,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from django.utils import timezone + from .models import Hackathon, HackTeam, HackProject, HackProjectScore, HackProjectScoreCategory from .forms import HackathonForm