def _render_template_list(target, event=None): tpl = get_template_module('designer/_list.html') default_ticket = get_default_ticket_on_category(target) if isinstance(target, Category) else None default_badge = get_default_badge_on_category(target) if isinstance(target, Category) else None not_deletable = get_not_deletable_templates(target) return tpl.render_template_list(target.designer_templates, target, event=event, default_ticket=default_ticket, default_badge=default_badge, inherited_templates=get_inherited_templates(target), not_deletable_templates=not_deletable)
def _process(self): templates = get_inherited_templates(self.target) not_deletable = get_not_deletable_templates(self.target) default_ticket = get_default_ticket_on_category(self.target) if isinstance(self.target, Category) else None default_badge = get_default_badge_on_category(self.target) if isinstance(self.target, Category) else None signals.event.filter_selectable_badges.send(type(self), badge_templates=templates) signals.event.filter_selectable_badges.send(type(self), badge_templates=not_deletable) return self._render_template('list.html', inherited_templates=templates, not_deletable_templates=not_deletable, default_ticket=default_ticket, default_badge=default_badge)
def _process(self): template = DesignerTemplate.get_or_404(request.view_args['template_id']) all_badge_templates = [tpl for tpl in get_all_templates(self.category) if tpl.type == TemplateType.badge and not tpl.is_ticket] if template not in all_badge_templates: raise Exception('Invalid template') if template == self.category.default_badge_template: # already the default -> clear it self.category.default_badge_template = None elif template == get_default_badge_on_category(self.category, only_inherited=True): # already the inherited default -> clear it instead of setting it explicitly self.category.default_badge_template = None else: self.category.default_badge_template = template if self.category.is_root and not self.category.default_badge_template: raise Exception('Cannot clear default ticket template on root category') return jsonify_data(html=_render_template_list(self.category))