Beispiel #1
0
 def _process_POST(self):
     old_values = layout_settings.get_all(self.event)
     ret = self._process_request()
     new_values = layout_settings.get_all(self.event)
     # Skip `timetable_theme_settings` as they are dynamically generated from themes.yaml
     changes = {k: (old_values[k], v) for k, v in new_values.iteritems()
                if old_values[k] != v and k != 'timetable_theme_settings'}
     if changes:
         form_cls = ConferenceLayoutForm if self.event.type_ == EventType.conference else LectureMeetingLayoutForm
         form = form_cls(event=self.event)
         self.event.log(EventLogRealm.participants, EventLogKind.change, 'Layout', summary='Layout was updated',
                        user=session.user, data={'Changes': make_diff_log(changes, form.log_fields_metadata)})
     return ret
Beispiel #2
0
    def _process(self):
        defaults = FormDefaults(**layout_settings.get_all(self._conf))
        form = LayoutForm(obj=defaults, event=self.event)
        css_form = CSSForm()
        logo_form = LogoForm()

        if form.validate_on_submit():
            data = {
                unicode(key): value
                for key, value in form.data.iteritems()
                if key in layout_settings.defaults
            }
            layout_settings.set_multi(self._conf, data)
            if form.theme.data == '_custom':
                layout_settings.set(self._conf, 'use_custom_css', True)
            flash(_('Settings saved'), 'success')
            return redirect(url_for('event_layout.index', self._conf))
        else:
            if self.event.logo_metadata:
                logo_form.logo.data = _logo_data(self.event)
            if self.event.has_stylesheet:
                css_form.css_file.data = _css_file_data(self.event)
        return WPLayoutEdit.render_template('layout.html',
                                            self._conf,
                                            form=form,
                                            event=self._conf,
                                            logo_form=logo_form,
                                            css_form=css_form)
Beispiel #3
0
    def run(self, new_event, cloners, shared_data):
        for col in ('logo_metadata', 'logo', 'stylesheet_metadata', 'stylesheet'):
            setattr(new_event, col, getattr(self.old_event, col))

        layout_settings.set_multi(new_event, layout_settings.get_all(self.old_event, no_defaults=True))
        if layout_settings.get(self.old_event, 'use_custom_menu'):
            for menu_entry in MenuEntry.get_for_event(self.old_event):
                self._copy_menu_entry(menu_entry, new_event)
        db.session.flush()
Beispiel #4
0
    def clone(self, new_event, options):
        if self.event.getType() != 'conference':
            # for meetings/lecture we want to keep the default timetable style in all cases
            theme = layout_settings.get(self.event, 'timetable_theme')
            if theme is not None:
                layout_settings.set(new_event, 'timetable_theme', theme)
            return

        if 'layout' not in options:
            return

        for col in ('logo_metadata', 'logo', 'stylesheet_metadata', 'stylesheet'):
            setattr(new_event.as_event, col, getattr(self.event.as_event, col))

        layout_settings.set_multi(new_event, layout_settings.get_all(self.event, no_defaults=True))
        if layout_settings.get(self.event, 'use_custom_menu'):
            for menu_entry in MenuEntry.get_for_event(self.event):
                self._copy_menu_entry(menu_entry, new_event, new_event.as_event.menu_entries)
        db.session.flush()
Beispiel #5
0
    def _process(self):
        defaults = FormDefaults(**layout_settings.get_all(self._conf))
        form = LayoutForm(obj=defaults, event=self.event_new)
        css_form = CSSForm()
        logo_form = LogoForm()

        if form.validate_on_submit():
            data = {unicode(key): value for key, value in form.data.iteritems() if key in layout_settings.defaults}
            layout_settings.set_multi(self._conf, data)
            if form.theme.data == '_custom':
                layout_settings.set(self._conf, 'use_custom_css', True)
            flash(_('Settings saved'), 'success')
            return redirect(url_for('event_layout.index', self._conf))
        else:
            if self.event_new.logo_metadata:
                logo_form.logo.data = self.event_new
            if self.event_new.has_stylesheet:
                css_form.css_file.data = self.event_new
        return WPLayoutEdit.render_template('layout.html', self._conf, form=form, event=self.event_new,
                                            logo_form=logo_form, css_form=css_form)
Beispiel #6
0
    def _process(self):
        defaults = FormDefaults(**layout_settings.get_all(self._conf))
        form = LayoutForm(obj=defaults, event=self.event)
        css_form = CSSForm()
        logo_form = LogoForm()

        if form.validate_on_submit():
            data = {unicode(key): value for key, value in form.data.iteritems() if key in layout_settings.defaults}
            layout_settings.set_multi(self._conf, data)
            if form.theme.data == "_custom":
                layout_settings.set(self._conf, "use_custom_css", True)
            flash(_("Settings saved"), "success")
            return redirect(url_for("event_layout.index", self._conf))
        else:
            if self.event.logo_metadata:
                logo_form.logo.data = _logo_data(self.event)
            if self.event.has_stylesheet:
                css_form.css_file.data = _css_file_data(self.event)
        return WPLayoutEdit.render_template(
            "layout.html", self._conf, form=form, event=self._conf, logo_form=logo_form, css_form=css_form
        )
Beispiel #7
0
    def clone(self, new_event, options):
        if self.event.getType() != 'conference':
            # for meetings/lecture we want to keep the default timetable style in all cases
            theme = layout_settings.get(self.event, 'timetable_theme')
            if theme is not None:
                layout_settings.set(new_event, 'timetable_theme', theme)
            return

        if 'layout' not in options:
            return

        for col in ('logo_metadata', 'logo', 'stylesheet_metadata',
                    'stylesheet'):
            setattr(new_event.as_event, col, getattr(self.event.as_event, col))

        layout_settings.set_multi(
            new_event, layout_settings.get_all(self.event, no_defaults=True))
        if layout_settings.get(self.event, 'use_custom_menu'):
            for menu_entry in MenuEntry.get_for_event(self.event):
                self._copy_menu_entry(menu_entry, new_event,
                                      new_event.as_event.menu_entries)
        db.session.flush()
Beispiel #8
0
 def _get_form_defaults(self):
     defaults = FormDefaults(**layout_settings.get_all(self.event))
     defaults.timetable_theme = self.event.theme
     return defaults
Beispiel #9
0
 def _get_form_defaults(self):
     defaults = FormDefaults(**layout_settings.get_all(self.event_new))
     defaults.timetable_theme = self.event_new.theme
     return defaults