|
|
|
@ -16,7 +16,7 @@ from django.views.generic.detail import SingleObjectMixin
|
|
|
|
|
from django_context_decorator import context
|
|
|
|
|
from pretalx.common.views.mixins import EventPermissionRequired
|
|
|
|
|
from pretalx.orga.views.submission import BaseSubmissionList, SubmissionList
|
|
|
|
|
from pretalx.submission.models import Submission
|
|
|
|
|
from pretalx.submission.models import Submission, SubmissionStates
|
|
|
|
|
|
|
|
|
|
from .forms import (
|
|
|
|
|
AssigneeForm,
|
|
|
|
@ -31,6 +31,25 @@ 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
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
submission
|
|
|
|
|
or submissions.filter(
|
|
|
|
|
submission_type__in=settings.submission_types.all(),
|
|
|
|
|
state=SubmissionStates.SUBMITTED,
|
|
|
|
|
)
|
|
|
|
|
.order_by("created")
|
|
|
|
|
.first()
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JoinView(TemplateView):
|
|
|
|
|
template_name = "pretalx_musicrate/join.html"
|
|
|
|
|
|
|
|
|
@ -57,14 +76,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 +98,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 +151,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 +164,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
|
|
|
|
@ -284,17 +292,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 +366,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
|
|
|
|
@ -410,7 +423,8 @@ class ExportView(EventPermissionRequired, View):
|
|
|
|
|
request.event.submissions.prefetch_related("answers")
|
|
|
|
|
.select_related("submission_type")
|
|
|
|
|
.filter(
|
|
|
|
|
submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all()
|
|
|
|
|
submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all(),
|
|
|
|
|
state=SubmissionStates.SUBMITTED,
|
|
|
|
|
)
|
|
|
|
|
.only("title", "submission_type__name")
|
|
|
|
|
.order_by("created")
|
|
|
|
|