Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if request.user.is_authenticated:
request.user.locale = locale
request.user.save()
max_age = 10 * 365 * 24 * 60 * 60
resp.set_cookie(
settings.LANGUAGE_COOKIE_NAME,
locale,
max_age=max_age,
expires=(dt.datetime.utcnow() + dt.timedelta(seconds=max_age)).strftime(
"%a, %d-%b-%Y %H:%M:%S GMT"
),
domain=settings.SESSION_COOKIE_DOMAIN,
)
with override(locale):
messages.success(request, str(phrases.cfp.locale_change_success))
return resp
Best regards,
pretalx
"""
)
)
).format(
title=obj.title,
speakers=obj.display_speaker_names,
user=request.user.get_display_name(),
event_dashboard=request.event.orga_urls.base.full(),
url=obj.orga_urls.edit.full(),
)
)
obj.withdraw(person=request.user)
messages.success(self.request, phrases.cfp.submission_withdrawn)
else:
messages.error(self.request, phrases.cfp.submission_not_withdrawn)
return redirect("cfp:event.user.submissions", event=self.request.event.slug)
pretalx
"""
)
)
).format(
title=obj.title,
speakers=obj.display_speaker_names,
user=request.user.get_display_name(),
event_dashboard=request.event.orga_urls.base.full(),
url=obj.orga_urls.edit.full(),
)
)
obj.withdraw(person=request.user)
messages.success(self.request, phrases.cfp.submission_withdrawn)
else:
messages.error(self.request, phrases.cfp.submission_not_withdrawn)
return redirect("cfp:event.user.submissions", event=self.request.event.slug)
)
if request.event.settings.mail_on_new_submission:
MailTemplate(
event=request.event,
subject=_("New submission!").format(event=request.event.slug),
text=request.event.settings.mail_text_new_submission,
).to_mail(
user=request.event.email,
event=request.event,
context=template_context_from_submission(request.submission),
skip_queue=True,
locale=request.event.locale,
)
except SendMailException as exception:
logging.getLogger("").warning(str(exception))
messages.warning(request, phrases.cfp.submission_email_fail)
return redirect(
reverse("cfp:event.user.submissions", kwargs={"event": request.event.slug})
)
def post(self, request, *args, **kwargs):
submission = self.get_object()
submission.speakers.add(self.request.user)
submission.log_action(
"pretalx.submission.speakers.add", person=self.request.user
)
submission.save()
messages.success(self.request, phrases.cfp.invite_accepted)
return redirect("cfp:event.user.view", event=self.request.event.slug)
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs["submission"] = self.submission
kwargs["speaker"] = self.request.user
if "email" in self.request.GET and not self.request.method == "POST":
initial = kwargs.get("initial", {})
initial["speaker"] = urllib.parse.unquote(self.request.GET["email"])
kwargs["initial"] = initial
try:
validate_email(initial["speaker"])
except ValidationError:
messages.warning(self.request, phrases.cfp.invite_invalid_email)
return kwargs
user = form.cleaned_data["user"]
if not user or (
user.pw_reset_time
and (now() - user.pw_reset_time).total_seconds() < 3600 * 24
):
messages.success(self.request, phrases.cfp.auth_password_reset)
return redirect(self.get_success_url())
try:
user.reset_password(event=getattr(self.request, "event", None))
except SendMailException:
messages.error(self.request, phrases.base.error_sending_mail)
return self.get(self.request, *self.args, **self.kwargs)
messages.success(self.request, phrases.cfp.auth_password_reset)
user.log_action("pretalx.user.password.reset")
return redirect(self.get_success_url())
def form_valid(self, form):
submission = self.submission
if self.request.user.has_perm("submission.confirm_submission", submission):
submission.confirm(person=self.request.user)
messages.success(self.request, phrases.cfp.submission_confirmed)
elif submission.state == SubmissionStates.CONFIRMED:
messages.success(self.request, phrases.cfp.submission_was_confirmed)
else:
messages.error(self.request, phrases.cfp.submission_not_confirmed)
return redirect("cfp:event.user.submissions", event=self.request.event.slug)
def form_valid(self, form):
self.user.set_password(form.cleaned_data["password"])
self.user.pw_reset_token = None
self.user.pw_reset_time = None
self.user.save()
messages.success(self.request, phrases.cfp.auth_reset_success)
return redirect(
reverse("cfp:event.login", kwargs={"event": self.request.event.slug})
)
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()
request.submission = submission