feat: export ratings
This commit is contained in:
parent
3091fb0783
commit
57317b51d2
|
@ -1 +1 @@
|
||||||
__version__ = "0.8.0"
|
__version__ = "0.9.0"
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: pretalx-musicrate 0.0.1\n"
|
"Project-Id-Version: pretalx-musicrate 0.9.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2023-12-16 03:23+0100\n"
|
"POT-Creation-Date: 2023-12-18 01:34+0100\n"
|
||||||
"PO-Revision-Date: 2023-12-16 03:24+0100\n"
|
"PO-Revision-Date: 2023-12-18 01:36+0100\n"
|
||||||
"Last-Translator: Luca <Luca@hackerspace-bamberg.de>\n"
|
"Last-Translator: Luca <Luca@hackerspace-bamberg.de>\n"
|
||||||
"Language-Team: Luca <Luca@hackerspace-bamberg.de>\n"
|
"Language-Team: Luca <Luca@hackerspace-bamberg.de>\n"
|
||||||
"Language: de_DE\n"
|
"Language: de_DE\n"
|
||||||
|
@ -93,6 +93,14 @@ msgstr "Zum Anhörtag"
|
||||||
msgid "pretalx-musicrate settings"
|
msgid "pretalx-musicrate settings"
|
||||||
msgstr "pretalx-musicrate-Einstellungen"
|
msgstr "pretalx-musicrate-Einstellungen"
|
||||||
|
|
||||||
|
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:22
|
||||||
|
msgid "Save"
|
||||||
|
msgstr "Speichern"
|
||||||
|
|
||||||
|
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:30
|
||||||
|
msgid "Export ratings"
|
||||||
|
msgstr "Bewertungen exportieren"
|
||||||
|
|
||||||
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:29
|
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:29
|
||||||
msgid "(not specified)"
|
msgid "(not specified)"
|
||||||
msgstr "(nicht angegeben)"
|
msgstr "(nicht angegeben)"
|
||||||
|
@ -105,19 +113,19 @@ msgstr "Zurück"
|
||||||
msgid "Next"
|
msgid "Next"
|
||||||
msgstr "Weiter"
|
msgstr "Weiter"
|
||||||
|
|
||||||
#: pretalx_musicrate/views.py:39
|
#: pretalx_musicrate/views.py:41
|
||||||
msgid "Invalid token"
|
msgid "Invalid token"
|
||||||
msgstr "Ungültiges Token"
|
msgstr "Ungültiges Token"
|
||||||
|
|
||||||
#: pretalx_musicrate/views.py:114
|
#: pretalx_musicrate/views.py:116
|
||||||
msgid "The pretalx-musicrate settings were updated."
|
msgid "The pretalx-musicrate settings were updated."
|
||||||
msgstr "Die pretalx-musicrate-Einstellungen wurden gespeichert."
|
msgstr "Die pretalx-musicrate-Einstellungen wurden gespeichert."
|
||||||
|
|
||||||
#: pretalx_musicrate/views.py:273
|
#: pretalx_musicrate/views.py:275
|
||||||
msgid "Saved!"
|
msgid "Saved!"
|
||||||
msgstr "Gespeichert!"
|
msgstr "Gespeichert!"
|
||||||
|
|
||||||
#: pretalx_musicrate/views.py:375
|
#: pretalx_musicrate/views.py:377
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "%(num_ratings)d of %(num_jurors)d has rated this submission"
|
msgid "%(num_ratings)d of %(num_jurors)d has rated this submission"
|
||||||
msgid_plural "%(num_ratings)d of %(num_jurors)d have rated this submission"
|
msgid_plural "%(num_ratings)d of %(num_jurors)d have rated this submission"
|
||||||
|
|
|
@ -24,4 +24,9 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<hr>
|
||||||
|
<a class="btn btn-success btn-lg btn-block" href="{% url "plugins:pretalx_musicrate:export" event=request.event.slug %}">
|
||||||
|
<i class="fa fa-download"></i>
|
||||||
|
{% translate "Export ratings" %}
|
||||||
|
</a>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
|
ExportView,
|
||||||
JoinView,
|
JoinView,
|
||||||
MayAdvanceView,
|
MayAdvanceView,
|
||||||
MusicrateSettingsView,
|
MusicrateSettingsView,
|
||||||
|
@ -12,8 +13,12 @@ from .views import (
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path(
|
path(
|
||||||
"orga/event/<slug:event>/settings/p/pretalx_musicrate/",
|
"orga/event/<slug:event>/settings/p/pretalx_musicrate/",
|
||||||
MusicrateSettingsView.as_view(),
|
include(
|
||||||
name="settings.musicrate",
|
[
|
||||||
|
path("", MusicrateSettingsView.as_view(), name="settings.musicrate"),
|
||||||
|
path("export/", ExportView.as_view(), name="export"),
|
||||||
|
]
|
||||||
|
),
|
||||||
),
|
),
|
||||||
path(
|
path(
|
||||||
"<slug:event>/p/pretalx_musicrate/",
|
"<slug:event>/p/pretalx_musicrate/",
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
import csv
|
||||||
import re
|
import re
|
||||||
from hmac import compare_digest
|
from hmac import compare_digest
|
||||||
from urllib.parse import parse_qs, urlparse
|
from urllib.parse import parse_qs, urlparse
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.http import JsonResponse
|
from django.db.models import Case, FilteredRelation, Q, Value, When
|
||||||
|
from django.http import HttpResponse, JsonResponse
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
@ -379,3 +381,53 @@ class MayAdvanceView(EventPermissionRequired, SubmissionMixin, View):
|
||||||
% {"num_jurors": num_jurors, "num_ratings": num_ratings},
|
% {"num_jurors": num_jurors, "num_ratings": num_ratings},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ExportView(EventPermissionRequired, View):
|
||||||
|
permission_required = "orga.view_submissions"
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
response = HttpResponse(
|
||||||
|
content_type="text/csv",
|
||||||
|
headers={
|
||||||
|
"Content-Disposition": f'attachment; filename="{request.event.slug}.csv"'
|
||||||
|
},
|
||||||
|
)
|
||||||
|
writer = csv.writer(response)
|
||||||
|
genre_question = request.event.pretalx_musicrate_settings.genre_question
|
||||||
|
origin_question = request.event.pretalx_musicrate_settings.origin_question
|
||||||
|
jurors = request.event.jurors.order_by("token")
|
||||||
|
for submission in request.event.submissions.prefetch_related("answers").filter(
|
||||||
|
submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all()
|
||||||
|
):
|
||||||
|
submission_info = [submission.title, submission.submission_type.name]
|
||||||
|
if genre_question is not None:
|
||||||
|
submission_info.append(
|
||||||
|
submission.answers.filter(question=genre_question)
|
||||||
|
.values_list("answer", flat=True)
|
||||||
|
.first()
|
||||||
|
or ""
|
||||||
|
)
|
||||||
|
if origin_question is not None:
|
||||||
|
submission_info.append(
|
||||||
|
submission.answers.filter(question=origin_question)
|
||||||
|
.values_list("answer", flat=True)
|
||||||
|
.first()
|
||||||
|
or ""
|
||||||
|
)
|
||||||
|
writer.writerow(
|
||||||
|
[
|
||||||
|
*submission_info,
|
||||||
|
*jurors.annotate(
|
||||||
|
filtered_ratings=FilteredRelation(
|
||||||
|
"ratings", condition=Q(ratings__submission=submission)
|
||||||
|
),
|
||||||
|
rating=Case(
|
||||||
|
When(filtered_ratings__rating=None, then=Value("")),
|
||||||
|
When(filtered_ratings__rating="", then=Value("E")),
|
||||||
|
default="filtered_ratings__rating",
|
||||||
|
),
|
||||||
|
).values_list("rating", flat=True),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
return response
|
||||||
|
|
Loading…
Reference in New Issue