Compare commits
No commits in common. "dcce8e54071162d813960d0e1ab99eb9bfc1441f" and "18af2a75e61c1666a14e6d91031beb2ebbe3babe" have entirely different histories.
dcce8e5407
...
18af2a75e6
|
@ -1 +1 @@
|
|||
__version__ = "2025.2.0.dev0"
|
||||
__version__ = "2025.1.0"
|
||||
|
|
|
@ -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, SubmissionStates
|
||||
from pretalx.submission.models import Submission
|
||||
|
||||
from .forms import (
|
||||
AssigneeForm,
|
||||
|
@ -31,25 +31,6 @@ 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"
|
||||
|
||||
|
@ -76,10 +57,14 @@ class JoinView(TemplateView):
|
|||
def get(self, request, *args, token, **kwargs):
|
||||
token_valid = self.validate_token(token)
|
||||
if self.juror is not None:
|
||||
submission = get_last_submission(
|
||||
self.request.event.pretalx_musicrate_settings,
|
||||
self.request.event.submissions,
|
||||
self.juror.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()
|
||||
)
|
||||
if submission is not None:
|
||||
return redirect(
|
||||
|
@ -98,10 +83,14 @@ class JoinView(TemplateView):
|
|||
event=self.request.event,
|
||||
last_submission=self.request.event.pretalx_musicrate_settings.last_submission,
|
||||
)
|
||||
submission = get_last_submission(
|
||||
self.request.event.pretalx_musicrate_settings,
|
||||
self.request.event.submissions,
|
||||
self.juror.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()
|
||||
)
|
||||
if submission is not None:
|
||||
return redirect(
|
||||
|
@ -151,9 +140,13 @@ class QRCodeView(EventPermissionRequired, TemplateView):
|
|||
},
|
||||
)
|
||||
)
|
||||
context["last_submission"] = get_last_submission(
|
||||
self.request.event.pretalx_musicrate_settings,
|
||||
self.request.event.submissions,
|
||||
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()
|
||||
)
|
||||
return context
|
||||
|
||||
|
@ -164,8 +157,7 @@ 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(),
|
||||
state=SubmissionStates.SUBMITTED,
|
||||
submission_type__in=self.request.event.pretalx_musicrate_settings.submission_types.all()
|
||||
)
|
||||
|
||||
@context
|
||||
|
@ -292,22 +284,17 @@ 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 (
|
||||
last_submission is not None
|
||||
and self.object.created > last_submission.created
|
||||
(settings := self.request.event.pretalx_musicrate_settings).last_submission
|
||||
is not None
|
||||
and self.object.created > settings.last_submission.created
|
||||
):
|
||||
return redirect(
|
||||
self.request.resolver_match.view_name,
|
||||
event=self.request.event.slug,
|
||||
token=self.juror.token,
|
||||
code=last_submission.code,
|
||||
code=settings.last_submission.code,
|
||||
)
|
||||
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
|
||||
|
@ -366,16 +353,16 @@ class PresenterView(EventPermissionRequired, SubmissionMixin, TemplateView):
|
|||
|
||||
def get(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
|
||||
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:
|
||||
if (
|
||||
(settings := self.request.event.pretalx_musicrate_settings).last_submission
|
||||
is None
|
||||
or self.object.created > settings.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
|
||||
|
@ -423,8 +410,7 @@ 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(),
|
||||
state=SubmissionStates.SUBMITTED,
|
||||
submission_type__in=request.event.pretalx_musicrate_settings.submission_types.all()
|
||||
)
|
||||
.only("title", "submission_type__name")
|
||||
.order_by("created")
|
||||
|
|
Loading…
Reference in New Issue