Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field_name in self.Meta.public_fields:
field = self.fields.get(field_name)
if field:
field.original_help_text = getattr(field, "original_help_text", "")
field.added_help_text = getattr(field, "added_help_text", "") + str(
phrases.base.public_content
)
field.help_text = field.original_help_text + " " + field.added_help_text
if self.can_edit:
form.save()
self.qform.save()
result = self.save_formset(form.instance)
if not result:
return self.get(self.request, *self.args, **self.kwargs)
if form.has_changed():
if form.instance.pk and "duration" in form.changed_data:
form.instance.update_duration()
form.instance.log_action(
"pretalx.submission.update", person=self.request.user
)
self.request.event.cache.set("rebuild_schedule_export", True, None)
messages.success(self.request, phrases.base.saved)
else:
messages.error(self.request, phrases.cfp.submission_uneditable)
return redirect(self.object.urls.user_base)
event = models.ForeignKey(
to="event.Event", related_name="information", on_delete=models.CASCADE
)
include_submitters = models.BooleanField(
verbose_name=_("Include all submitters"),
help_text=_("Show to every submitter regardless of their submissions' status"),
default=False,
)
exclude_unconfirmed = models.BooleanField(
verbose_name=_("Exclude unconfirmed speakers"),
help_text=_("Show to speakers only once they have confirmed attendance"),
default=False,
)
title = I18nCharField(verbose_name=_("Subject"), max_length=200)
text = I18nTextField(verbose_name=_("Text"), help_text=phrases.base.use_markdown)
resource = models.FileField(
verbose_name=_("file"),
null=True,
blank=True,
help_text=_("Please try to keep your upload small, preferably below 16 MB."),
)
objects = ScopedManager(event="event")
class orga_urls(EventUrls):
base = edit = "{self.event.orga_urls.information}{self.pk}/"
delete = "{base}delete"
def done(self, request):
self.request = request
form = self.get_form(from_storage=True)
form.instance.event = self.event
form.save()
submission = form.instance
submission.speakers.add(request.user)
submission.log_action("pretalx.submission.create", person=request.user)
messages.success(request, phrases.cfp.submission_success)
additional_speaker = form.cleaned_data.get("additional_speaker").strip()
if additional_speaker:
try:
submission.send_invite(to=[additional_speaker], _from=request.user)
except SendMailException as exception:
logging.getLogger("").warning(str(exception))
messages.warning(self.request, phrases.cfp.submission_email_fail)
access_code = getattr(request, "access_code", None)
if access_code:
submission.access_code = access_code
submission.save()
access_code.redeemed += 1
access_code.save()
def get_success_url(self):
messages.success(self.request, phrases.orga.logged_in)
if self.event:
return self.event.orga_urls.base
return reverse("orga:event.list")
def dispatch(self, request, *args, **kwargs):
try:
self.user = User.objects.get(
pw_reset_token=kwargs.get("token"),
pw_reset_time__gte=now() - dt.timedelta(days=1),
)
except User.DoesNotExist:
messages.error(self.request, phrases.cfp.auth_reset_fail)
return redirect(reverse("orga:auth.reset"))
return super().dispatch(request, *args, **kwargs)