Compare commits

..

2 Commits

Author SHA1 Message Date
Luca f04e114062 feat(settings): add genre and origin questions
continuous-integration/drone/push Build is passing Details
2023-12-15 00:06:53 +01:00
Luca 1288737f11 chore(pyproject.toml): add dependencies 2023-12-15 00:03:39 +01:00
5 changed files with 73 additions and 3 deletions

View File

@ -1,5 +1,5 @@
from django import forms
from django_scopes.forms import SafeModelMultipleChoiceField
from django_scopes.forms import SafeModelChoiceField, SafeModelMultipleChoiceField
from i18nfield.forms import I18nModelForm
from .models import MusicrateSettings
@ -13,13 +13,27 @@ class MusicrateSettingsForm(I18nModelForm):
self.fields.pop("submission_types")
else:
self.fields["submission_types"].queryset = event.submission_types.all()
self.fields["genre_question"].queryset = (
event.questions.exclude(pk=self.instance.origin_question.pk)
if self.instance.origin_question
else event.questions.all()
)
self.fields["origin_question"].queryset = (
event.questions.exclude(pk=self.instance.genre_question.pk)
if self.instance.genre_question
else event.questions.all()
)
class Meta:
model = MusicrateSettings
fields = ("submission_types",)
fields = ("submission_types", "genre_question", "origin_question")
widgets = {
"submission_types": forms.SelectMultiple(attrs={"class": "select2"}),
"genre_question": forms.Select(attrs={"class": "select2"}),
"origin_question": forms.Select(attrs={"class": "select2"}),
}
field_classes = {
"submission_types": SafeModelMultipleChoiceField,
"genre_question": SafeModelChoiceField,
"origin_question": SafeModelChoiceField,
}

View File

@ -0,0 +1,34 @@
# Generated by Django 4.2.8 on 2023-12-14 22:47
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("submission", "0074_created_updated_everywhere"),
("pretalx_musicrate", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="musicratesettings",
name="genre_question",
field=models.OneToOneField(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="pretalx_musicrate_settings_genre",
to="submission.question",
),
),
migrations.AddField(
model_name="musicratesettings",
name="origin_question",
field=models.OneToOneField(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="pretalx_musicrate_settings_origin",
to="submission.question",
),
),
]

View File

@ -17,3 +17,19 @@ class MusicrateSettings(models.Model):
verbose_name=_("Session Types"),
blank=True,
)
genre_question = models.OneToOneField(
to="submission.Question",
on_delete=models.SET_NULL,
related_name="pretalx_musicrate_settings_genre",
verbose_name=_("Genre Question"),
blank=True,
null=True,
)
origin_question = models.OneToOneField(
to="submission.Question",
on_delete=models.SET_NULL,
related_name="pretalx_musicrate_settings_origin",
verbose_name=_("Origin Question"),
blank=True,
null=True,
)

View File

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

View File

@ -12,7 +12,11 @@ maintainers = [
{name = "Luca", email = "Luca@hackerspace-bamberg.de"},
]
dependencies = []
dependencies = [
"Django",
"django-i18nfield",
"pretalx",
]
[project.urls]
homepage = "https://git.luj0ga.de/kontakt/pretalx-musicrate"