Compare commits
4 Commits
049062d5bb
...
57317b51d2
Author | SHA1 | Date |
---|---|---|
Luca | 57317b51d2 | |
Luca | 3091fb0783 | |
Luca | 14df5d5b68 | |
Luca | a0ccd2ff8e |
|
@ -1 +1 @@
|
|||
__version__ = "0.8.0"
|
||||
__version__ = "0.9.0"
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: pretalx-musicrate 0.0.1\n"
|
||||
"Project-Id-Version: pretalx-musicrate 0.9.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-12-16 03:23+0100\n"
|
||||
"PO-Revision-Date: 2023-12-16 03:24+0100\n"
|
||||
"POT-Creation-Date: 2023-12-18 01:34+0100\n"
|
||||
"PO-Revision-Date: 2023-12-18 01:36+0100\n"
|
||||
"Last-Translator: Luca <Luca@hackerspace-bamberg.de>\n"
|
||||
"Language-Team: Luca <Luca@hackerspace-bamberg.de>\n"
|
||||
"Language: de_DE\n"
|
||||
|
@ -93,6 +93,14 @@ msgstr "Zum Anhörtag"
|
|||
msgid "pretalx-musicrate settings"
|
||||
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
|
||||
msgid "(not specified)"
|
||||
msgstr "(nicht angegeben)"
|
||||
|
@ -105,19 +113,19 @@ msgstr "Zurück"
|
|||
msgid "Next"
|
||||
msgstr "Weiter"
|
||||
|
||||
#: pretalx_musicrate/views.py:39
|
||||
#: pretalx_musicrate/views.py:41
|
||||
msgid "Invalid token"
|
||||
msgstr "Ungültiges Token"
|
||||
|
||||
#: pretalx_musicrate/views.py:114
|
||||
#: pretalx_musicrate/views.py:116
|
||||
msgid "The pretalx-musicrate settings were updated."
|
||||
msgstr "Die pretalx-musicrate-Einstellungen wurden gespeichert."
|
||||
|
||||
#: pretalx_musicrate/views.py:273
|
||||
#: pretalx_musicrate/views.py:275
|
||||
msgid "Saved!"
|
||||
msgstr "Gespeichert!"
|
||||
|
||||
#: pretalx_musicrate/views.py:375
|
||||
#: pretalx_musicrate/views.py:377
|
||||
#, python-format
|
||||
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"
|
||||
|
|
|
@ -10,7 +10,7 @@ def pretalx_musicrate_qrcode(sender, request, **kwargs):
|
|||
return []
|
||||
return [
|
||||
{
|
||||
"active": request.resolver_match.url_name
|
||||
"active": request.resolver_match.view_name
|
||||
== "plugins:pretalx_musicrate:qrcode",
|
||||
"icon": "star",
|
||||
"label": _("Collective Rating"),
|
||||
|
@ -29,10 +29,10 @@ def pretalx_musicrate_settings(sender, request, **kwargs):
|
|||
{
|
||||
"label": "pretalx-musicrate",
|
||||
"url": reverse(
|
||||
"plugins:pretalx_musicrate:settings",
|
||||
"plugins:pretalx_musicrate:settings.musicrate",
|
||||
kwargs={"event": request.event.slug},
|
||||
),
|
||||
"active": request.resolver_match.url_name
|
||||
== "plugins:pretalx_musicrate:settings",
|
||||
"active": request.resolver_match.view_name
|
||||
== "plugins:pretalx_musicrate:settings.musicrate",
|
||||
}
|
||||
]
|
||||
|
|
|
@ -24,4 +24,9 @@
|
|||
</span>
|
||||
</div>
|
||||
</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 %}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django.urls import include, path
|
||||
|
||||
from .views import (
|
||||
ExportView,
|
||||
JoinView,
|
||||
MayAdvanceView,
|
||||
MusicrateSettingsView,
|
||||
|
@ -12,8 +13,12 @@ from .views import (
|
|||
urlpatterns = [
|
||||
path(
|
||||
"orga/event/<slug:event>/settings/p/pretalx_musicrate/",
|
||||
MusicrateSettingsView.as_view(),
|
||||
name="settings",
|
||||
include(
|
||||
[
|
||||
path("", MusicrateSettingsView.as_view(), name="settings.musicrate"),
|
||||
path("export/", ExportView.as_view(), name="export"),
|
||||
]
|
||||
),
|
||||
),
|
||||
path(
|
||||
"<slug:event>/p/pretalx_musicrate/",
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import csv
|
||||
import re
|
||||
from hmac import compare_digest
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
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.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
|
@ -379,3 +381,53 @@ class MayAdvanceView(EventPermissionRequired, SubmissionMixin, View):
|
|||
% {"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