Skip to content

Commit 973dc24

Browse files
#M14. Misc cleanup changes and improvements (#132)
1 parent bf30d67 commit 973dc24

5 files changed

Lines changed: 52 additions & 53 deletions

File tree

hackathon/static/hackathon/css/hackathon.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.hack-score-form {
22
width: 100%;
3-
margin-right: 0px;
4-
margin-left: 0px;
3+
margin: 0 auto;
4+
max-width: none;
55
}
66

77
.hack-score-cat-name {

hackathon/templates/hackathon/hackathon_view.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,20 @@
1515

1616
<div class="row">
1717
<div class="col p-0">
18-
{% if user.is_superuser %}
18+
{% if user.is_staff %}
1919
<div class="dropdown mt-4 mb-2 ">
2020
<button class="btn btn-ci dropdown-toggle form-control" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
2121
Admin Actions
2222
</button>
2323
<div id="judge-dropdown" class="dropdown-menu judge-dropdown" aria-labelledby="dropdownMenuButton">
24+
2425
{% include 'hackathon/includes/enrollstaff.html' %}
26+
{% if user.is_superuser %}
2527
<a class="dropdown-item" href="change_teams">
2628
{% if hackathon.teams.all|length == 0 %}Distribute{% else %}Change{% endif %} Teams
2729
</a>
2830
<a role="button" class="dropdown-item" id="change-hack-status" data-toggle="modal" data-target="#changeStatusModal">Change Hackathon Status</a>
29-
<a class="dropdown-item" href="#">Judge Teams</a>
31+
{% endif %}
3032
</div>
3133
</div>
3234
{% else %}
@@ -87,8 +89,14 @@ <h3 class="team-name">
8789
<!-- Render project submission button if user is participant of team -->
8890
{% if user in team.participants.get_queryset %}
8991
<div class="text-left">
90-
<a href="#" class="btn btn-ci">Submit Project</a>
92+
<a href="/teams/{{team.id}}/project/" class="btn btn-ci">Edit Project</a>
93+
</div>
94+
{% elif user in hackathon.judges.all %}
95+
{% if hackathon.status == 'hack_in_progress' or hackathon.status == 'judging' %}
96+
<div class="text-left">
97+
<a href="/hackathon/{{hackathon.id}}/team/{{team.id}}/judging/" class="btn btn-ci">Edit Scores</a>
9198
</div>
99+
{% endif %}
92100
{% endif %}
93101
</div>
94102
</div>

hackathon/templates/hackathon/judging.html

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<section>
1212
<h2>Judging Team {{ team }}</h2>
1313
<div class="d-flex flex-wrap justify-content-around my-2 my-md-4">
14+
<div>
15+
<a href="/teams/{{team.id}}/" class="btn btn-outline-info mb-3 mb-md-0" target="_blank">View Team Page</a>
16+
</div>
1417
<div>
1518
<a href="{{ project.github_url }}" class="btn btn-outline-info mb-3 mb-md-0" target="_blank">View Project Repo</a>
1619
</div>
@@ -20,55 +23,43 @@ <h2>Judging Team {{ team }}</h2>
2023
</div>
2124
</section>
2225

23-
<section class="container">
24-
<!-- judging form -->
25-
<form class="hack-score-form tex-center" action="{% url 'hackathon:judging' hackathon.id team.id %}" method="post">
26-
{% csrf_token %}
27-
<div class=" row justify-content-around" >
26+
<section class="container-fluid">
27+
<form class="hack-score-form text-center" action="{% url 'hackathon:judging' hackathon.id team.id %}" method="post">
28+
<div class="row justify-content-around">
2829
{% for category in score_categories %}
29-
<div class="col-12 col-md-6 mb-3 mb-md-4 p-0 p-md-2">
30-
<div class="shadow p-3 bg-white rounded mx-3">
31-
<div class="row">
32-
<div class="col-32 order-12 col-md-3 order-md-1 mt-2 input-group">
33-
<select required class="custom-select" name="score_{{ category.id }}">
34-
<option selected disabled value="">Score</option>
35-
<!-- using custom get_range tag -->
36-
{% for i in category.max_score|get_range:category.min_score %}
37-
38-
<option value="{{ i }}">{{ i }}</option>
39-
{% endfor %}
40-
41-
</select>
42-
</div>
43-
<div class="col-12 order-1 col-md-9 order-md-12 text-left">
44-
<h5 class="hack-score-cat-name"><strong>{{ category }}</strong></h5>
45-
</div>
30+
<div class="col-12 col-md-4 mb-3 mb-md-4 p-0 p-md-2">
31+
32+
<div class="card">
33+
<div class="card-body">
34+
<div class="card-title">
35+
<h5 class="hack-score-cat-name"><strong>{{ category }}</strong></h5>
4636
</div>
47-
<div class="row">
48-
<div class="col-12 my-2 text-left">
49-
<p class="mb-0">some description here... probably something one liner or max two</p>
50-
<p class="mb-0">
51-
<em><small> descr. field needed in ScoreCat model</small></em>
37+
<div class="card-text">
38+
39+
<select required class="custom-select" name="score_{{ category.id }}">
40+
<option selected disabled value="">Score</option>
41+
<!-- using custom get_range tag -->
42+
{% for i in category.max_score|get_range:category.min_score %}
43+
<option value="{{ i }}">{{ i }}</option>
44+
{% endfor %}
45+
</select>
46+
<p>
47+
5248
</p>
5349
</div>
54-
</div>
55-
56-
57-
5850
</div>
5951
</div>
60-
{% endfor %}
52+
6153
</div>
62-
<div class="row d-flex justify-content-center">
63-
<div class="mt-1 mb-5">
64-
<button class="btn-lg btn-ci mt-1" type="submit" value="Submit">Submit scores</button>
65-
</div>
54+
{% endfor %}
55+
</div>
56+
<div class="row d-flex justify-content-center">
57+
<div class="mt-1 mb-5">
58+
<button class="btn-lg btn-ci mt-1" type="submit" value="Submit">Submit scores</button>
6659
</div>
67-
60+
</div>
6861
</form>
69-
7062
</section>
7163

72-
7364
</div>
7465
{% endblock %}

hackathon/views.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,31 @@ def judging(request, hack_id, team_id):
4848
# verify whether user is judge for the hackathon
4949
if hackathon not in Hackathon.objects.filter(judges=request.user):
5050
messages.error(request, "You are not a judge for that event!")
51-
return render(request, 'home/index.html')
51+
return redirect(reverse('home'))
5252

53-
# verify if hackathon is ready to be judged (judging_status == 'open')
54-
if hackathon.judging_status != 'open':
53+
# verify if hackathon is ready to be judged
54+
if hackathon.status not in ['hack_in_progress', 'judging']:
5555
messages.error(
56-
request, f"Judging is not open! {hackathon.judging_status}!")
57-
return render(request, 'home/index.html')
56+
request, f"Judging is not open! {hackathon.status}!")
57+
return redirect(reverse('home'))
5858

5959
# verify that the selected team belongs to the selected hackathon
6060
if team.hackathon != hackathon:
6161
messages.error(
6262
request, f"Nice try! That team is not part of the event...")
63-
return render(request, 'home/index.html')
63+
return redirect(reverse('home'))
6464

6565
# check if the judge has already scored the requested team's Project
6666
project = get_object_or_404(HackTeam, pk=team_id).project
6767
if not project:
6868
messages.error(
6969
request, f"The team doesn't have a project yet, check back later...")
70-
return render(request, 'home/index.html')
70+
return redirect(reverse('home'))
7171
judge_has_scored_this = False
7272
if HackProjectScore.objects.filter(judge=request.user, project=project):
7373
messages.error(
7474
request, f"Oooops, sorry! Something went wrong, you have already scored that team...")
75-
return render(request, 'home/index.html')
75+
return redirect(reverse('home'))
7676

7777
if request.method == 'POST':
7878
# judge score submitted for a team

profiles/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def profile(request, user_id=None):
2222
or request.user.is_staff):
2323
context['user'] = user
2424
else:
25-
return
25+
context['user'] = None
2626
context['is_owner'] = False
2727

2828
template = "profiles/profile.html"

0 commit comments

Comments
 (0)