Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
@cached_property
def object(self):
return self.get_object()
@context
def submission(self):
return self.object
class SubmissionStateChange(SubmissionViewMixin, TemplateView):
permission_required = "orga.change_submission_state"
template_name = "orga/submission/state_change.html"
TARGETS = {
"submit": SubmissionStates.SUBMITTED,
"accept": SubmissionStates.ACCEPTED,
"reject": SubmissionStates.REJECTED,
"confirm": SubmissionStates.CONFIRMED,
"delete": SubmissionStates.DELETED,
"withdraw": SubmissionStates.WITHDRAWN,
"cancel": SubmissionStates.CANCELED,
}
@cached_property
def _target(self) -> str:
"""Returns one of
submit|accept|reject|confirm|delete|withdraw|cancel."""
return self.TARGETS[self.request.resolver_match.url_name.split(".")[-1]]
@context
def target(self):
]
public_fields = ["title", "abstract", "description", "image"]
widgets = {
"abstract": MarkdownWidget,
"description": MarkdownWidget,
"notes": MarkdownWidget,
}
field_classes = {
"submission_type": SafeModelChoiceField,
"track": SafeModelChoiceField,
}
class SubmissionFilterForm(forms.Form):
state = forms.MultipleChoiceField(
choices=SubmissionStates.get_choices(),
required=False,
widget=CheckboxMultiDropdown,
)
submission_type = forms.MultipleChoiceField(
required=False, widget=CheckboxMultiDropdown
)
track = forms.MultipleChoiceField(required=False, widget=CheckboxMultiDropdown)
def __init__(self, event, *args, **kwargs):
self.event = event
usable_states = kwargs.pop("usable_states", None)
super().__init__(*args, **kwargs)
qs = event.submissions
state_qs = Submission.all_objects.filter(event=event)
if usable_states:
qs = qs.filter(state__in=usable_states)
def _set_slot_count(self, instance=None):
if not self.event.settings.present_multiple_times:
self.fields.pop("slot_count", None)
elif (
"slot_count" in self.fields
and instance
and instance.state
in [SubmissionStates.ACCEPTED, SubmissionStates.CONFIRMED]
):
self.fields["slot_count"].disabled = True
self.fields["slot_count"].help_text += " " + str(
_(
"Please contact the organisers if you want to change how often you're presenting this submission."
)
def get_object(self):
obj = self.request.event.submissions.filter(
review_code=self.kwargs["slug"],
state__in=[
SubmissionStates.SUBMITTED,
SubmissionStates.ACCEPTED,
SubmissionStates.CONFIRMED,
],
).first()
if obj:
return obj
raise Http404()
:class:`~pretalx.submission.models.submission.Submission` objects this
:class:`~pretalx.person.models.user.User` still has to review for the
given :class:`~pretalx.event.models.event.Event`.
Excludes submissions this user has submitted, and takes track
:class:`~pretalx.event.models.organiser.Team` permissions into account.
The result is ordered by review count.
:type event: :class:`~pretalx.event.models.event.Event`
:type user: :class:`~pretalx.person.models.user.User`
:rtype: Queryset of :class:`~pretalx.submission.models.submission.Submission` objects
"""
from pretalx.submission.models import SubmissionStates
queryset = (
event.submissions.filter(state=SubmissionStates.SUBMITTED)
.exclude(reviews__user=user)
.exclude(speakers__in=[user])
.annotate(review_count=models.Count("reviews"))
)
limit_tracks = user.teams.filter(
models.Q(all_events=True)
| models.Q(models.Q(all_events=False) & models.Q(limit_events__in=[event])),
limit_tracks__isnull=False,
)
if limit_tracks.exists():
tracks = set()
for team in limit_tracks:
tracks.update(team.limit_tracks.filter(event=event))
queryset = queryset.filter(track__in=tracks)
if ignore:
queryset = queryset.exclude(pk__in=[submission.pk for submission in ignore])
def get_speakers(self, obj):
request = self.context.get("request")
has_slots = (
obj.slots.filter(is_visible=True)
and obj.state == SubmissionStates.CONFIRMED
)
has_permission = request and request.user.has_perm(
"orga.view_speakers", request.event
)
if has_slots or has_permission:
return SubmitterSerializer(
obj.speakers.all(), many=True, context={"request": request}
).data
return []
def get_queryset(self):
return (
self.request.event.submissions.select_related("submission_type")
.prefetch_related("speakers")
.filter(
state__in=[
SubmissionStates.ACCEPTED,
SubmissionStates.CONFIRMED,
SubmissionStates.SUBMITTED,
]
def get_object(self):
obj = self.request.event.submissions.filter(
review_code=self.kwargs["slug"],
state__in=[
SubmissionStates.SUBMITTED,
SubmissionStates.ACCEPTED,
SubmissionStates.CONFIRMED,
],
).first()
if obj:
return obj
raise Http404()
def can_be_accepted(user, obj):
return obj and SubmissionStates.ACCEPTED in SubmissionStates.valid_next_states.get(
obj.state, []
)
def get_queryset(self):
return (
self.request.event.submissions.select_related("submission_type")
.prefetch_related("speakers")
.filter(
state__in=[
SubmissionStates.ACCEPTED,
SubmissionStates.CONFIRMED,
SubmissionStates.SUBMITTED,
]