pc-coholic / pretix-googlepaypasses

[Work in Progress] Support for Google Pay Passes/Walletobjects in pretix
Other
2 stars 1 forks source link

No preview in control possible #2

Open pc-coholic opened 6 years ago

pc-coholic commented 6 years ago

When using the preview ticket option I get this Dijango error

ERROR 2018-10-31 15:03:48,024 django.request log Internal Server Error: /control/event/LordBonzi/rulzc/settings/tickets/preview/googlepaypasses
Traceback (most recent call last):
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/control/permissions.py", line 27, in wrapper
    return function(request, *args, **kw)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/control/views/event.py", line 670, in get
    fname, mimet, data = tickets.preview(self.request.event.pk, self.output.identifier)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/base/services/tickets.py", line 100, in preview
    return prov.generate(p)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix_googlepaypasses-1.0.0-py3.6.egg/pretix_googlepaypasses/googlepaypasses.py", line 98, in generate
    tpl_html = get_template('pretix_googlepaypasses/downloadfallback.html')
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: pretix_googlepaypasses/downloadfallback.html
ERROR 2018-10-31 15:03:48,024 django.request log Internal Server Error: /control/event/LordBonzi/rulzc/settings/tickets/preview/googlepaypasses
Traceback (most recent call last):
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/control/permissions.py", line 27, in wrapper
    return function(request, *args, **kw)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/control/views/event.py", line 670, in get
    fname, mimet, data = tickets.preview(self.request.event.pk, self.output.identifier)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/base/services/tickets.py", line 100, in preview
    return prov.generate(p)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix_googlepaypasses-1.0.0-py3.6.egg/pretix_googlepaypasses/googlepaypasses.py", line 98, in generate
    tpl_html = get_template('pretix_googlepaypasses/downloadfallback.html')
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: pretix_googlepaypasses/downloadfallback.html

When testing it with a "real" (Brought via shop) ticket I get this

ERROR 2018-10-31 15:37:15,932 django.request log Internal Server Error: /LordBonzi/rulzc/order/order/secret/
Traceback (most recent call last):
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/base.py", line 169, in render
    with context.bind_template(self):
  File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__                              return next(self.gen)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/context.py", line 246, in bind_template
    updates.update(processor(self.request))
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/presale/context.py", line 46, in contextprocessor
    for receiver, response in html_head.send(request.event, request=request):
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/base/signals.py", line 70, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix_googlepaypasses-1.0.0-py3.6.egg/pretix_googlepaypasses/signals.py", line 60, in html_head_presale
    template = get_template('pretix_googlepaypasses/presale_head.html')
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: pretix_googlepaypasses/presale_head.html

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
    response = response.render()
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
    content = template.render(context, self._request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 63, in render
    reraise(exc, self.backend)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 84, in reraise
    raise new from exc
django.template.exceptions.TemplateDoesNotExist: pretix_googlepaypasses/presale_head.html
ERROR 2018-10-31 15:37:15,932 django.request log Internal Server Error: /LordBonzi/rulzc/order/order/secret/
Traceback (most recent call last):
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/base.py", line 169, in render
    with context.bind_template(self):
  File "/usr/lib/python3.6/contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/context.py", line 246, in bind_template
    updates.update(processor(self.request))
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/presale/context.py", line 46, in contextprocessor
    for receiver, response in html_head.send(request.event, request=request):
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix/base/signals.py", line 70, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/var/pretix/venv/lib/python3.6/site-packages/pretix_googlepaypasses-1.0.0-py3.6.egg/pretix_googlepaypasses/signals.py", line 60, in html_head_presale
    template = get_template('pretix_googlepaypasses/presale_head.html')
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: pretix_googlepaypasses/presale_head.html

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
    response = response.render()
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
    content = template.render(context, self._request)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 63, in render
    reraise(exc, self.backend)
  File "/var/pretix/venv/lib/python3.6/site-packages/django/template/backends/django.py", line 84, in reraise
    raise new from exc
django.template.exceptions.TemplateDoesNotExist: pretix_googlepaypasses/presale_head.html

Originally posted by @LordBonzi in https://github.com/pc-coholic/pretix-googlepaypasses/issues/1#issuecomment-434730283

pc-coholic commented 6 years ago

Background from #1:

I do not know, why the template is not found - but even if it was found, so far the Preview-Feature is not properly implemented yet.

Some technical background:

A regular ticketgenerator-plugin has a generate()-method, that takes an orderPosition as parameter and returns the generated ticket for the passed position. When you click the download-button in the frontend, <url of the order>/<orderposition>/<generatorname> is navigated to, and the above generate()-function is called, and you get your ticket. If you click on the preview-button in the backend, the function is called but a fake orderPosition is passed.

However, this plugin is doing things a little bit different in order to allow participants to give informed consent before having their data transmitted to Google.

The generate()-function for this plugin is generally not being called except as a fallback. In the frontend, clicks on the Download-Button are being rewritten to display a modal message that includes a button to <url of the order>/<orderposition>/googlepaypasses/generate (instead of the original <url of the order>/<orderposition>/googlepaypasses. Calling the URL without the /generate will show the consent-message, assuming that the user hasn't seen it (disabled Javascript, etc.).

That means, that we're pretty much ignoring whatever orderPosition is passed to generate(). Only when calling /generate, we extract the orderPosition from the URL, generate the pass and return it to the user.

So this is also the reason, why the preview-feature wouldn't work - even if the template was found: we would only return a HTML-file with the consent-message, linking to a /generate that won't be doing anything.

Long story, short: As of now, if you want to see a pass, you have to generate it through the frontend.

But see - that's one of the reasons I was reluctant to upload all the resources to have this half-done plugin run into this kind of issues ;)

pc-coholic commented 6 years ago

With recent changes to pretix, it seems like calling the Preview will not cause the reported error anymore.

However, as it is customary for this plugin, the download-fallback page is rendered and offered for download.

At this point, I'll relabel this issue as enhancement, display a corresponding message that previews are not available, and move the implementation of the preview-mode to a later date.

As the passed orderPosition is fictitious, the "click this button to get your pass"-button won't be functional, as the system will try to lookup an order with the ID "PREVIEW1234" and a random secret - but obviously failing.