Allow to hide payment methods behind a secret link

This commit is contained in:
Raphael Michel
2020-02-05 18:09:27 +01:00
parent b387fba5f4
commit e83b8ac218
4 changed files with 92 additions and 2 deletions

View File

@@ -53,6 +53,8 @@ event_patterns = [
csrf_exempt(pretix.presale.views.cart.CartAdd.as_view()),
name='event.cart.add'),
url(r'unlock/(?P<hash>[a-z0-9]{64})/$', pretix.presale.views.user.UnlockHashView.as_view(),
name='event.payment.unlock'),
url(r'resend/$', pretix.presale.views.user.ResendLinkView.as_view(), name='event.resend_link'),
url(r'^order/(?P<order>[^/]+)/(?P<secret>[A-Za-z0-9]+)/open/(?P<hash>[a-z0-9]+)/$', pretix.presale.views.order.OrderOpen.as_view(),

View File

@@ -5,6 +5,7 @@ from django.contrib import messages
from django.shortcuts import redirect
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
from django.views import View
from django.views.generic import TemplateView
from pretix.base.email import get_email_context
@@ -60,3 +61,13 @@ class ResendLinkView(EventViewMixin, TemplateView):
context = super().get_context_data(**kwargs)
context['form'] = self.link_form
return context
class UnlockHashView(EventViewMixin, View):
# Allows to register an unlock hash in the user's session, e.g. to unlock a hidden payment provider
def get(self, request, *args, **kwargs):
hashes = request.session.get('pretix_unlock_hashes', [])
hashes.append(kwargs.get('hash'))
request.session['pretix_unlock_hashes'] = hashes
return redirect(eventreverse(self.request.event, 'presale:event.index'))