Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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)
Beispiel #5
0
    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)
Beispiel #6
0
    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)
Beispiel #7
0
    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)