Пример #1
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)
Пример #2
0
 def _process(self):
     page = request.args.get('page', '1')
     order_columns = {
         'start_dt': Event.start_dt,
         'title': db.func.lower(Event.title)
     }
     direction = 'desc' if request.args.get('desc', '1') == '1' else 'asc'
     order_column = order_columns[request.args.get('order', 'start_dt')]
     query = (Event.query.with_parent(self.category).options(
         joinedload('series'), undefer_group('series'),
         load_only('id', 'category_id', 'created_dt', 'end_dt',
                   'protection_mode', 'start_dt', 'title', 'type_',
                   'series_pos', 'series_count', 'visibility')).order_by(
                       getattr(order_column,
                               direction)()).order_by(Event.id))
     if page == 'all':
         events = query.paginate(show_all=True)
     else:
         events = query.paginate(page=int(page))
     return WPCategoryManagement.render_template(
         'management/content.html',
         self.category,
         'content',
         subcategories=self.category.children,
         events=events,
         page=page,
         order_column=request.args.get('order', 'start_dt'),
         direction=direction)
Пример #3
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)
Пример #4
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)
Пример #5
0
 def _process(self):
     page = request.args.get('page', '1')
     order_columns = {'start_dt': Event.start_dt, 'title': db.func.lower(Event.title)}
     direction = 'desc' if request.args.get('desc', '1') == '1' else 'asc'
     order_column = order_columns[request.args.get('order', 'start_dt')]
     query = (Event.query.with_parent(self.category)
              .options(joinedload('series'), undefer_group('series'),
                       load_only('id', 'category_id', 'created_dt',  'end_dt', 'protection_mode',  'start_dt',
                                 'title', 'type_', 'series_pos', 'series_count'))
              .order_by(getattr(order_column, direction)())
              .order_by(Event.id))
     if page == 'all':
         events = query.paginate(show_all=True)
     else:
         events = query.paginate(page=int(page))
     return WPCategoryManagement.render_template('management/content.html', self.category, 'content',
                                                 subcategories=self.category.children,
                                                 events=events, page=page,
                                                 order_column=request.args.get('order', 'start_dt'),
                                                 direction=direction)
Пример #6
0
 def _process(self):
     form = CategoryProtectionForm(obj=self._get_defaults(),
                                   category=self.category)
     if form.validate_on_submit():
         update_permissions(self.category, form)
         update_category_protection(
             self.category, {
                 'protection_mode': form.protection_mode.data,
                 'own_no_access_contact': form.own_no_access_contact.data,
                 'event_creation_mode': form.event_creation_mode.data,
                 'visibility': form.visibility.data
             })
         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)
Пример #7
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)
Пример #8
0
 def _process(self):
     return WPCategoryManagement.render_template('management/roles.html',
                                                 self.category,
                                                 'roles',
                                                 roles=_get_roles(
                                                     self.category))
Пример #9
0
 def getJSFiles(self):
     return WPCategoryManagement.getJSFiles(
         self) + self._asset_env['modules_designer_js'].urls()
Пример #10
0
 def getJSFiles(self):
     return WPCategoryManagement.getJSFiles(self) + self._asset_env['modules_designer_js'].urls()
Пример #11
0
 def _process(self):
     return WPCategoryManagement.render_template(
         'management/moderation.html', self.category, 'moderation')