Compare commits

...

25 Commits

Author SHA1 Message Date
Luca d319559272 fix(computescores): unexpected keyword argument
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2025-02-23 17:57:25 +01:00
Luca 1b264054fc chore: bump version
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2025-02-23 17:46:19 +01:00
Luca c5b39e1890 feat(computescores): add option to include frozen jurors 2025-02-23 17:45:55 +01:00
Luca 97a1dbf33a chore: bump version
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2025-02-23 14:41:17 +01:00
Luca 27e0b1e2c5 feat: add flag to Juror to disable them 2025-02-23 14:40:52 +01:00
Luca ec3acac3fc fix: assignee assignment
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2025-01-30 18:47:07 +01:00
Luca d5e3a35056 chore: bump version
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2024-12-09 22:33:19 +01:00
Luca 9accf9714e feat: add score export 2024-12-09 22:32:50 +01:00
Luca 2d7efeaf09 chore: bump version
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2024-12-08 15:49:16 +01:00
Luca 50d189d8ed feat: 'fix' last submission when submission types change 2024-12-08 15:48:24 +01:00
Luca f8f95db5c3 chore: bump version
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2024-12-07 20:40:54 +01:00
Luca dcce8e5407 fix: find new last submission if current one is not 'submitted'
continuous-integration/drone/push Build is passing Details
2024-12-07 20:36:15 +01:00
Luca 660650c8da feat: include only 'submitted' submissions in rating 2024-12-07 19:34:29 +01:00
Luca 18af2a75e6 chore: bump version
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2024-11-02 19:59:01 +01:00
Luca 01f5434065 fix: round half up instead of rounding down
continuous-integration/drone/push Build is passing Details
2024-11-02 19:57:39 +01:00
Luca e7df05566f chore: update year 2024-11-02 19:53:14 +01:00
Luca cabf4538d2 fix: missing style definition for .submit-group 2024-11-02 19:48:44 +01:00
Luca 81f1d44700 chore: update localization
continuous-integration/drone/push Build is passing Details
2024-11-02 19:34:39 +01:00
Luca 1c8047a006 refactor: remove dependencies on Bootstrap and jQuery 2024-11-02 19:21:47 +01:00
Luca 6823e11ff0 refactor: match urls using pretalx' custom SLUG_REGEX 2024-11-02 19:20:35 +01:00
Luca a693370a7d chore: remove legacy css classes on widgets 2024-11-02 19:15:31 +01:00
Luca 5b508bf61b fix: mixins import path 2024-11-02 19:14:29 +01:00
Luca d4a1a4738f chore: start development cycle 2024-11-02 19:13:30 +01:00
Luca 91acd4e855 style: add .editorconfig 2024-11-02 19:12:14 +01:00
Luca 83409ef2c8 chore: update for pretalx 2024.1.0
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2024-02-16 19:11:14 +01:00
18 changed files with 266 additions and 186 deletions

5
.editorconfig Normal file
View File

@ -0,0 +1,5 @@
root = true
[*.{html,js}]
indent_size = 4
indent_style = space

View File

@ -1,4 +1,4 @@
Copyright 2023 Luca
Copyright 2023-2024 Luca Schmid
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -40,7 +40,7 @@ black .
## License
Copyright 2023 Luca Schmid
Copyright 2023-2024 Luca Schmid
Released under the terms of the Apache License 2.0

View File

@ -1 +1 @@
__version__ = "0.14.3"
__version__ = "2025.6.1"

View File

@ -37,12 +37,6 @@ class MusicrateSettingsForm(I18nModelForm):
"link_questions",
"advance_threshold",
)
widgets = {
"submission_types": forms.SelectMultiple(attrs={"class": "select2"}),
"genre_question": forms.Select(attrs={"class": "select2"}),
"origin_question": forms.Select(attrs={"class": "select2"}),
"link_questions": forms.SelectMultiple(attrs={"class": "select2"}),
}
field_classes = {
"submission_types": SafeModelMultipleChoiceField,
"genre_question": SafeModelChoiceField,
@ -68,12 +62,9 @@ class AssigneeForm(forms.ModelForm):
except Assignee.DoesNotExist:
self.instance = Assignee(submission=submission)
super().__init__(*args, instance=self.instance, **kwargs)
self.fields["user"].queryset = User.objects.none().union(
*(
t.members.all()
for t in submission.event.teams.filter(can_change_submissions=True)
)
)
self.fields["user"].queryset = User.objects.filter(
teams__in=submission.event.teams, teams__can_change_submissions=True
).distinct()
class Meta:
model = Assignee
@ -83,3 +74,10 @@ class AssigneeForm(forms.ModelForm):
class EnhancedSubmissionFilterForm(SubmissionFilterForm):
require_all_tags = forms.BooleanField(required=False, label=_("require all"))
def filter_queryset(self, qs):
qs = super().filter_queryset(qs)
if self.cleaned_data.get("require_all_tags"):
for tag in self.cleaned_data.get("tags"):
qs = qs.filter(tags__in=[tag])
return qs

View File

@ -1,14 +1,14 @@
# pretalx plugin for rating music.
# Copyright (C) 2023
# Copyright (C) 2023-2024
# This file is distributed under the same license as the pretalx_musicrate package.
# Luca Schmid <Luca@hackerspace-bamberg.de>, 2023.
# Luca Schmid <Luca@hackerspace-bamberg.de>, 2023-2024.
#
msgid ""
msgstr ""
"Project-Id-Version: pretalx-musicrate 0.9.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-02-14 22:24+0100\n"
"PO-Revision-Date: 2024-02-14 22:30+0100\n"
"POT-Creation-Date: 2024-12-09 22:22+0100\n"
"PO-Revision-Date: 2024-12-09 22:23+0100\n"
"Last-Translator: Luca <Luca@hackerspace-bamberg.de>\n"
"Language-Team: Luca <Luca@hackerspace-bamberg.de>\n"
"Language: de_DE\n"
@ -16,9 +16,9 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.4.1\n"
"X-Generator: Poedit 3.4.2\n"
#: pretalx_musicrate/apps.py:12
#: pretalx_musicrate/apps.py:12 pretalx_musicrate/signals.py:59
msgid "pretalx-musicrate"
msgstr "pretalx-musicrate"
@ -26,7 +26,7 @@ msgstr "pretalx-musicrate"
msgid "pretalx plugin for rating music"
msgstr "pretalx-Plugin zur Bewertung von Musik"
#: pretalx_musicrate/forms.py:85
#: pretalx_musicrate/forms.py:79
msgid "require all"
msgstr "alle voraussetzen"
@ -71,100 +71,95 @@ msgid "The name of the submission's assignee"
msgstr "Der Name der für die Einreichung zuständigen Person"
#: pretalx_musicrate/signals.py:35
msgid "Proposals, but better"
msgstr "Einreichungen, aber besser"
msgid "Sessions, but better"
msgstr "Vorträge, aber besser"
#: pretalx_musicrate/signals.py:45
msgid "Collective Rating"
msgstr "Anhörtag"
#: pretalx_musicrate/templates/pretalx_musicrate/assignee.html:6
#: pretalx_musicrate/templates/pretalx_musicrate/assignee.html:5
#, python-format
msgid "Assignee for %(quotation_open)s%(title)s%(quotation_close)s"
msgstr "Zuständige*r für %(quotation_open)s%(title)s%(quotation_close)s"
#: pretalx_musicrate/templates/pretalx_musicrate/assignee.html:16
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:22
msgid "Save"
msgstr "Speichern"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:23
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:43
msgid "proposal"
msgid_plural "proposals"
msgstr[0] "Einreichung"
msgstr[1] "Einreichungen"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:46
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:72
msgid "Search"
msgstr "Suche"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:51
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:77
#, python-format
msgid "List filtered by answers to question \"%(question)s\"."
msgstr "Liste gefiltert nach Antworten zur Frage \"%(question)s\"."
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:56
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:82
msgid "Remove filter"
msgstr "Filter entfernen"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:67
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:93
msgid "Rating"
msgstr "Bewertung"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:68
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:94
msgid "Sort by rating (0-10)"
msgstr "Nach Bewertung sortieren (0-10)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:69
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:95
msgid "Sort by rating (10-0)"
msgstr "Nach Bewertung sortieren (10-0)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:72
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:98
msgid "Title"
msgstr "Titel"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:73
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:99
msgid "Sort by title (a-z)"
msgstr "Nach Titel sortieren (a-z)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:74
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:100
msgid "Sort by title (z-a)"
msgstr "Nach Titel sortieren (z-a)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:78
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:104
msgid "Type"
msgstr "Typ"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:82
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:108
msgid "State"
msgstr "Status"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:83
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:109
msgid "Sort by state (a-z)"
msgstr "Nach Status sortieren (a-z)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:84
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:110
msgid "Sort by state (z-a)"
msgstr "Nach Status sortieren (z-a)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:87
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:113
msgid "Assignee"
msgstr "Zuständige*r"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:88
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:114
msgid "Sort by assignee (a-z)"
msgstr "Nach Zuständiger*m sortieren (a-z)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:89
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:115
msgid "Sort by assignee (z-a)"
msgstr "Nach Zuständiger*m sortieren (z-a)"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:128
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:136
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:154
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:162
msgid "edit"
msgstr "bearbeiten"
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:141
#: pretalx_musicrate/templates/pretalx_musicrate/enhanced_list.html:167
msgid "Delete"
msgstr "Löschen"
@ -191,39 +186,43 @@ msgstr "Mitmach-QR-Code anzeigen"
msgid "Go to collective rating"
msgstr "Zum Anhörtag"
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:8
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:7
msgid "pretalx-musicrate settings"
msgstr "pretalx-musicrate-Einstellungen"
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:30
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:12
msgid "Export ratings"
msgstr "Bewertungen exportieren"
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:29
#: pretalx_musicrate/templates/pretalx_musicrate/settings.html:16
msgid "Export scores"
msgstr "Auswertung exportieren"
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:34
msgid "(not specified)"
msgstr "(nicht angegeben)"
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:42
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:47
msgid "Previous"
msgstr "Zurück"
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:50
#: pretalx_musicrate/templates/pretalx_musicrate/submission_base.html:55
msgid "Next"
msgstr "Weiter"
#: pretalx_musicrate/views.py:48
#: pretalx_musicrate/views.py:66
msgid "Invalid token"
msgstr "Ungültiges Token"
#: pretalx_musicrate/views.py:123
#: pretalx_musicrate/views.py:133
msgid "The pretalx-musicrate settings were updated."
msgstr "Die pretalx-musicrate-Einstellungen wurden gespeichert."
#: pretalx_musicrate/views.py:282 pretalx_musicrate/views.py:469
#: pretalx_musicrate/views.py:289 pretalx_musicrate/views.py:482
msgid "Saved!"
msgstr "Gespeichert!"
#: pretalx_musicrate/views.py:386
#: pretalx_musicrate/views.py:398
#, 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"

View File

@ -20,6 +20,9 @@ class Command(BaseCommand):
help = "Compute submission scores from ratings"
def add_arguments(self, parser):
parser.add_argument(
"-a", "--all", action="store_true", help="include frozen jurors"
)
parser.add_argument("event")
def handle(self, *args, **kwargs):
@ -31,9 +34,15 @@ class Command(BaseCommand):
with scope(event=event):
submissions = {}
for juror in event.jurors.prefetch_related("ratings__submission").order_by(
jurors = event.jurors.prefetch_related("ratings__submission").order_by(
"token"
):
)
if not kwargs["all"]:
jurors = jurors.filter(frozen=False)
self.stderr.write(f"computing scores from {jurors.count()} jurors")
for juror in jurors:
ratings = list(
juror.ratings.exclude(rating="").order_by("submission__created")
)

View File

@ -1,7 +1,7 @@
# Generated by Django 4.2.8 on 2023-12-15 18:27
import django.db.models.deletion
import pretalx.common.mixins.models
import pretalx.common.models.mixins
from django.db import migrations, models
import pretalx_musicrate.models
@ -51,8 +51,8 @@ class Migration(migrations.Migration):
"abstract": False,
},
bases=(
pretalx.common.mixins.models.LogMixin,
pretalx.common.mixins.models.FileCleanupMixin,
pretalx.common.models.mixins.LogMixin,
pretalx.common.models.mixins.FileCleanupMixin,
models.Model,
),
),

View File

@ -0,0 +1,18 @@
# Generated by Django 5.1.5 on 2025-02-23 13:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("pretalx_musicrate", "0009_score"),
]
operations = [
migrations.AddField(
model_name="juror",
name="frozen",
field=models.BooleanField(default=False),
),
]

View File

@ -78,6 +78,7 @@ class Juror(models.Model):
related_name="jurors",
null=True,
)
frozen = models.BooleanField(default=False)
class Rating(models.Model):

View File

@ -32,7 +32,7 @@ def pretalx_musicrate_nav_event(sender, request, **kwargs):
"active": request.resolver_match.view_name
== "plugins:pretalx_musicrate:enhanced_list",
"icon": "sticky-note-o",
"label": _("Proposals, but better"),
"label": _("Sessions, but better"),
"url": reverse(
"plugins:pretalx_musicrate:enhanced_list",
kwargs={"event": request.event.slug},
@ -56,7 +56,7 @@ def pretalx_musicrate_settings(sender, request, **kwargs):
return []
return [
{
"label": "pretalx-musicrate",
"label": _("pretalx-musicrate"),
"url": reverse(
"plugins:pretalx_musicrate:settings.musicrate",
kwargs={"event": request.event.slug},

View File

@ -1,11 +1,14 @@
document.addEventListener("DOMContentLoaded", function() {
const updateRequireAllVisibility = () => {
if (document.querySelector("#id_tags").value) {
document.querySelector("#requireAll").classList.remove("d-none")
} else {
document.querySelector("#requireAll").classList.add("d-none")
onReady(() => {
const updateRequireAllVisibility = () => {
if (document.querySelector("#id_tags").value) {
document.querySelector("#requireAll").classList.remove("d-none")
} else {
document.querySelector("#requireAll").classList.add("d-none")
}
}
}
$("#id_tags").on("change", updateRequireAllVisibility)
updateRequireAllVisibility()
document
.querySelector("#id_tags")
.addEventListener("change", updateRequireAllVisibility)
updateRequireAllVisibility()
})

View File

@ -1,22 +1,8 @@
{% extends "orga/base.html" %}
{% load bootstrap4 %}
{% load i18n %}
{% block content %}
<h2>{% blocktranslate with title=submission.title %}Assignee for {{ quotation_open }}{{ title }}{{ quotation_close }}{% endblocktranslate %}</h2>
<form method="post">
{% csrf_token %}
{% bootstrap_form_errors form %}
{% bootstrap_field form.user layout='event' %}
<div class="submit-group panel">
<span></span>
<span>
<button type="submit" class="btn btn-success btn-lg">
<i class="fa fa-check"></i>
{% translate "Save" %}
</button>
</span>
</div>
</form>
{% include "orga/includes/base_form.html" %}
{% endblock %}

View File

@ -1,17 +1,37 @@
{% extends "orga/base.html" %}
{% load bootstrap4 %}
{% load compress %}
{% load i18n %}
{% load rules %}
{% load static %}
{% load url_replace %}
{% block scripts %}
{% compress js %}
<script src="{% static "orga/js/submission_filter.js" %}"></script>
<script defer src="{% static "orga/js/submission_filter.js" %}"></script>
{% endcompress %}
{% compress js %}
<script src="{% static "pretalx_musicrate/submission_filter.js" %}"></script>
<script defer src="{% static "pretalx_musicrate/submission_filter.js" %}"></script>
{% endcompress %}
{% endblock %}
{% block stylesheets %}
{% compress css %}
<style>
.search-form {
#requireAll .form-group {
margin-bottom: 0;
}
#requireAll label {
display: inline-block;
color: #6c757d;
}
}
#requireAll .form-group-inline {
flex-direction: row;
align-items: center;
}
</style>
{% endcompress %}
{% endblock %}
@ -29,20 +49,26 @@
<div class="submit-group search-submit-group">
<form class="search-form">
{% bootstrap_form search_form %}
{% if show_submission_types and filter_form.submission_type %}{% bootstrap_field filter_form.submission_type %}{% endif %}
{{ filter_form.q.as_field_group }}
{% if show_submission_types and filter_form.submission_type %}{{ filter_form.submission_type.as_field_group }}{% endif %}
<div class="d-flex flex-column form-group">
{% bootstrap_field filter_form.state layout='inline' %}
<div id="pending" class="d-none">{% bootstrap_field filter_form.pending_state__isnull layout='inline' %}</div>
{{ filter_form.state.as_field_group }}
<div id="pending" class="ml-1 d-none">{{ filter_form.pending_state__isnull.as_field_group }}</div>
</div>
{% if filter_form.track %}{% bootstrap_field filter_form.track %}{% endif %}
{% if filter_form.track %}{{ filter_form.track.as_field_group }}{% endif %}
{% if filter_form.tags %}
<div class="d-flex flex-column form-group">
{% bootstrap_field filter_form.tags layout='inline' %}
<div id="requireAll" class="d-none">{% bootstrap_field filter_form.require_all_tags layout='inline' %}</div>
{{ filter_form.tags.as_field_group }}
<div id="requireAll" class="ml-1 d-none">{{ filter_form.require_all_tags.as_field_group }}</div>
</div>
{% endif %}
{% if filter_form.content_locale %}{% bootstrap_field filter_form.content_locale %}{% endif %}
{% if filter_form.content_locale %}{{ filter_form.content_locale.as_field_group }}{% endif %}
{# These fields are hidden, but included to keep question search intact #}
{% if request.GET.question %} <input type="hidden" name="question" value="{{ request.GET.question }}"> {% endif %}
{% if request.GET.answer__options %} <input type="hidden" name="answer__options" value="{{ request.GET.answer__options }}"> {% endif %}
{% if request.GET.answer %} <input type="hidden" name="answer" value="{{ request.GET.answer }}"> {% endif %}
{% if request.GET.unanswered %} <input type="hidden" name="unanswered" value="{{ request.GET.unanswered }}"> {% endif %}
<button class="btn btn-success" type="submit">{% translate "Search" %}</button>
</form>
{% if filter_form.is_valid and filter_form.cleaned_data.question %}
@ -51,7 +77,7 @@
{% blocktranslate trimmed with question=filter_form.cleaned_data.question.question %}
List filtered by answers to question "{{ question }}".
{% endblocktranslate %}
<a href="?{% url_replace request 'question' '' 'answer' '' 'answer__options' '' %}" class="text-muted">
<a href="{% querystring question="" answer="" answer__options="" %}" class="text-muted">
<span class="fa fa-times"></span>
{% translate "Remove filter" %}
</a>
@ -65,13 +91,13 @@
<tr>
<th>
{% translate "Rating" %}
<a href="?{% url_replace request 'sort' 'score__value' %}"><i class="fa fa-caret-down" title="{% translate "Sort by rating (0-10)" %}"></i></a>
<a href="?{% url_replace request 'sort' '-score__value' %}"><i class="fa fa-caret-up" title="{% translate "Sort by rating (10-0)" %}"></i></a>
<a href="{% querystring sort="score__value" %}"><i class="fa fa-caret-down" title="{% translate "Sort by rating (0-10)" %}"></i></a>
<a href="{% querystring sort="-score__value" %}"><i class="fa fa-caret-up" title="{% translate "Sort by rating (10-0)" %}"></i></a>
</th>
<th>
{% translate "Title" %}
<a href="?{% url_replace request 'sort' 'title' %}"><i class="fa fa-caret-down" title="{% translate "Sort by title (a-z)" %}"></i></a>
<a href="?{% url_replace request 'sort' '-title' %}"><i class="fa fa-caret-up" title="{% translate "Sort by title (z-a)" %}"></i></a>
<a href="?{% querystring sort="title" %}"><i class="fa fa-caret-down" title="{% translate "Sort by title (a-z)" %}"></i></a>
<a href="?{% querystring sort="-title" %}"><i class="fa fa-caret-up" title="{% translate "Sort by title (z-a)" %}"></i></a>
</th>
{% if show_submission_types %}
<th>
@ -80,13 +106,13 @@
{% endif %}
<th>
{% translate "State" %}
<a href="?{% url_replace request 'sort' 'state' %}"><i class="fa fa-caret-down" title="{% translate "Sort by state (a-z)" %}"></i></a>
<a href="?{% url_replace request 'sort' '-state' %}"><i class="fa fa-caret-up" title="{% translate "Sort by state (z-a)" %}"></i></a>
<a href="?{% querystring sort="state" %}"><i class="fa fa-caret-down" title="{% translate "Sort by state (a-z)" %}"></i></a>
<a href="?{% querystring sort="-state" %}"><i class="fa fa-caret-up" title="{% translate "Sort by state (z-a)" %}"></i></a>
</th>
<th>
{% translate "Assignee" %}
<a href="?{% url_replace request 'sort' 'assignee' %}"><i class="fa fa-caret-down" title="{% translate "Sort by assignee (a-z)" %}"></i></a>
<a href="?{% url_replace request 'sort' '-assignee' %}"><i class="fa fa-caret-up" title="{% translate "Sort by assignee (z-a)" %}"></i></a>
<a href="?{% querystring sort="assignee" %}"><i class="fa fa-caret-down" title="{% translate "Sort by assignee (a-z)" %}"></i></a>
<a href="?{% querystring sort="-assignee" %}"><i class="fa fa-caret-up" title="{% translate "Sort by assignee (z-a)" %}"></i></a>
</th>
{% if can_change_submission %}
<th></th>
@ -150,5 +176,5 @@
</table>
</div>
{% include "orga/pagination.html" %}
{% include "orga/includes/pagination.html" %}
{% endblock %}

View File

@ -1,32 +1,18 @@
{% extends "orga/base.html" %}
{% load bootstrap4 %}
{% load compress %}
{% load i18n %}
{% load static %}
{% block content %}
<h2>{% translate "pretalx-musicrate settings" %}</h2>
<form method="post">
{% csrf_token %}
{% bootstrap_form_errors form %}
{% bootstrap_field form.submission_types layout='event' %}
{% bootstrap_field form.genre_question layout='event' %}
{% bootstrap_field form.origin_question layout='event' %}
{% bootstrap_field form.link_questions layout='event' %}
{% bootstrap_field form.advance_threshold layout='event' %}
<div class="submit-group panel">
<span></span>
<span>
<button type="submit" class="btn btn-success btn-lg">
<i class="fa fa-check"></i>
{% translate "Save" %}
</button>
</span>
</div>
</form>
{% include "orga/includes/base_form.html" %}
<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>
<a class="btn btn-success btn-lg btn-block" href="{% url "plugins:pretalx_musicrate:scores" event=request.event.slug %}">
<i class="fa fa-download"></i>
{% translate "Export scores" %}
</a>
{% endblock %}

View File

@ -1,11 +1,13 @@
{% extends "cfp/event/base.html" %}
{% load compress %}
{% load i18n %}
{% load static %}
{% block title %}{{ submission.title }} ::{% endblock %}
{% block cfp_header %}
{% block stylesheets %}
{% compress css %}
<link rel="stylesheet" type="text/css" href="{% static "common/css/_forms.css" %}" />
<style>
.musicrate-pagination {
display: flex;
@ -21,6 +23,9 @@
}
</style>
{% endcompress %}
{% endblock %}
{% block cfp_header %}
{% block submission_header %}
{% endblock %}
{% endblock %}

View File

@ -1,4 +1,5 @@
from django.urls import include, path
from django.urls import include, path, re_path
from pretalx.event.models.event import SLUG_REGEX
from .views import (
AssigneeView,
@ -10,11 +11,12 @@ from .views import (
PresenterView,
QRCodeView,
RatingView,
ScoreExportView,
)
urlpatterns = [
path(
"orga/event/<slug:event>/",
re_path(
rf"^orga/event/(?P<event>{SLUG_REGEX})/",
include(
[
path(
@ -32,6 +34,7 @@ urlpatterns = [
EnhancedSubmissionList.as_view(),
name="enhanced_list",
),
path("scores/", ScoreExportView.as_view(), name="scores"),
path("<code>/", AssigneeView.as_view(), name="assignee"),
]
),
@ -39,8 +42,8 @@ urlpatterns = [
]
),
),
path(
"<slug:event>/p/pretalx_musicrate/",
re_path(
rf"^(?P<event>{SLUG_REGEX})/p/pretalx_musicrate/",
include(
[
path("", QRCodeView.as_view(), name="qrcode"),

View File

@ -4,7 +4,7 @@ from hmac import compare_digest
from urllib.parse import parse_qs, urlparse
from django.contrib import messages
from django.db.models import Case, FilteredRelation, Q, Value, When
from django.db.models import Case, F, FilteredRelation, Q, Value, When
from django.http import HttpResponse, JsonResponse
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
@ -14,9 +14,9 @@ from django.utils.translation import gettext_lazy as _, ngettext
from django.views.generic import FormView, TemplateView, View
from django.views.generic.detail import SingleObjectMixin
from django_context_decorator import context
from pretalx.common.mixins.views import EventPermissionRequired
from pretalx.orga.views.submission import SubmissionList
from pretalx.submission.models import Submission
from pretalx.common.views.mixins import EventPermissionRequired
from pretalx.orga.views.submission import BaseSubmissionList, SubmissionList
from pretalx.submission.models import Submission, SubmissionStates
from .forms import (
AssigneeForm,
@ -31,12 +31,30 @@ youtube_re = re.compile(
)
def get_last_submission(settings, submissions, submission=None):
if submission is not None and submission.state != SubmissionStates.SUBMITTED:
submission = None
submission = submission or settings.last_submission
if submission is not None and submission.state != SubmissionStates.SUBMITTED:
submission = None
submissions = submissions.filter(
submission_type__in=settings.submission_types.all(),
state=SubmissionStates.SUBMITTED,
)
if submission is not None and not submissions.filter(pk=submission.pk).exists():
submission = None
return submission or submissions.order_by("created").first()
class JoinView(TemplateView):
template_name = "pretalx_musicrate/join.html"
def validate_token(self, token):
try:
self.juror = Juror.objects.get(token=token)
self.juror = Juror.objects.get(token=token, frozen=False)
return True
except Juror.DoesNotExist:
self.juror = None
@ -57,14 +75,10 @@ class JoinView(TemplateView):
def get(self, request, *args, token, **kwargs):
token_valid = self.validate_token(token)
if self.juror is not None:
submission = (
self.juror.last_submission
or self.request.event.pretalx_musicrate_settings.last_submission
or self.request.event.submissions.filter(
submission_type__in=self.request.event.pretalx_musicrate_settings.submission_types.all()
)
.order_by("created")
.first()
submission = get_last_submission(
self.request.event.pretalx_musicrate_settings,
self.request.event.submissions,
self.juror.last_submission,
)
if submission is not None:
return redirect(
@ -83,14 +97,10 @@ class JoinView(TemplateView):
event=self.request.event,
last_submission=self.request.event.pretalx_musicrate_settings.last_submission,
)
submission = (
self.juror.last_submission
or self.request.event.pretalx_musicrate_settings.last_submission
or self.request.event.submissions.filter(
submission_type__in=self.request.event.pretalx_musicrate_settings.submission_types.all()
)
.order_by("created")
.first()
submission = get_last_submission(
self.request.event.pretalx_musicrate_settings,
self.request.event.submissions,
self.juror.last_submission,
)
if submission is not None:
return redirect(
@ -140,13 +150,9 @@ class QRCodeView(EventPermissionRequired, TemplateView):
},
)
)
context["last_submission"] = (
self.request.event.pretalx_musicrate_settings.last_submission
or self.request.event.submissions.filter(
submission_type__in=self.request.event.pretalx_musicrate_settings.submission_types.all()
)
.order_by("created")
.first()
context["last_submission"] = get_last_submission(
self.request.event.pretalx_musicrate_settings,
self.request.event.submissions,
)
return context
@ -157,7 +163,8 @@ class SubmissionMixin(SingleObjectMixin):
def get_queryset(self):
return self.request.event.submissions.prefetch_related("answers").filter(
submission_type__in=self.request.event.pretalx_musicrate_settings.submission_types.all()
submission_type__in=self.request.event.pretalx_musicrate_settings.submission_types.all(),
state=SubmissionStates.SUBMITTED,
)
@context
@ -249,7 +256,7 @@ class RatingView(FormView, SubmissionMixin):
@cached_property
def juror(self):
return get_object_or_404(
Juror, token=self.request.resolver_match.kwargs["token"]
Juror, token=self.request.resolver_match.kwargs["token"], frozen=False
)
@context
@ -284,17 +291,22 @@ class RatingView(FormView, SubmissionMixin):
def get(self, request, *args, **kwargs):
self.object = self.get_object()
last_submission = get_last_submission(
self.request.event.pretalx_musicrate_settings,
self.request.event.submissions,
)
if (
(settings := self.request.event.pretalx_musicrate_settings).last_submission
is not None
and self.object.created > settings.last_submission.created
last_submission is not None
and self.object.created > last_submission.created
):
return redirect(
self.request.resolver_match.view_name,
event=self.request.event.slug,
token=self.juror.token,
code=settings.last_submission.code,
code=last_submission.code,
)
return super().get(request, *args, **kwargs)
@ -353,16 +365,16 @@ class PresenterView(EventPermissionRequired, SubmissionMixin, TemplateView):
def get(self, request, *args, **kwargs):
self.object = self.get_object()
if (
(settings := self.request.event.pretalx_musicrate_settings).last_submission
is None
or self.object.created > settings.last_submission.created
):
settings = self.request.event.pretalx_musicrate_settings
last_submission = get_last_submission(settings, self.request.event.submissions)
if last_submission is None or self.object.created > last_submission.created:
try:
settings.last_submission = self.object
settings.save()
except Exception:
pass
response = super().get(request, *args, **kwargs)
response._csp_update = {"frame-src": "https://www.youtube-nocookie.com"}
return response
@ -372,12 +384,12 @@ class MayAdvanceView(EventPermissionRequired, SubmissionMixin, View):
permission_required = "orga.view_submissions"
def get(self, request, *args, **kwargs):
num_ratings = self.submission.ratings.count()
num_jurors = self.request.event.jurors.count()
num_ratings = self.submission.ratings.filter(juror__frozen=False).count()
num_jurors = self.request.event.jurors.filter(frozen=False).count()
return JsonResponse(
{
"mayAdvance": num_ratings
>= int(
>= round(
num_jurors
* self.request.event.pretalx_musicrate_settings.advance_threshold
)
@ -405,7 +417,7 @@ class ExportView(EventPermissionRequired, View):
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")
jurors = request.event.jurors.filter(frozen=False).order_by("token")
for submission in (
request.event.submissions.prefetch_related("answers")
.select_related("submission_type")
@ -488,11 +500,40 @@ class EnhancedSubmissionList(SubmissionList):
event=self.request.event,
usable_states=self.usable_states,
limit_tracks=self.limit_tracks,
search_fields=self.get_default_filters(),
)
def filter_queryset(self, qs):
qs = super().filter_queryset(qs.prefetch_related("assignee"))
if self.request.GET.get("require_all_tags", "") == "on":
for tag in self.request.GET.getlist("tags"):
qs = qs.filter(tags__in=[tag])
return qs
def _get_base_queryset(self, for_review=False):
qs = (
super(BaseSubmissionList, self)
.get_queryset(for_review=for_review)
.prefetch_related("assignee")
.order_by("-id")
)
if not self.filter_form.is_valid():
return qs
return self.filter_form.filter_queryset(qs)
class ScoreExportView(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"'
},
)
csv.writer(response).writerows(
request.event.submissions.select_related("score", "submission_type")
.filter(
submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all()
)
.exclude(state__in=(SubmissionStates.CANCELED, SubmissionStates.WITHDRAWN))
.order_by(F("score__value").desc(nulls_last=True))
.values_list("score__value", "title")
)
return response