Skip to content

Commit

Permalink
Add links to the solution upload page
Browse files Browse the repository at this point in the history
  • Loading branch information
krzys-h committed Feb 23, 2021
1 parent 0105302 commit 56cc9d0
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 26 deletions.
4 changes: 2 additions & 2 deletions frontend/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'bootstrap/dist/js/bootstrap.js';
// Font Awesome
// Explicitly specify the used icons to make the bundle size smaller
import { library, dom } from "@fortawesome/fontawesome-svg-core";
import { faCheckCircle, faTimesCircle, faMinusCircle, faExclamationCircle, faQuestionCircle, faPlus, faMinus, faCheck, faHome, faFile, faPencilAlt, faSignOutAlt, faEye, faEyeSlash, faColumns, faCopy, faFileExcel, faFilePdf, faPrint, faSave, faCloudUploadAlt } from "@fortawesome/free-solid-svg-icons";
library.add(faCheckCircle, faTimesCircle, faMinusCircle, faExclamationCircle, faQuestionCircle, faPlus, faMinus, faCheck, faHome, faFile, faPencilAlt, faSignOutAlt, faEye, faEyeSlash, faColumns, faCopy, faFileExcel, faFilePdf, faPrint, faSave, faCloudUploadAlt);
import { faCheckCircle, faTimesCircle, faMinusCircle, faExclamationCircle, faQuestionCircle, faPlus, faMinus, faCheck, faHome, faFile, faPencilAlt, faSignOutAlt, faEye, faEyeSlash, faColumns, faCopy, faFileExcel, faFilePdf, faPrint, faSave, faCloudUploadAlt, faPaperPlane } from "@fortawesome/free-solid-svg-icons";
library.add(faCheckCircle, faTimesCircle, faMinusCircle, faExclamationCircle, faQuestionCircle, faPlus, faMinus, faCheck, faHome, faFile, faPencilAlt, faSignOutAlt, faEye, faEyeSlash, faColumns, faCopy, faFileExcel, faFilePdf, faPrint, faSave, faCloudUploadAlt, faPaperPlane);
dom.watch();


Expand Down
62 changes: 40 additions & 22 deletions templates/_qualificationsTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,29 @@
{{ workshop_participant.workshop.title }}
</a>
</th>
<td>
{% if workshop_participant.workshop.is_qualifying %}
{% if not workshop_participant.solution and workshop_participant.workshop.are_solutions_editable and workshop_participant.workshop.solution_uploads_enabled and workshop_participant.workshop.is_qualifying and workshop_participant.workshop.qualification_problems %}
<td colspan="2">
<a role="button" class="btn btn-primary btn-sm" href="{% url 'workshop_my_solution' workshop_participant.workshop.year.pk workshop_participant.workshop.name %}"><i class="fas fa-paper-plane"></i> Prześlij rozwiązania!</a>
</td>
{% elif workshop_participant.workshop.is_qualifying and not workshop_participant.workshop.qualification_problems %}
<td colspan="2">
<span class="text-warning"><i class="fas fa-exclamation-circle"></i> Poczekaj na opublikowanie zadań</span>
</td>
{% elif workshop_participant.workshop.is_qualifying %}
<td>
{{ workshop_participant.qualification_result | default_if_none:'?' }} / {{ workshop_participant.workshop.max_points | default_if_none:'?' }}
{% else %}
-
{% endif %}
</td>
<td>
{% if workshop_participant.workshop.is_qualifying %}
</td>
<td>
{{ workshop_participant.is_qualified | qualified_mark }}
{% else %}
</td>
{% else %}
<td>
-
{% endif %}
</td>
</td>
<td>
-
</td>
{% endif %}
</tr>
{% if workshop_participant.workshop.is_qualifying and workshop_participant.comment %}
<tr>
Expand Down Expand Up @@ -58,20 +67,29 @@
{{ workshop_participant.workshop.title }}
</a>
</th>
<td>
{% if workshop_participant.workshop.is_qualifying %}
{% if not workshop_participant.solution and workshop_participant.workshop.are_solutions_editable and workshop_participant.workshop.solution_uploads_enabled and workshop_participant.workshop.is_qualifying and workshop_participant.workshop.qualification_problems %}
<td colspan="2">
<a role="button" class="btn btn-primary btn-sm" href="{% url 'workshop_my_solution' workshop_participant.workshop.year.pk workshop_participant.workshop.name %}"><i class="fas fa-paper-plane"></i> Prześlij rozwiązania!</a>
</td>
{% elif workshop_participant.workshop.is_qualifying and not workshop_participant.workshop.qualification_problems %}
<td colspan="2">
<span class="text-warning"><i class="fas fa-exclamation-circle"></i> Poczekaj na opublikowanie zadań</span>
</td>
{% elif workshop_participant.workshop.is_qualifying %}
<td>
{{ workshop_participant.qualification_result | default_if_none:'?' }} / {{ workshop_participant.workshop.max_points | default_if_none:'?' }}
{% else %}
-
{% endif %}
</td>
<td>
{% if workshop_participant.workshop.is_qualifying %}
</td>
<td>
{{ workshop_participant.is_qualified | qualified_mark }}
{% else %}
</td>
{% else %}
<td>
-
{% endif %}
</td>
</td>
<td>
-
</td>
{% endif %}
<td>
{% if workshop_participant.workshop.is_qualifying and workshop_participant.comment %}
{{ workshop_participant.comment }}
Expand Down
15 changes: 14 additions & 1 deletion templates/program.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,20 @@ <h5 class="m-0">
<div class="col-6 col-lg-4">Zadania kwalifikacyjne:</div>
<div class="col-6 col-lg-8">
{% if workshop.is_qualifying and workshop.qualification_problems %}
<a href="{% url 'qualification_problems' workshop.year.pk workshop.name %}"> Link </a>
<a href="{% url 'qualification_problems' workshop.year.pk workshop.name %}" class="mr-3"> Link </a>

{% if workshop.are_solutions_editable and workshop.solution_uploads_enabled %}
<span class="d-inline-block enable-tooltip"
{# this wrapper div is here to allow the tooltip to work on a disabled element, see https://getbootstrap.com/docs/4.0/components/tooltips/#disabled-elements #}
{% if not registered %}data-toggle="tooltip" data-placement="right" title="Przed przesłaniem rozwiązań, zapisz się na warsztaty"{% endif %}
>
<a role="button"
class="btn btn-primary btn-sm {% if not registered %}disabled{% endif %}"
href="{% url 'workshop_my_solution' workshop.year.pk workshop.name %}">
<i class="fas fa-paper-plane"></i> Prześlij rozwiązania!
</a>
</span>
{% endif %}
{% elif workshop.is_qualifying %}
Pojawią się wkrótce.
{% else %}
Expand Down
20 changes: 20 additions & 0 deletions templates/workshoppage.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@
{% endif %}
{% endif %}

{% if workshop.are_solutions_editable and workshop.solution_uploads_enabled and workshop.is_qualifying and workshop.qualification_problems %}
<span class="d-inline-block enable-tooltip"
{# this wrapper div is here to allow the tooltip to work on a disabled element, see https://getbootstrap.com/docs/4.0/components/tooltips/#disabled-elements #}
{% if not registered %}data-toggle="tooltip" data-placement="right" title="Przed przesłaniem rozwiązań, zapisz się na warsztaty"{% endif %}
>
<a role="button"
class="btn btn-primary btn-sm {% if not registered %}disabled{% endif %}"
href="{% url 'workshop_my_solution' workshop.year.pk workshop.name %}">
<i class="fas fa-paper-plane"></i> Prześlij rozwiązania!
</a>
</span>
{% endif %}

{% if workshop.page_content_is_public %}
<div role="tabpanel" style="margin: 1em 0;">
{{ workshop.page_content | bleach }}
Expand All @@ -33,4 +46,11 @@
{% else %}
<div class="alert alert-info" role="alert">Prowadzący warsztatów nie wstawił jeszcze opisu.</div>
{% endif %}
{% endblock %}

{% block script %}
{{ block.super }}
<script>
$('.enable-tooltip').tooltip();
</script>
{% endblock %}
3 changes: 3 additions & 0 deletions wwwapp/tests/test_workshop_qualification.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import datetime
import os

import mock
from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test.testcases import TestCase
from django.urls import reverse
from freezegun import freeze_time
Expand Down Expand Up @@ -40,6 +42,7 @@ def setUp(self):
proposition_description='<p>Testowy opis</p>',
status=Workshop.STATUS_ACCEPTED,
solution_uploads_enabled=False,
qualification_problems=SimpleUploadedFile('problems.pdf', os.urandom(1024 * 1024)),
qualification_threshold=5,
max_points=10,
)
Expand Down
8 changes: 7 additions & 1 deletion wwwapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def mydata_status_view(request):
for p in participation_data:
p['qualification_results'] = []

qualifications = WorkshopParticipant.objects.filter(participant=user_profile).prefetch_related('workshop', 'workshop__year').all()
qualifications = WorkshopParticipant.objects.filter(participant=user_profile).select_related('workshop', 'workshop__year', 'solution').all()
for q in qualifications:
participation_for_year = next(filter(lambda x: x['year'] == q.workshop.year, participation_data), None)
if participation_for_year is None:
Expand Down Expand Up @@ -290,9 +290,15 @@ def workshop_page_view(request, year, name):
if not workshop.is_publicly_visible(): # Accepted or cancelled
return HttpResponseForbidden("Warsztaty nie zostały zaakceptowane")

if request.user.is_authenticated:
registered = workshop.participants.filter(user=request.user).exists()
else:
registered = False

context = {}
context['title'] = workshop.title
context['workshop'] = workshop
context['registered'] = registered
context['is_lecturer'] = is_lecturer
context['has_perm_to_edit'] = has_perm_to_edit
context['has_perm_to_view_details'] = \
Expand Down

0 comments on commit 56cc9d0

Please sign in to comment.