Пример #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(
                        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=reminder,
                                           form=form)
Пример #2
0
 def _process(self):
     reminders = EventReminder.query.with_parent(self.event_new).order_by(
         EventReminder.scheduled_dt.desc()).all()
     return WPReminders.render_template('reminders.html',
                                        self._conf,
                                        event=self.event_new,
                                        reminders=reminders)
Пример #3
0
 def _process(self):
     reminders = EventReminder.find(event_id=self.event.id).order_by(
         EventReminder.scheduled_dt.desc()).all()
     tz = get_timezone(DisplayTZ(conf=self.event).getDisplayTZ())
     return WPReminders.render_template('reminders.html',
                                        self.event,
                                        event=self.event,
                                        reminders=reminders,
                                        timezone=tz)
Пример #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 {}: {}'.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)
Пример #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(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=reminder,
                                           form=form)
Пример #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
        )
Пример #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)
Пример #8
0
 def _process(self):
     reminders = EventReminder.find(event_id=self.event.id).order_by(EventReminder.scheduled_dt.desc()).all()
     tz = get_timezone(DisplayTZ(conf=self.event).getDisplayTZ())
     return WPReminders.render_template('reminders.html', self.event, event=self.event, reminders=reminders,
                                        timezone=tz)
Пример #9
0
 def _process(self):
     reminders = EventReminder.query.with_parent(self.event).order_by(EventReminder.scheduled_dt.desc()).all()
     return WPReminders.render_template('reminders.html', self.event, reminders=reminders)
Пример #10
0
 def _process(self):
     reminders = EventReminder.query.with_parent(self.event_new).order_by(EventReminder.scheduled_dt.desc()).all()
     return WPReminders.render_template("reminders.html", self._conf, event=self.event_new, reminders=reminders)