Compare commits

..

No commits in common. "f0caef1cca7dd7ef47341d21dc83e499822594bd" and "122c120eae90f38085152c3accda34017bfba6af" have entirely different histories.

5 changed files with 6 additions and 93 deletions

View File

@ -1 +1 @@
__version__ = "0.12.0" __version__ = "0.11.1"

View File

@ -1,9 +1,8 @@
from django import forms from django import forms
from django_scopes.forms import SafeModelChoiceField, SafeModelMultipleChoiceField from django_scopes.forms import SafeModelChoiceField, SafeModelMultipleChoiceField
from i18nfield.forms import I18nModelForm from i18nfield.forms import I18nModelForm
from pretalx.person.models import User
from .models import Assignee, MusicrateSettings, Rating from .models import MusicrateSettings, Rating
class MusicrateSettingsForm(I18nModelForm): class MusicrateSettingsForm(I18nModelForm):
@ -57,23 +56,3 @@ class RatingForm(forms.ModelForm):
class Meta: class Meta:
model = Rating model = Rating
fields = ("rating",) fields = ("rating",)
class AssigneeForm(forms.ModelForm):
def __init__(self, *args, submission=None, **kwargs):
try:
self.instance = Assignee.objects.get(submission=submission)
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)
)
)
class Meta:
model = Assignee
fields = ("user",)
widgets = {"user": forms.Select(attrs={"class": "select2"})}

View File

@ -1,22 +0,0 @@
{% 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>
{% endblock %}

View File

@ -1,7 +1,6 @@
from django.urls import include, path from django.urls import include, path
from .views import ( from .views import (
AssigneeView,
ExportView, ExportView,
JoinView, JoinView,
MayAdvanceView, MayAdvanceView,
@ -13,26 +12,14 @@ from .views import (
urlpatterns = [ urlpatterns = [
path( path(
"orga/event/<slug:event>/", "orga/event/<slug:event>/settings/p/pretalx_musicrate/",
include( include(
[ [
path( path("", MusicrateSettingsView.as_view(), name="settings.musicrate"),
"settings/p/pretalx_musicrate/",
MusicrateSettingsView.as_view(),
name="settings.musicrate",
),
path(
"p/pretalx_musicrate/",
include(
[
path("<code>/", AssigneeView.as_view(), name="assignee"),
path("export/", ExportView.as_view(), name="export"), path("export/", ExportView.as_view(), name="export"),
] ]
), ),
), ),
]
),
),
path( path(
"<slug:event>/p/pretalx_musicrate/", "<slug:event>/p/pretalx_musicrate/",
include( include(

View File

@ -15,9 +15,8 @@ from django.views.generic import FormView, TemplateView, View
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from django_context_decorator import context from django_context_decorator import context
from pretalx.common.mixins.views import EventPermissionRequired from pretalx.common.mixins.views import EventPermissionRequired
from pretalx.submission.models import Submission
from .forms import AssigneeForm, MusicrateSettingsForm, RatingForm from .forms import MusicrateSettingsForm, RatingForm
from .models import Juror, Rating from .models import Juror, Rating
youtube_re = re.compile( youtube_re = re.compile(
@ -440,33 +439,3 @@ class ExportView(EventPermissionRequired, View):
] ]
) )
return response return response
class AssigneeView(EventPermissionRequired, FormView, SingleObjectMixin):
form_class = AssigneeForm
model = Submission
permission_required = "orga.change_submissions"
slug_field = "code"
slug_url_kwarg = "code"
template_name = "pretalx_musicrate/assignee.html"
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs["submission"] = self.object
return kwargs
def get_success_url(self):
return self.request.path
def form_valid(self, form):
form.save()
messages.success(self.request, _("Saved!"))
return super().form_valid(form)
def get(self, *args, **kwargs):
self.object = self.get_object()
return super().get(*args, **kwargs)
def post(self, *args, **kwargs):
self.object = self.get_object()
return super().post(*args, **kwargs)