def send(self): if self.sent: raise Exception( 'This mail has been sent already. It cannot be sent again.') body_md = bleach.linkify( bleach.clean(markdown.markdown(self.text), tags=bleach.ALLOWED_TAGS + ['p', 'pre'])) html_context = { 'body': body_md, 'event': self.event, 'color': self.event.primary_color or '#1c4a3b', } body_html = get_template('mail/mailwrapper.html').render(html_context) from pretalx.common.mail import mail_send_task mail_send_task.apply_async( kwargs={ 'to': self.to.split(','), 'subject': self.subject, 'body': self.text, 'html': body_html, 'sender': self.reply_to, 'event': self.event.pk, 'cc': (self.cc or '').split(','), 'bcc': (self.bcc or '').split(','), }) self.sent = now() if self.pk: self.save()
def send_orga_mail(self, text, stats=False): from django.utils.translation import override from pretalx.common.mail import mail_send_task from pretalx.mail.models import QueuedMail context = { 'event_dashboard': self.orga_urls.base.full(), 'event_review': self.orga_urls.reviews.full(), 'event_schedule': self.orga_urls.schedule.full(), 'event_submissions': self.orga_urls.submissions.full(), 'event_team': self.orga_urls.team_settings.full(), 'submission_count': self.submissions.all().count(), } if stats: context.update({ 'talk_count': self.current_schedule.talks.filter(is_visible=True).count(), 'reviewer_count': self.permissions.filter(is_reviewer=True).count(), 'review_count': self.reviews.count(), 'schedule_count': self.schedules.count() - 1, 'mail_count': self.queued_mails.filter(sent__isnull=False).count(), }) with override(self.locale): text = str(text).format(**context) + '-- ' text += _(''' This mail was sent to you by the content system of your event {name}.''').format(name=self.name) mail_send_task.apply_async(kwargs={ 'to': [self.email], 'subject': _('[{slug}] News from your content system').format(slug=self.slug), 'body': text, 'html': QueuedMail.text_to_html(text, event=self), })
def send_update_notification_email(): gs = GlobalSettings() if not gs.settings.update_check_email: return mail_send_task.apply_async( kwargs={ "to": [gs.settings.update_check_email], "subject": _("pretalx update available"), "body": str( LazyI18nString.from_gettext( gettext_noop( "Hi!\n\nAn update is available for pretalx or for one of the plugins you installed in your " "pretalx installation at {base_url}.\nPlease follow this link for more information:\n\n {url} \n\n" "You can always find information on the latest updates in the changelog:\n\n" " https://docs.pretalx.org/changelog.html\n\n" "Larger updates are also announced with upgrade notes on the pretalx.com blog:\n\n" " https://pretalx.com/p/news" "\n\nBest regards,\nyour pretalx developers" ), ) ).format( base_url=settings.SITE_URL, url=settings.SITE_URL + reverse("orga:admin.update"), ), "html": None, } )
def post(self, request, event): email = request.POST.get('email') event = request.event invitation_token = get_random_string( allowed_chars=string.ascii_lowercase + string.digits, length=20) invitation_link = build_absolute_uri('orga:invitation.view', kwargs={'code': invitation_token}) EventPermission.objects.create( event=event, invitation_email=email, invitation_token=invitation_token, is_orga=True, ) invitation_text = _('''Hi! You have been invited to the orga crew of {event} - Please click here to accept: {invitation_link} See you there, The {event} orga crew (minus you)''').format(event=event.name, invitation_link=invitation_link) mail_send_task.apply_async(args=( [email], _('You have been invited to the orga crew of {event}').format( event=request.event.name), invitation_text, request.event.email, event.pk)) request.event.log_action('pretalx.event.invite.orga.send', person=request.user, orga=True) messages.success( request, _('<{email}> has been invited to your team - more team members help distribute the workload, so … yay!' ).format(email=email)) return redirect(request.event.orga_urls.team_settings)
def send(self): if self.sent: raise Exception( _('This mail has been sent already. It cannot be sent again.')) has_event = getattr(self, 'event', None) text = self.make_text(self.text, event=has_event) body_html = self.make_html(text) from pretalx.common.mail import mail_send_task mail_send_task.apply_async( kwargs={ 'to': self.to.split(','), 'subject': self.make_subject(self.subject, event=has_event), 'body': text, 'html': body_html, 'reply_to': (self.reply_to or '').split(',') or ( [self.event.email] if has_event else None), 'event': self.event.pk if has_event else None, 'cc': (self.cc or '').split(','), 'bcc': (self.bcc or '').split(','), }) self.sent = now() if self.pk: self.save()
def send(self, requestor=None, orga=True): if self.sent: raise Exception(_('This mail has been sent already. It cannot be sent again.')) has_event = getattr(self, 'event', None) text = self.make_text(self.text, event=has_event) body_html = self.make_html(text) from pretalx.common.mail import mail_send_task to = (self.to or '').split(',') if self.id: to += [user.email for user in self.to_users.all()] mail_send_task.apply_async( kwargs={ 'to': to, 'subject': self.make_subject(self.subject, event=has_event), 'body': text, 'html': body_html, 'reply_to': (self.reply_to or '').split(',') or ([self.event.email] if has_event else None), 'event': self.event.pk if has_event else None, 'cc': (self.cc or '').split(','), 'bcc': (self.bcc or '').split(','), } ) self.sent = now() if self.pk: self.log_action( 'pretalx.mail.sent', person=requestor, orga=orga, data={'to_users': [(user.pk, user.email) for user in self.to_users.all()]}, ) self.save()
def send(self): from pretalx.common.mail import mail_send_task mail_send_task.apply_async( kwargs={ 'to': [self.to], 'subject': self.subject, 'body': self.text, 'sender': self.reply_to, 'event': self.event.pk, }) # TODO: log if self.pk: self.delete()
def send(self, requestor=None, orga: bool = True): """Sends an email. :param requestor: The user issuing the command. Used for logging. :type requestor: :class:`~pretalx.person.models.user.User` :param orga: Was this email sent as by a privileged user?""" if self.sent: raise Exception( _('This mail has been sent already. It cannot be sent again.')) has_event = getattr(self, 'event', None) text = self.make_text(self.text, event=has_event) body_html = self.make_html(text) from pretalx.common.mail import mail_send_task to = (self.to or '').split(',') if self.id: to += [user.email for user in self.to_users.all()] mail_send_task.apply_async( kwargs={ 'to': to, 'subject': self.make_subject(self.subject, event=has_event), 'body': text, 'html': body_html, 'reply_to': (self.reply_to or '').split(',') or ( [self.event.email] if has_event else None), 'event': self.event.pk if has_event else None, 'cc': (self.cc or '').split(','), 'bcc': (self.bcc or '').split(','), }) self.sent = now() if self.pk: self.log_action( 'pretalx.mail.sent', person=requestor, orga=orga, data={ 'to_users': [(user.pk, user.email) for user in self.to_users.all()] }, ) self.save()
def send(self): if self.sent: raise Exception( 'This mail has been sent already. It cannot be sent again.') from pretalx.common.mail import mail_send_task mail_send_task.apply_async( kwargs={ 'to': self.to.split(','), 'subject': self.subject, 'body': self.text, 'sender': self.reply_to, 'event': self.event.pk, }) self.sent = now() self.save()
def send(self, requestor=None, orga: bool = True): """Sends an email. :param requestor: The user issuing the command. Used for logging. :type requestor: :class:`~pretalx.person.models.user.User` :param orga: Was this email sent as by a privileged user? """ if self.sent: raise Exception( _("This mail has been sent already. It cannot be sent again.") ) has_event = getattr(self, "event", None) text = self.make_text(self.text, event=has_event) body_html = self.make_html(text) from pretalx.common.mail import mail_send_task to = self.to.split(",") if self.to else [] if self.id: to += [user.email for user in self.to_users.all()] mail_send_task.apply_async( kwargs={ "to": to, "subject": self.make_subject(self.subject, event=has_event), "body": text, "html": body_html, "reply_to": (self.reply_to or "").split(","), "event": self.event.pk if has_event else None, "cc": (self.cc or "").split(","), "bcc": (self.bcc or "").split(","), } ) self.sent = now() if self.pk: self.log_action( "pretalx.mail.sent", person=requestor, orga=orga, data={ "to_users": [(user.pk, user.email) for user in self.to_users.all()] }, ) self.save()
def send(self): if self.sent: raise Exception( 'This mail has been sent already. It cannot be sent again.') body_html = self.text_to_html(self.text) from pretalx.common.mail import mail_send_task mail_send_task.apply_async( kwargs={ 'to': self.to.split(','), 'subject': self.subject, 'body': self.text, 'html': body_html, 'reply_to': self.reply_to or self.event.email, 'event': self.event.pk, 'cc': (self.cc or '').split(','), 'bcc': (self.bcc or '').split(','), }) self.sent = now() if self.pk: self.save()