Exemple #1
0
def generate_ticket(registration):
    template = (registration.registration_form.ticket_template or
                get_default_template_on_category(registration.event.category))
    signals.event.designer.print_badge_template.send(template, regform=registration.registration_form)
    pdf_class = RegistrantsListToBadgesPDFFoldable if template.backside_template else RegistrantsListToBadgesPDF
    pdf = pdf_class(template, DEFAULT_TICKET_PRINTING_SETTINGS, registration.event, [registration.id])
    return pdf.get_pdf()
Exemple #2
0
def _render_template_list(target, event=None):
    tpl = get_template_module('designer/_list.html')
    default_template = get_default_template_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_template=default_template,
                                    inherited_templates=get_inherited_templates(target),
                                    not_deletable_templates=not_deletable)
Exemple #3
0
def _render_template_list(target, event=None):
    tpl = get_template_module('designer/_list.html')
    default_template = get_default_template_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_template=default_template,
                                    inherited_templates=get_inherited_templates(target),
                                    not_deletable_templates=not_deletable)
Exemple #4
0
def generate_ticket(registration):
    template = (registration.registration_form.ticket_template or
                get_default_template_on_category(registration.event.category))
    signals.event.designer.print_badge_template.send(
        template, regform=registration.registration_form)
    pdf_class = RegistrantsListToBadgesPDFFoldable if template.backside_template else RegistrantsListToBadgesPDF
    pdf = pdf_class(template, DEFAULT_TICKET_PRINTING_SETTINGS,
                    registration.event, [registration.id])
    return pdf.get_pdf()
Exemple #5
0
def generate_ticket(registration):
    from indico.modules.designer.util import get_default_template_on_category
    from indico.modules.events.registration.controllers.management.tickets import DEFAULT_TICKET_PRINTING_SETTINGS
    template = (registration.registration_form.ticket_template or
                get_default_template_on_category(registration.event.category))
    signals.event.designer.print_badge_template.send(template, regform=registration.registration_form)
    pdf_class = RegistrantsListToBadgesPDFFoldable if template.backside_template else RegistrantsListToBadgesPDF
    pdf = pdf_class(template, DEFAULT_TICKET_PRINTING_SETTINGS, registration.event, [registration.id])
    return pdf.get_pdf()
Exemple #6
0
def generate_ticket(registration):
    from indico.modules.designer.util import get_default_template_on_category
    from indico.modules.events.registration.controllers.management.tickets import DEFAULT_TICKET_PRINTING_SETTINGS
    template = (registration.registration_form.ticket_template or
                get_default_template_on_category(registration.event.category))
    signals.event.designer.print_badge_template.send(template, regform=registration.registration_form)
    pdf_class = RegistrantsListToBadgesPDFFoldable if template.backside_template else RegistrantsListToBadgesPDF
    pdf = pdf_class(template, DEFAULT_TICKET_PRINTING_SETTINGS, registration.event, [registration.id])
    return pdf.get_pdf()
Exemple #7
0
 def __init__(self, *args, **kwargs):
     event = kwargs.pop('event')
     super(EventSettingsForm, self).__init__(*args, **kwargs)
     default_tpl = get_default_template_on_category(event.category)
     all_templates = set(event.designer_templates) | get_inherited_templates(event)
     badge_templates = [(tpl.id, tpl.title) for tpl in all_templates
                        if tpl.type == TemplateType.badge and tpl != default_tpl]
     # Show the default template first
     badge_templates.insert(0, (default_tpl.id, '{} ({})'.format(default_tpl.title, _('Default category template'))))
     self.ticket_template_id.choices = badge_templates
Exemple #8
0
 def __init__(self, *args, **kwargs):
     event = kwargs.pop('event')
     super(TicketsForm, self).__init__(*args, **kwargs)
     default_tpl = get_default_template_on_category(event.category)
     all_templates = set(event.designer_templates) | get_inherited_templates(event)
     badge_templates = [(tpl.id, tpl.title) for tpl in all_templates
                        if tpl.type == TemplateType.badge and tpl != default_tpl]
     # Show the default template first
     badge_templates.insert(0, (default_tpl.id, '{} ({})'.format(default_tpl.title, _('Default category template'))))
     self.ticket_template_id.choices = badge_templates
Exemple #9
0
 def _process(self):
     templates = get_inherited_templates(self.target)
     not_deletable = get_not_deletable_templates(self.target)
     default_template = get_default_template_on_category(
         self.target) if isinstance(self.target, Category) else None
     return self._render_template(
         'list.html',
         inherited_templates=templates,
         not_deletable_templates=not_deletable,
         default_template=default_template,
     )
Exemple #10
0
 def _process(self):
     templates = get_inherited_templates(self.target)
     not_deletable = get_not_deletable_templates(self.target)
     default_template = get_default_template_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_template=default_template)
Exemple #11
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))
Exemple #12
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))
def generate_ticket(registration):
    """Mostly copied from indico.module.events.registration.utils, but different ticket
       template resolution
    """

    from indico.modules.designer.util import get_default_template_on_category
    from indico.modules.events.registration.controllers.management.tickets import DEFAULT_TICKET_PRINTING_SETTINGS
    # default is A4

    template = print_checkin_event_settings.get(registration.event,
                                                'ticket_template')
    if not template:
        template = (registration.registration_form.ticket_template
                    or get_default_template_on_category(
                        registration.event.category))

    signals.event.designer.print_badge_template.send(
        template, regform=registration.registration_form)
    pdf_class = RegistrantsListToBadgesPDFFoldable if template.backside_template else RegistrantsListToBadgesPDF
    pdf = pdf_class(template, DEFAULT_TICKET_PRINTING_SETTINGS,
                    registration.event, [registration.id])
    return pdf.get_pdf()
Exemple #14
0
 def _process(self):
     templates = get_inherited_templates(self.target)
     not_deletable = get_not_deletable_templates(self.target)
     default_template = get_default_template_on_category(self.target) if isinstance(self.target, Category) else None
     return self._render_template('list.html', inherited_templates=templates, not_deletable_templates=not_deletable,
                                  default_template=default_template,)