def extend_event_management_menu(self, sender, event, **kwargs):
     if event.can_manage(session.user):
         return SideMenuItem('BadgeOnCheckin',
                             _('Bagde On Checkin Printing'),
                             url_for_plugin('print_checkin.configure',
                                            event),
                             section='services')
Пример #2
0
class EventSettingsForm(IndicoForm):
    #event_specific_fields = ['webhookurl']
    webhookurl = URLField(_('webhook-url'), [DataRequired()], description=WEBHOOK_DESC)
    ticket_template_id = SelectField(_('Ticket template'), [DataRequired()], coerce=int)
    send_json =  BooleanField(_('Send data as JSON'), widget=SwitchWidget())


    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
    def send_pdf(self, registration):
        try:

            fname = 'print-' + str(registration.id) + '.pdf'
            files = {'file': (fname, pdf, 'application/pdf', {'Expires': '0'})}
            pdf = generate_ticket(registration)
            requests.post(self._wh_url(registration), files=files)
        except Exception as e:
            logger.warn(_('Could not print the checkin badge (%s)'), e)
 def _send_json(self, registration):
     try:
         event = registration.event
         fullreg = (event.registrations.filter_by(
             id=registration.id, is_deleted=False).options(
                 joinedload('data').joinedload(
                     'field_data')).first_or_404())
         data = self.build_registration_data(fullreg)
         requests.post(self._wh_url(registration),
                       data=json.dumps(data),
                       headers={'Content-Type': 'application/json'})
     except Exception as e:
         logger.warn(_('Could not send data (%s)'), e)
Пример #5
0
    def _process(self):
        form = EventSettingsForm(
            prefix='print_checkin-',
            event=self.event,
            obj=FormDefaults(
                **print_checkin_event_settings.get_all(self.event)))
        if form.validate_on_submit():

            print_checkin_event_settings.set_multi(self.event, form.data)
            flash(_('Settings saved'), 'success')
            return redirect(url_for('.configure', self.event))
        return WPPrintCheckinEventMgmt.render_template('printbagdemanage.html',
                                                       self.event,
                                                       form=form)
Пример #6
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