Add improved UI if no event can be created

This commit is contained in:
Raphael Michel
2017-01-07 14:25:01 +01:00
parent 2336505309
commit 2182a4e361
2 changed files with 34 additions and 17 deletions

View File

@@ -6,22 +6,33 @@
<h1>{% trans "Create a new event" %} <small>{% blocktrans trimmed with step=wizard.steps.step1 %} <h1>{% trans "Create a new event" %} <small>{% blocktrans trimmed with step=wizard.steps.step1 %}
Step {{ step }} Step {{ step }}
{% endblocktrans %}</small></h1> {% endblocktrans %}</small></h1>
<form action="" method="post" class="form-horizontal"> {% if has_organizer %}
{% csrf_token %} <form action="" method="post" class="form-horizontal">
{{ wizard.management_form }} {% csrf_token %}
{% bootstrap_form_errors form %} {{ wizard.management_form }}
{% block form %} {% bootstrap_form_errors form %}
{% endblock %} {% block form %}
<div class="form-group submit-group"> {% endblock %}
{% if wizard.steps.prev %} <div class="form-group submit-group">
<button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}" {% if wizard.steps.prev %}
class="btn btn-default btn-lg pull-left"> <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}"
{% trans "Back" %} class="btn btn-default btn-lg pull-left">
{% trans "Back" %}
</button>
{% endif %}
<button type="submit" class="btn btn-primary btn-save">
{% trans "Continue" %}
</button> </button>
{% endif %} </div>
<button type="submit" class="btn btn-primary btn-save"> </form>
{% trans "Continue" %} {% else %}
</button> <div class="alert alert-danger">
{% trans "Every event needs to be created as part of an organizer account. Currently, you do not have access to any organizer accounts." %}
</div> </div>
</form> {% if request.user.is_superuser %}
<a href="{% url "control:organizers.add" %}" class="btn btn-default">
{% trans "Create a new organizer" %}
</a>
{% endif %}
{% endif %}
{% endblock %} {% endblock %}

View File

@@ -7,7 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from django.views.generic import ListView from django.views.generic import ListView
from formtools.wizard.views import SessionWizardView from formtools.wizard.views import SessionWizardView
from pretix.base.models import Event, EventPermission from pretix.base.models import Event, EventPermission, OrganizerPermission
from pretix.control.forms.event import ( from pretix.control.forms.event import (
EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm, EventWizardBasicsForm, EventWizardCopyForm, EventWizardFoundationForm,
) )
@@ -48,6 +48,12 @@ class EventWizard(SessionWizardView):
'copy': condition_copy 'copy': condition_copy
} }
def get_context_data(self, form, **kwargs):
ctx = super().get_context_data(form, **kwargs)
ctx['has_organizer'] = OrganizerPermission.objects.filter(user=self.request.user,
can_create_events=True).exists()
return ctx
def get_form_kwargs(self, step=None): def get_form_kwargs(self, step=None):
kwargs = { kwargs = {
'user': self.request.user 'user': self.request.user