feat: look for links in configured questions
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2023-12-16 03:29:52 +01:00
parent cc4178baba
commit 66d315e8d6
6 changed files with 49 additions and 6 deletions

View File

@ -23,6 +23,7 @@ class MusicrateSettingsForm(I18nModelForm):
if self.instance.genre_question
else event.questions.all()
)
self.fields["link_questions"].queryset = event.questions.all()
class Meta:
model = MusicrateSettings
@ -30,17 +31,20 @@ class MusicrateSettingsForm(I18nModelForm):
"submission_types",
"genre_question",
"origin_question",
"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,
"origin_question": SafeModelChoiceField,
"link_questions": SafeModelMultipleChoiceField,
}

View File

@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: pretalx-musicrate 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-12-16 03:01+0100\n"
"PO-Revision-Date: 2023-12-16 03:02+0100\n"
"POT-Creation-Date: 2023-12-16 03:23+0100\n"
"PO-Revision-Date: 2023-12-16 03:24+0100\n"
"Last-Translator: Luca <Luca@hackerspace-bamberg.de>\n"
"Language-Team: Luca <Luca@hackerspace-bamberg.de>\n"
"Language: de_DE\n"
@ -58,6 +58,10 @@ msgstr ""
msgid "Advance Threshold"
msgstr "Weiter-Schwellenwert"
#: pretalx_musicrate/models.py:63
msgid "Link Questions"
msgstr "Fragen zu Links"
#: pretalx_musicrate/signals.py:16
msgid "Collective Rating"
msgstr "Anhörtag"
@ -101,19 +105,19 @@ msgstr "Zurück"
msgid "Next"
msgstr "Weiter"
#: pretalx_musicrate/views.py:40
#: pretalx_musicrate/views.py:39
msgid "Invalid token"
msgstr "Ungültiges Token"
#: pretalx_musicrate/views.py:115
#: pretalx_musicrate/views.py:114
msgid "The pretalx-musicrate settings were updated."
msgstr "Die pretalx-musicrate-Einstellungen wurden gespeichert."
#: pretalx_musicrate/views.py:274
#: pretalx_musicrate/views.py:273
msgid "Saved!"
msgstr "Gespeichert!"
#: pretalx_musicrate/views.py:372
#: pretalx_musicrate/views.py:375
#, 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

@ -0,0 +1,24 @@
# Generated by Django 4.2.8 on 2023-12-16 02:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("submission", "0074_created_updated_everywhere"),
(
"pretalx_musicrate",
"0005_juror_musicratesettings_last_submission_rating_and_more",
),
]
operations = [
migrations.AddField(
model_name="musicratesettings",
name="link_questions",
field=models.ManyToManyField(
related_name="pretalx_musicrate_settings_links",
to="submission.question",
),
),
]

View File

@ -57,6 +57,12 @@ class MusicrateSettings(models.Model):
related_name="pretalx_musicrate_settings",
null=True,
)
link_questions = models.ManyToManyField(
to="submission.Question",
related_name="pretalx_musicrate_settings_links",
verbose_name=_("Link Questions"),
blank=True,
)
class Juror(PretalxModel):

View File

@ -12,6 +12,7 @@
{% 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' %}
{% include "orga/includes/submit_row.html" %}
</form>

View File

@ -311,6 +311,10 @@ class PresenterView(EventPermissionRequired, SubmissionMixin, TemplateView):
urlizer(self.submission.description)
urlizer(self.submission.notes)
urlizer(self.submission.internal_notes)
for answer in self.submission.answers.filter(
question__in=self.request.event.pretalx_musicrate_settings.link_questions.all()
).values_list("answer", flat=True):
urlizer(answer)
links = []
for url in extractor.urls:
if (m := youtube_re.search(url)) is not None: