Example #1
0
    def _process(self):
        defaults = FormDefaults(
            self.category,
            meeting_theme=self.category.default_event_themes['meeting'],
            lecture_theme=self.category.default_event_themes['lecture'])
        form = CategorySettingsForm(obj=defaults, category=self.category)
        icon_form = CategoryIconForm(obj=self.category)
        logo_form = CategoryLogoForm(obj=self.category)

        if form.validate_on_submit():
            update_category(self.category,
                            form.data,
                            skip={'meeting_theme', 'lecture_theme'})
            self.category.default_event_themes = {
                'meeting': form.meeting_theme.data,
                'lecture': form.lecture_theme.data
            }
            flash(_("Category settings saved!"), 'success')
            return redirect(url_for('.manage_settings', self.category))
        else:
            if self.category.icon_metadata:
                icon_form.icon.data = self.category
            if self.category.logo_metadata:
                logo_form.logo.data = self.category
        return WPCategoryManagement.render_template('management/settings.html',
                                                    self.category,
                                                    'settings',
                                                    form=form,
                                                    icon_form=icon_form,
                                                    logo_form=logo_form)
Example #2
0
 def _process(self):
     form = CategoryProtectionForm(obj=self._get_defaults(),
                                   category=self.category)
     if form.validate_on_submit():
         update_category(
             self.category, {
                 'protection_mode': form.protection_mode.data,
                 'own_no_access_contact': form.own_no_access_contact.data,
                 'event_creation_restricted':
                 form.event_creation_restricted.data,
                 'visibility': form.visibility.data
             })
         update_object_principals(self.category,
                                  form.acl.data,
                                  read_access=True)
         update_object_principals(self.category,
                                  form.managers.data,
                                  full_access=True)
         update_object_principals(self.category,
                                  form.event_creators.data,
                                  role='create')
         flash(_('Protection settings of the category have been updated'),
               'success')
         return redirect(url_for('.manage_protection', self.category))
     return WPCategoryManagement.render_template(
         'management/category_protection.html',
         self.category,
         'protection',
         form=form)
Example #3
0
 def _process(self):
     form = CategoryProtectionForm(obj=self._get_defaults(), category=self.category)
     if form.validate_on_submit():
         update_category(self.category,
                         {'protection_mode': form.protection_mode.data,
                          'own_no_access_contact': form.own_no_access_contact.data,
                          'event_creation_restricted': form.event_creation_restricted.data})
         update_object_principals(self.category, form.acl.data, read_access=True)
         update_object_principals(self.category, form.managers.data, full_access=True)
         update_object_principals(self.category, form.event_creators.data, role='create')
         flash(_('Protection settings of the category have been updated'), 'success')
         return redirect(url_for('.manage_protection', self.category))
     return WPCategoryManagement.render_template('management/category_protection.html', self.category, 'protection',
                                                 form=form)
Example #4
0
    def _process(self):
        defaults = FormDefaults(self.category,
                                meeting_theme=self.category.default_event_themes['meeting'],
                                lecture_theme=self.category.default_event_themes['lecture'])
        form = CategorySettingsForm(obj=defaults, category=self.category)
        icon_form = CategoryIconForm(obj=self.category)
        logo_form = CategoryLogoForm(obj=self.category)

        if form.validate_on_submit():
            update_category(self.category, form.data, skip={'meeting_theme', 'lecture_theme'})
            self.category.default_event_themes = {
                'meeting': form.meeting_theme.data,
                'lecture': form.lecture_theme.data
            }
            flash(_("Category settings saved!"), 'success')
            return redirect(url_for('.manage_settings', self.category))
        else:
            if self.category.icon_metadata:
                icon_form.icon.data = self.category
            if self.category.logo_metadata:
                logo_form.logo.data = self.category
        return WPCategoryManagement.render_template('management/settings.html', self.category, 'settings', form=form,
                                                    icon_form=icon_form, logo_form=logo_form)