def _process(self): reminder = self.reminder form = ReminderForm(obj=self._get_defaults(), event=self.event) if form.validate_on_submit(): if reminder.is_sent: flash( _("This reminder has already been sent and cannot be modified anymore." ), 'error') return redirect(url_for('.edit', reminder)) form.populate_obj(reminder, existing_only=True) if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder modified by %s: %s', session.user, reminder) flash( _("The reminder at {} has been modified.").format( to_unicode(format_datetime(reminder.scheduled_dt))), 'success') return jsonify_data(flash=False) return jsonify_template('events/reminders/edit_reminder.html', event=self.event, reminder=reminder, form=form)
def send_event_reminders(): reminders = EventReminder.find_all(~EventReminder.is_sent, ~Event.is_deleted, EventReminder.scheduled_dt <= now_utc(), _join=EventReminder.event) for reminder in reminders: logger.info('Sending event reminder: %s', reminder) reminder.send() db.session.commit()
def _process(self): if self.reminder.is_sent: flash(_('Sent reminders cannot be deleted.'), 'error') else: db.session.delete(self.reminder) logger.info('Reminder deleted by %s: %s', session.user, self.reminder) flash(_("The reminder at {} has been deleted.") .format(to_unicode(format_datetime(self.reminder.scheduled_dt))), 'success') return redirect(url_for('.list', self.event_new))
def send_event_reminders(): reminders = (EventReminder.query.filter( ~EventReminder.is_sent, ~Event.is_deleted, EventReminder.scheduled_dt <= now_utc()).join( EventReminder.event).all()) for reminder in reminders: logger.info('Sending event reminder: %s', reminder) reminder.send() db.session.commit()
def _process(self): if self.reminder.is_sent: flash(_('Sent reminders cannot be deleted.'), 'error') else: db.session.delete(self.reminder) logger.info('Reminder deleted by {}: {}'.format(session.user, self.reminder)) flash(_("The reminder at {} has been deleted.").format(format_datetime(self.reminder.scheduled_dt)), 'success') return redirect(url_for('.list', self.event))
def send(self): """Sends the reminder to its recipients.""" self.is_sent = True recipients = self.all_recipients if not recipients: logger.info('Notification %s has no recipients; not sending anything', self) return email_tpl = make_reminder_email(self.event, self.include_summary, self.include_description, self.message) email = make_email(bcc_list=recipients, from_address=self.reply_to_address, template=email_tpl) send_email(email, self.event, 'Reminder', self.creator)
def _process(self): if self.reminder.is_sent: flash(_("Sent reminders cannot be deleted."), "error") else: db.session.delete(self.reminder) logger.info("Reminder deleted by {}: {}".format(session.user, self.reminder)) flash( _("The reminder at {} has been deleted.").format(format_datetime(self.reminder.scheduled_dt)), "success" ) return redirect(url_for(".list", self.event))
def send(self): """Sends the reminder to its recipients.""" self.is_sent = True recipients = self.all_recipients if not recipients: logger.info('Notification %s has no recipients; not sending anything', self) return email_tpl = make_reminder_email(self.event_new, self.include_summary, self.message) email = make_email(bcc_list=recipients, from_address=self.reply_to_address, template=email_tpl) send_email(email, self.event_new, 'Reminder', self.creator)
def send_event_reminders(): reminders = EventReminder.find_all(~EventReminder.is_sent, EventReminder.scheduled_dt <= now_utc()) try: for reminder in reminders: logger.info('Sending event reminder: {}'.format(reminder)) reminder.send() finally: # If we fail at any point during the loop, we'll still commit # the is_sent change for already-sent reminders instead of # sending them over and over and thus spamming people. db.session.commit() DBMgr.getInstance().commit() # only needed for event email logs
def send_event_reminders(): reminders = EventReminder.find_all(~EventReminder.is_sent, ~Event.is_deleted, EventReminder.scheduled_dt <= now_utc(), _join=EventReminder.event_new) try: for reminder in reminders: logger.info('Sending event reminder: %s', reminder) reminder.send() finally: # If we fail at any point during the loop, we'll still commit # the is_sent change for already-sent reminders instead of # sending them over and over and thus spamming people. db.session.commit()
def _process(self): form = ReminderForm(event=self.event, schedule_type='relative', attach_ical=True) if form.validate_on_submit(): reminder = EventReminder(creator=session.user, event=self.event) form.populate_obj(reminder, existing_only=True) db.session.add(reminder) db.session.flush() if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder created by %s: %s', session.user, reminder) flash(_('A reminder at {} has been created.') .format(format_datetime(reminder.scheduled_dt)), 'success') return jsonify_data(flash=False) return jsonify_template('events/reminders/edit_reminder.html', event=self.event, reminder=None, form=form)
def _process(self): form = ReminderForm(event=self.event, schedule_type='relative') if form.validate_on_submit(): reminder = EventReminder(creator=session.user, event=self.event) form.populate_obj(reminder, existing_only=True) db.session.add(reminder) db.session.flush() if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder created by {}: {}'.format(session.user, reminder)) flash(_("A reminder at {} has been created.").format(format_datetime(reminder.scheduled_dt)), 'success') return redirect(url_for('.list', self.event)) return WPReminders.render_template('edit_reminder.html', self.event, event=self.event, reminder=None, form=form, widget_attrs=form.default_widget_attrs)
def _process(self): form = ReminderForm(event=self.event, schedule_type='relative') if form.validate_on_submit(): reminder = EventReminder(creator=session.user, event=self.event) form.populate_obj(reminder, existing_only=True) db.session.add(reminder) db.session.flush() if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder created by %s: %s', session.user, reminder) flash(_("A reminder at {} has been created.") .format(to_unicode(format_datetime(reminder.scheduled_dt))), 'success') return jsonify_data(flash=False) return jsonify_template('events/reminders/edit_reminder.html', event=self.event, reminder=None, form=form, widget_attrs=form.default_widget_attrs)
def send(self): """Send the reminder to its recipients.""" self.is_sent = True recipients = self.all_recipients if not recipients: logger.info('Notification %s has no recipients; not sending anything', self) return email_tpl = make_reminder_email(self.event, self.include_summary, self.include_description, self.message) attachments = [] if self.attach_ical: event_ical = event_to_ical(self.event, skip_access_check=True, method='REQUEST', organizer=(core_settings.get('site_title'), config.NO_REPLY_EMAIL)) attachments.append(MIMECalendar('event.ics', event_ical)) for recipient in recipients: email = self._make_email(recipient, email_tpl, attachments) send_email(email, self.event, 'Reminder', self.creator, log_metadata={'reminder_id': self.id})
def _process(self): reminder = self.reminder form = ReminderForm(obj=self._get_defaults(), event=self.event) if form.validate_on_submit(): if reminder.is_sent: flash(_("This reminder has already been sent and cannot be modified anymore."), 'error') return redirect(url_for('.edit', reminder)) form.populate_obj(reminder, existing_only=True) if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder modified by %s: %s', session.user, reminder) flash(_("The reminder at {} has been modified.") .format(to_unicode(format_datetime(reminder.scheduled_dt))), 'success') return jsonify_data(flash=False) return jsonify_template('events/reminders/edit_reminder.html', event=self.event, reminder=reminder, form=form)
def send(self): """Send the reminder to its recipients.""" self.is_sent = True recipients = self.all_recipients if not recipients: logger.info( 'Notification %s has no recipients; not sending anything', self) return email_tpl = make_reminder_email(self.event, self.include_summary, self.include_description, self.message) attachments = [] if self.attach_ical: event_ical = event_to_ical(self.event) attachments.append(('event.ics', event_ical, 'text/calendar')) email = make_email(bcc_list=recipients, from_address=self.reply_to_address, template=email_tpl, attachments=attachments) send_email(email, self.event, 'Reminder', self.creator)
def _process(self): reminder = self.reminder form = ReminderForm(obj=self._get_defaults(), event=self.event) if form.validate_on_submit(): if reminder.is_sent: flash(_("This reminder has already been sent and cannot be modified anymore."), 'error') return redirect(url_for('.edit', reminder)) form.populate_obj(reminder, existing_only=True) if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder modified by {}: {}'.format(session.user, reminder)) flash(_("The reminder at {} has been modified.").format(format_datetime(reminder.scheduled_dt)), 'success') return redirect(url_for('.list', self.event)) widget_attrs = ({field.short_name: {'disabled': True} for field in form} if reminder.is_sent else form.default_widget_attrs) return WPReminders.render_template('edit_reminder.html', self.event, event=self.event, reminder=reminder, form=form, widget_attrs=widget_attrs)
def _process(self): form = ReminderForm(event=self.event, schedule_type='relative') if form.validate_on_submit(): reminder = EventReminder(creator=session.user, event=self.event) form.populate_obj(reminder, existing_only=True) db.session.add(reminder) db.session.flush() if form.schedule_type.data == 'now': _send_reminder(reminder) else: logger.info('Reminder created by %s: %s', session.user, reminder) flash( _("A reminder at {} has been created.").format( format_datetime(reminder.scheduled_dt)), 'success') return redirect(url_for('.list', self.event)) return WPReminders.render_template( 'edit_reminder.html', self.event, event=self.event, reminder=None, form=form, widget_attrs=form.default_widget_attrs)
def _send_reminder(reminder): """Send reminder immediately""" reminder.send() logger.info('Reminder sent by {}: {}'.format(session.user, reminder)) flash(_('The reminder has been sent.'), 'success')
def _send_reminder(reminder): """Send reminder immediately""" reminder.send() logger.info("Reminder sent by {}: {}".format(session.user, reminder)) flash(_("The reminder has been sent."), "success")
def _send_reminder(reminder): """Send reminder immediately.""" reminder.send() logger.info('Reminder sent by %s: %s', session.user, reminder) flash(_('The reminder has been sent.'), 'success')