Allow to access not-yet-live shop on different domain

This commit is contained in:
Raphael Michel
2017-01-05 11:50:10 +01:00
parent f6d8b825d5
commit d3f21353ca
5 changed files with 82 additions and 9 deletions

View File

@@ -3,12 +3,21 @@
{% load eventurl %}
{% block title %}{{ request.event.name }}{% endblock %}
{% block content %}
<h1>
{{ request.event.name }}
<a href="{% eventurl request.event "presale:event.index" %}" class="btn btn-default btn-sm" target="_blank">
{% trans "Go to shop" %}
</a>
</h1>
<form action="{% eventurl request.event "presale:event.auth" %}" method="post" target="_blank">
<h1>
{{ request.event.name }}
{% if has_domain and not request.event.live %}
<input type="hidden" value="{{ new_session }}" name="session">
<button type="submit" class="btn btn-default btn-sm">
{% trans "Go to shop" %}
</button>
{% else %}
<a href="{% eventurl request.event "presale:event.index" %}" class="btn btn-default btn-sm" target="_blank">
{% trans "Go to shop" %}
</a>
{% endif %}
</h1>
</form>
{% if actions|length > 0 %}
<div class="panel panel-danger">

View File

@@ -1,5 +1,7 @@
from decimal import Decimal
from importlib import import_module
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.db.models import Sum
@@ -17,6 +19,7 @@ from pretix.control.signals import (
from ..logdisplay import OVERVIEW_BLACKLIST
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore
NUM_WIDGET = '<div class="numwidget"><span class="num">{num}</span><span class="text">{text}</span></div>'
@@ -167,11 +170,21 @@ def event_index(request, organizer, event):
a_qs = request.event.requiredaction_set.filter(done=False)
has_domain = request.event.organizer.domains.exists()
ctx = {
'widgets': rearrange(widgets),
'logs': qs[:5],
'actions': a_qs[:5] if request.eventperm.can_change_orders else []
'actions': a_qs[:5] if request.eventperm.can_change_orders else [],
'has_domain': has_domain
}
if not request.event.live and has_domain:
s = SessionStore()
s['pretix_event_access_{}'.format(request.event.pk)] = request.session.session_key
s.create()
ctx['new_session'] = s.session_key
for a in ctx['actions']:
a.display = a.display(request)