コード例 #1
0
ファイル: reglists.py プロジェクト: DavidAndreev/indico
    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)
コード例 #2
0
    def _process(self):
        all_templates = set(
            self.event.designer_templates) | get_inherited_templates(
                self.event)
        badge_templates = {
            tpl.id: {
                'data':
                tpl.data,
                'backside_tpl_id':
                tpl.backside_template_id,
                'orientation':
                'landscape'
                if tpl.data['width'] > tpl.data['height'] else 'portrait',
                'format':
                self._get_format(tpl)
            }
            for tpl in all_templates if tpl.type.name == 'badge'
        }
        settings = event_badge_settings.get_all(self.event.id)
        form = BadgeSettingsForm(self.event,
                                 template=self.template_id,
                                 **settings)
        registrations = self.registrations or self.regform.registrations
        if self.event.is_locked:
            del form.save_values

        if form.validate_on_submit():
            data = form.data
            if data['page_layout'] == PageLayout.foldable:
                data['top_margin'] = 0
                data['bottom_margin'] = 0
                data['left_margin'] = 0
                data['right_margin'] = 0
                data['margin_columns'] = 0
                data['margin_rows'] = 0
                data['dashed_border'] = False
            data.pop('submitted', None)
            template_id = data.pop('template')
            if data.pop('save_values', False):
                event_badge_settings.set_multi(self.event, 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,
                                redirect_no_loading=True)
        return jsonify_template(
            'events/registration/management/print_badges.html',
            event=self.event,
            regform=self.regform,
            settings_form=form,
            templates=badge_templates,
            registrations=registrations)
コード例 #3
0
ファイル: reglists.py プロジェクト: jas01/indico
    def _process(self):
        all_templates = set(self.event.designer_templates) | get_inherited_templates(self.event)
        badge_templates = {tpl.id: {
            'data': tpl.data,
            'backside_tpl_id': tpl.backside_template_id,
            'orientation': 'landscape' if tpl.data['width'] > tpl.data['height'] else 'portrait',
            'format': self._get_format(tpl)
        } for tpl in all_templates if tpl.type.name == 'badge'}
        settings = event_badge_settings.get_all(self.event.id)
        form = BadgeSettingsForm(self.event, template=self.template_id, tickets=self.TICKET_BADGES, **settings)
        all_registrations = [r for r in (self.registrations or self.regform.registrations) if r.is_active]
        registrations = self._filter_registrations(all_registrations)
        if self.event.is_locked:
            del form.save_values

        if form.validate_on_submit():
            data = form.data
            if data['page_layout'] == PageLayout.foldable:
                data['top_margin'] = 0
                data['bottom_margin'] = 0
                data['left_margin'] = 0
                data['right_margin'] = 0
                data['margin_columns'] = 0
                data['margin_rows'] = 0
                data['dashed_border'] = False
            data.pop('submitted', None)
            template_id = data.pop('template')
            if data.pop('save_values', False):
                event_badge_settings.set_multi(self.event, 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, redirect_no_loading=True)
        return jsonify_template('events/registration/management/print_badges.html', event=self.event,
                                regform=self.regform, settings_form=form, templates=badge_templates,
                                registrations=registrations, all_registrations=all_registrations)