Exemplo n.º 1
0
    def _process(self):
        badge_templates = sorted((tpl
                                  for tpl in get_all_templates(self.event_new)
                                  if tpl.type.name == 'badge'),
                                 key=attrgetter('title'))
        settings = event_badge_settings.get_all(self.event_new.id)
        form = BadgeSettingsForm(self.event_new,
                                 template=self.template_id,
                                 **settings)
        registrations = self.registrations or self.regform.registrations

        if form.validate_on_submit():
            data = form.data
            data.pop('submitted', None)
            template_id = data.pop('template')
            if data.pop('save_values'):
                event_badge_settings.set_multi(self.event_new, data)
            data['registration_ids'] = [x.id for x in registrations]

            key = unicode(uuid.uuid4())
            badge_cache.set(key, data, time=1800)
            download_url = url_for('.registrations_print_badges',
                                   self.regform,
                                   template_id=template_id,
                                   uuid=key)
            return jsonify_data(flash=False, redirect=download_url)
        return jsonify_template(
            'events/registration/management/print_badges.html',
            event=self.event_new,
            regform=self.regform,
            settings_form=form,
            templates=badge_templates,
            registrations=registrations)
Exemplo n.º 2
0
 def _process(self):
     template = DesignerTemplate.get_one(request.view_args['template_id'])
     if template not in get_all_templates(self.category):
         raise Exception('Invalid template')
     if template == self.category.default_ticket_template:
         # already the default -> clear it
         self.category.default_ticket_template = None
     elif template == get_default_template_on_category(self.category, only_inherited=True):
         # already the inherited default -> clear it instead of setting it explicitly
         self.category.default_ticket_template = None
     else:
         self.category.default_ticket_template = template
     if self.category.is_root and not self.category.default_ticket_template:
         raise Exception('Cannot clear default ticket template on root category')
     return jsonify_data(html=_render_template_list(self.category))
Exemplo n.º 3
0
 def _process(self):
     template = DesignerTemplate.get_one(request.view_args['template_id'])
     if template not in get_all_templates(self.category):
         raise Exception('Invalid template')
     if template == self.category.default_ticket_template:
         # already the default -> clear it
         self.category.default_ticket_template = None
     elif template == get_default_template_on_category(self.category, only_inherited=True):
         # already the inherited default -> clear it instead of setting it explicitly
         self.category.default_ticket_template = None
     else:
         self.category.default_ticket_template = template
     if self.category.is_root and not self.category.default_ticket_template:
         raise Exception('Cannot clear default ticket template on root category')
     return jsonify_data(html=_render_template_list(self.category))