forked from CGM_Public/pretix_original
Refs #96 -- Completely removed local users
This commit is contained in:
@@ -1,227 +0,0 @@
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import authenticate
|
||||
from django.contrib.auth.forms import \
|
||||
AuthenticationForm as BaseAuthenticationForm
|
||||
from django.core.validators import RegexValidator
|
||||
from django.forms import Form
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from pretix.base.models import User
|
||||
|
||||
|
||||
class LoginForm(BaseAuthenticationForm):
|
||||
username = forms.CharField(
|
||||
label=_('Username'),
|
||||
help_text=(
|
||||
_('If you registered for multiple events, your username is your email address.')
|
||||
if settings.PRETIX_GLOBAL_REGISTRATION
|
||||
else None
|
||||
)
|
||||
)
|
||||
password = forms.CharField(
|
||||
label=_('Password'),
|
||||
widget=forms.PasswordInput
|
||||
)
|
||||
|
||||
error_messages = {
|
||||
'invalid_login': _("Please enter a correct username and password."),
|
||||
'inactive': _("This account is inactive."),
|
||||
}
|
||||
|
||||
def __init__(self, request=None, *args, **kwargs):
|
||||
self.request = request
|
||||
self.user_cache = None
|
||||
super(forms.Form, self).__init__(*args, **kwargs)
|
||||
|
||||
def clean(self):
|
||||
username = self.cleaned_data.get('username')
|
||||
password = self.cleaned_data.get('password')
|
||||
|
||||
if username and password:
|
||||
if '@' in username:
|
||||
identifier = username.lower()
|
||||
else:
|
||||
identifier = "%s@%s.event.pretix" % (username, self.request.event.identity)
|
||||
self.user_cache = authenticate(identifier=identifier,
|
||||
password=password)
|
||||
if self.user_cache is None:
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['invalid_login'],
|
||||
code='invalid_login',
|
||||
)
|
||||
else:
|
||||
self.confirm_login_allowed(self.user_cache)
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
|
||||
class GlobalRegistrationForm(forms.Form):
|
||||
error_messages = {
|
||||
'duplicate_email': _("You already registered with that e-mail address, please use the login form."),
|
||||
'pw_mismatch': _("Please enter the same password twice"),
|
||||
}
|
||||
email = forms.EmailField(
|
||||
label=_('Email address'),
|
||||
required=True
|
||||
)
|
||||
password = forms.CharField(
|
||||
label=_('Password'),
|
||||
widget=forms.PasswordInput,
|
||||
required=True
|
||||
)
|
||||
password_repeat = forms.CharField(
|
||||
label=_('Repeat password'),
|
||||
widget=forms.PasswordInput
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
password1 = self.cleaned_data.get('password')
|
||||
password2 = self.cleaned_data.get('password_repeat')
|
||||
|
||||
if password1 and password1 != password2:
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['pw_mismatch'],
|
||||
code='pw_mismatch',
|
||||
)
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
def clean_email(self):
|
||||
email = self.cleaned_data['email']
|
||||
if User.objects.filter(identifier=email).exists():
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['duplicate_email'],
|
||||
code='duplicate_email',
|
||||
)
|
||||
return email
|
||||
|
||||
|
||||
class LocalRegistrationForm(forms.Form):
|
||||
error_messages = {
|
||||
'invalid_username': _("Please only use characters, numbers or ./+/-/_ in your username."),
|
||||
'duplicate_username': _("This username is already taken. Please choose a different one."),
|
||||
'pw_mismatch': _("Please enter the same password twice"),
|
||||
}
|
||||
username = forms.CharField(
|
||||
label=_('Username'),
|
||||
validators=[
|
||||
RegexValidator(
|
||||
regex='^[a-zA-Z0-9\.+\-_]*$',
|
||||
code='invalid_username',
|
||||
message=error_messages['invalid_username']
|
||||
),
|
||||
],
|
||||
required=True
|
||||
)
|
||||
email = forms.EmailField(
|
||||
label=_('E-mail address'),
|
||||
required=False
|
||||
)
|
||||
password = forms.CharField(
|
||||
label=_('Password'),
|
||||
widget=forms.PasswordInput,
|
||||
required=True
|
||||
)
|
||||
password_repeat = forms.CharField(
|
||||
label=_('Repeat password'),
|
||||
widget=forms.PasswordInput
|
||||
)
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.request = request
|
||||
self.fields['email'].required = request.event.settings.user_mail_required
|
||||
|
||||
def clean(self):
|
||||
password1 = self.cleaned_data.get('password')
|
||||
password2 = self.cleaned_data.get('password_repeat')
|
||||
|
||||
if password1 and password1 != password2:
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['pw_mismatch'],
|
||||
code='pw_mismatch',
|
||||
)
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
def clean_username(self):
|
||||
username = self.cleaned_data['username']
|
||||
if User.objects.filter(event=self.request.event, username=username).exists():
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['duplicate_username'],
|
||||
code='duplicate_username',
|
||||
)
|
||||
return username
|
||||
|
||||
|
||||
class PasswordRecoverForm(Form):
|
||||
error_messages = {
|
||||
'pw_mismatch': _("Please enter the same password twice"),
|
||||
}
|
||||
password = forms.CharField(
|
||||
label=_('Password'),
|
||||
widget=forms.PasswordInput,
|
||||
required=True
|
||||
)
|
||||
password_repeat = forms.CharField(
|
||||
label=_('Repeat password'),
|
||||
widget=forms.PasswordInput
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def clean(self):
|
||||
password1 = self.cleaned_data.get('password')
|
||||
password2 = self.cleaned_data.get('password_repeat')
|
||||
|
||||
if password1 and password1 != password2:
|
||||
raise forms.ValidationError(
|
||||
self.error_messages['pw_mismatch'],
|
||||
code='pw_mismatch',
|
||||
)
|
||||
|
||||
return self.cleaned_data
|
||||
|
||||
|
||||
class PasswordForgotForm(Form):
|
||||
username = forms.CharField(
|
||||
label=_('Username or E-mail'),
|
||||
)
|
||||
|
||||
def __init__(self, event, *args, **kwargs):
|
||||
self.event = event
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def clean_username(self):
|
||||
username = self.cleaned_data['username']
|
||||
try:
|
||||
self.cleaned_data['user'] = User.objects.get(
|
||||
identifier=username, event__isnull=True
|
||||
)
|
||||
return username
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
try:
|
||||
self.cleaned_data['user'] = User.objects.get(
|
||||
username=username, event=self.event
|
||||
)
|
||||
return username
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
try:
|
||||
self.cleaned_data['user'] = User.objects.get(
|
||||
email=username, event=self.event
|
||||
)
|
||||
return username
|
||||
except User.MultipleObjectsReturned:
|
||||
raise forms.ValidationError(
|
||||
_("We found multiple users with that e-mail address. Please specify the username instead"),
|
||||
code='unknown_user',
|
||||
)
|
||||
except User.DoesNotExist:
|
||||
raise forms.ValidationError(
|
||||
_("We are unable to find a user matching the data you provided."),
|
||||
code='unknown_user',
|
||||
)
|
||||
@@ -7,7 +7,7 @@
|
||||
<form class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors form type='all' layout='inline' %}
|
||||
{% bootstrap_field form.username layout="horizontal" %}
|
||||
{% bootstrap_field form.email layout="horizontal" %}
|
||||
<input type="hidden" name="form" value="login" />
|
||||
<div class="form-group">
|
||||
<div class="submit-group col-md-offset-2 col-md-4 text-right">
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<form class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors login_form type='all' layout='inline' %}
|
||||
{% bootstrap_field login_form.username layout="horizontal" %}
|
||||
{% bootstrap_field login_form.email layout="horizontal" %}
|
||||
{% bootstrap_field login_form.password layout="horizontal" %}
|
||||
<input type="hidden" name="form" value="login" />
|
||||
<div class="form-group">
|
||||
@@ -39,67 +39,47 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingOne">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#localRegistrationForm" data-parent="#login_accordion">
|
||||
{% if global_registration_form %}
|
||||
{% trans "I want to create a new account just for this event" %}
|
||||
{% else %}
|
||||
{% trans "I want to create a new account" %}
|
||||
{% endif %}
|
||||
<a data-toggle="collapse" href="#guestForm" data-parent="#login_accordion">
|
||||
{% trans "I want to order as a guest" %}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="localRegistrationForm" class="panel-collapse collapsed {% if request.POST.form == 'local_registration' %}in{% endif %}">
|
||||
<div id="guestForm" class="panel-collapse collapsed {% if request.POST.form == 'guest' %}in{% endif %}">
|
||||
<div class="panel-body">
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors local_registration_form type='all' layout='inline' %}
|
||||
{% bootstrap_field local_registration_form.username layout="horizontal" %}
|
||||
{% bootstrap_field local_registration_form.email layout="horizontal" %}
|
||||
{% bootstrap_field local_registration_form.password layout="horizontal" %}
|
||||
{% bootstrap_field local_registration_form.password_repeat layout="horizontal" %}
|
||||
<input type="hidden" name="form" value="local_registration" />
|
||||
<div class="form-group">
|
||||
<div class="submit-group col-md-offset-2 col-md-4 text-right">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
{% trans "Register" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
Coming soon.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if global_registration_form %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingOne">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#globalRegistrationForm" data-parent="#login_accordion">
|
||||
{% trans "I want to create a permanent account" %}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="globalRegistrationForm" class="panel-collapse collapsed {% if request.POST.form == 'global_registration' %}in{% endif %}">
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors global_registration_form type='all' layout='inline' %}
|
||||
{% bootstrap_field global_registration_form.email layout="horizontal" %}
|
||||
{% bootstrap_field global_registration_form.password layout="horizontal" %}
|
||||
{% bootstrap_field global_registration_form.password_repeat layout="horizontal" %}
|
||||
<input type="hidden" name="form" value="global_registration" />
|
||||
<div class="form-group">
|
||||
<div class="submit-group col-md-offset-2 col-md-4 text-right">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
{% trans "Register" %}
|
||||
</button>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading" role="tab" id="headingOne">
|
||||
<h4 class="panel-title">
|
||||
<a data-toggle="collapse" href="#registrationForm" data-parent="#login_accordion">
|
||||
{% trans "I want to create a permanent account" %}
|
||||
</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="registrationForm" class="panel-collapse collapsed
|
||||
{% if request.POST.form == 'registration' %}in{% endif %}">
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors registration_form type='all' layout='inline' %}
|
||||
{% bootstrap_field registration_form.email layout="horizontal" %}
|
||||
{% bootstrap_field registration_form.password layout="horizontal" %}
|
||||
{% bootstrap_field registration_form.password_repeat layout="horizontal" %}
|
||||
<input type="hidden" name="form" value="registration" />
|
||||
<div class="form-group">
|
||||
<div class="submit-group col-md-offset-2 col-md-4 text-right">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
{% trans "Register" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from datetime import timedelta
|
||||
from itertools import groupby
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.views import redirect_to_login
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db.models import Q
|
||||
@@ -11,26 +12,12 @@ from pretix.base.models import CartPosition
|
||||
from pretix.base.signals import register_payment_providers
|
||||
|
||||
|
||||
class EventLoginRequiredMixin:
|
||||
class LoginRequiredMixin:
|
||||
|
||||
@classmethod
|
||||
def as_view(cls, **initkwargs):
|
||||
view = super(EventLoginRequiredMixin, cls).as_view(**initkwargs)
|
||||
|
||||
def decorator(view_func):
|
||||
def _wrapped_view(request, *args, **kwargs):
|
||||
if request.user.is_authenticated() and \
|
||||
(request.user.event is None or request.user.event == request.event):
|
||||
return view_func(request, *args, **kwargs)
|
||||
path = request.path
|
||||
return redirect_to_login(
|
||||
path, reverse('presale:event.checkout.login', kwargs={
|
||||
'organizer': request.event.organizer.slug,
|
||||
'event': request.event.slug,
|
||||
}), 'next'
|
||||
)
|
||||
return _wrapped_view
|
||||
return decorator(view)
|
||||
view = super().as_view(**initkwargs)
|
||||
return login_required(view)
|
||||
|
||||
|
||||
class CartDisplayMixin:
|
||||
|
||||
@@ -13,7 +13,7 @@ from django.views.generic import View
|
||||
from pretix.base.models import (
|
||||
CartPosition, EventLock, Item, ItemVariation, Quota,
|
||||
)
|
||||
from pretix.presale.views import EventLoginRequiredMixin, EventViewMixin
|
||||
from pretix.presale.views import EventViewMixin, LoginRequiredMixin
|
||||
|
||||
|
||||
class CartActionMixin:
|
||||
@@ -62,7 +62,7 @@ class CartActionMixin:
|
||||
return items
|
||||
|
||||
|
||||
class CartRemove(EventViewMixin, CartActionMixin, EventLoginRequiredMixin, View):
|
||||
class CartRemove(EventViewMixin, CartActionMixin, LoginRequiredMixin, View):
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
items = self._items_from_post_data()
|
||||
@@ -110,10 +110,9 @@ class CartAdd(EventViewMixin, CartActionMixin, View):
|
||||
|
||||
self.items = self._items_from_post_data()
|
||||
|
||||
# We do not use EventLoginRequiredMixin here, as we want to store stuff into the
|
||||
# We do not use LoginRequiredMixin here, as we want to store stuff into the
|
||||
# session before redirecting to login
|
||||
if not request.user.is_authenticated() or \
|
||||
(request.user.event is not None and request.user.event != request.event):
|
||||
if not request.user.is_authenticated():
|
||||
request.session['cart_tmp'] = json.dumps(self.items)
|
||||
return redirect_to_login(
|
||||
self.get_success_url(), reverse('presale:event.checkout.login', kwargs={
|
||||
|
||||
@@ -12,7 +12,7 @@ from pretix.base.services.orders import OrderError, perform_order
|
||||
from pretix.base.signals import register_payment_providers
|
||||
from pretix.presale.forms.checkout import QuestionsForm
|
||||
from pretix.presale.views import (
|
||||
CartDisplayMixin, EventLoginRequiredMixin, EventViewMixin,
|
||||
CartDisplayMixin, EventViewMixin, LoginRequiredMixin,
|
||||
)
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class QuestionsViewMixin:
|
||||
return not failed
|
||||
|
||||
|
||||
class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
class CheckoutStart(EventViewMixin, CartDisplayMixin, LoginRequiredMixin,
|
||||
QuestionsViewMixin, CheckoutView):
|
||||
template_name = "pretixpresale/event/checkout_questions.html"
|
||||
|
||||
@@ -138,7 +138,7 @@ class CheckoutStart(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
return ctx
|
||||
|
||||
|
||||
class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, CheckoutView):
|
||||
class PaymentDetails(EventViewMixin, CartDisplayMixin, LoginRequiredMixin, CheckoutView):
|
||||
template_name = "pretixpresale/event/checkout_payment.html"
|
||||
|
||||
@cached_property
|
||||
@@ -194,7 +194,7 @@ class PaymentDetails(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin,
|
||||
return self.get_questions_url() + "?back=true"
|
||||
|
||||
|
||||
class OrderConfirm(EventViewMixin, CartDisplayMixin, EventLoginRequiredMixin, CheckoutView):
|
||||
class OrderConfirm(EventViewMixin, CartDisplayMixin, LoginRequiredMixin, CheckoutView):
|
||||
template_name = "pretixpresale/event/checkout_confirm.html"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
@@ -14,16 +14,15 @@ from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.generic import TemplateView, UpdateView, View
|
||||
|
||||
from pretix.base.forms.auth import (
|
||||
LoginForm, PasswordForgotForm, PasswordRecoverForm, RegistrationForm,
|
||||
)
|
||||
from pretix.base.forms.user import UserSettingsForm
|
||||
from pretix.base.models import User
|
||||
from pretix.base.services.mail import mail
|
||||
from pretix.helpers.urls import build_absolute_uri
|
||||
from pretix.presale.forms.auth import (
|
||||
GlobalRegistrationForm, LocalRegistrationForm, LoginForm,
|
||||
PasswordForgotForm, PasswordRecoverForm,
|
||||
)
|
||||
from pretix.presale.views import (
|
||||
CartDisplayMixin, EventLoginRequiredMixin, EventViewMixin,
|
||||
CartDisplayMixin, EventViewMixin, LoginRequiredMixin,
|
||||
)
|
||||
from pretix.presale.views.cart import CartAdd
|
||||
|
||||
@@ -102,8 +101,7 @@ class EventLogin(EventViewMixin, TemplateView):
|
||||
event=self.request.event.slug)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated() and \
|
||||
(request.user.event is None or request.user.event == request.event):
|
||||
if request.user.is_authenticated():
|
||||
return self.redirect_to_next()
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
@@ -113,27 +111,15 @@ class EventLogin(EventViewMixin, TemplateView):
|
||||
if form.is_valid() and form.user_cache:
|
||||
login(request, form.user_cache)
|
||||
return self.redirect_to_next()
|
||||
elif request.POST.get('form') == 'local_registration':
|
||||
form = self.local_registration_form
|
||||
elif request.POST.get('form') == 'registration':
|
||||
form = self.registration_form
|
||||
if form.is_valid():
|
||||
user = User.objects.create_local_user(
|
||||
request.event, form.cleaned_data['username'], form.cleaned_data['password'],
|
||||
email=form.cleaned_data['email'] if form.cleaned_data['email'] != '' else None,
|
||||
locale=request.LANGUAGE_CODE,
|
||||
timezone=request.timezone if hasattr(request, 'timezone') else settings.TIME_ZONE
|
||||
)
|
||||
user = authenticate(identifier=user.identifier, password=form.cleaned_data['password'])
|
||||
login(request, user)
|
||||
return self.redirect_to_next()
|
||||
elif request.POST.get('form') == 'global_registration' and settings.PRETIX_GLOBAL_REGISTRATION:
|
||||
form = self.global_registration_form
|
||||
if form.is_valid():
|
||||
user = User.objects.create_global_user(
|
||||
user = User.objects.create_user(
|
||||
form.cleaned_data['email'], form.cleaned_data['password'],
|
||||
locale=request.LANGUAGE_CODE,
|
||||
timezone=request.timezone if hasattr(request, 'timezone') else settings.TIME_ZONE
|
||||
)
|
||||
user = authenticate(identifier=user.identifier, password=form.cleaned_data['password'])
|
||||
user = authenticate(email=user.email, password=form.cleaned_data['password'])
|
||||
login(request, user)
|
||||
return self.redirect_to_next()
|
||||
return super().get(request, *args, **kwargs)
|
||||
@@ -146,26 +132,15 @@ class EventLogin(EventViewMixin, TemplateView):
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def global_registration_form(self):
|
||||
if settings.PRETIX_GLOBAL_REGISTRATION:
|
||||
return GlobalRegistrationForm(
|
||||
data=self.request.POST if self.request.POST.get('form', '') == 'global_registration' else None
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
@cached_property
|
||||
def local_registration_form(self):
|
||||
return LocalRegistrationForm(
|
||||
self.request,
|
||||
data=self.request.POST if self.request.POST.get('form', '') == 'local_registration' else None
|
||||
def registration_form(self):
|
||||
return RegistrationForm(
|
||||
data=self.request.POST if self.request.POST.get('form', '') == 'registration' else None
|
||||
)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['login_form'] = self.login_form
|
||||
context['global_registration_form'] = self.global_registration_form
|
||||
context['local_registration_form'] = self.local_registration_form
|
||||
context['registration_form'] = self.registration_form
|
||||
return context
|
||||
|
||||
|
||||
@@ -173,8 +148,7 @@ class EventForgot(EventViewMixin, TemplateView):
|
||||
template_name = 'pretixpresale/event/forgot.html'
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated() and \
|
||||
(request.user.event is None or request.user.event == request.event):
|
||||
if request.user.is_authenticated():
|
||||
return redirect('presale:event.orders',
|
||||
organizer=self.request.event.organizer.slug,
|
||||
event=self.request.event.slug)
|
||||
@@ -238,8 +212,7 @@ class EventRecover(EventViewMixin, TemplateView):
|
||||
}
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated() and \
|
||||
(request.user.event is None or request.user.event == request.event):
|
||||
if request.user.is_authenticated():
|
||||
return redirect('presale:event.orders',
|
||||
organizer=self.request.event.organizer.slug,
|
||||
event=self.request.event.slug)
|
||||
@@ -306,7 +279,7 @@ class EventLogout(EventViewMixin, View):
|
||||
event=self.request.event.slug)
|
||||
|
||||
|
||||
class EventAccount(EventLoginRequiredMixin, EventViewMixin, TemplateView):
|
||||
class EventAccount(LoginRequiredMixin, EventViewMixin, TemplateView):
|
||||
template_name = 'pretixpresale/event/account.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
@@ -315,7 +288,7 @@ class EventAccount(EventLoginRequiredMixin, EventViewMixin, TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
class EventOrders(EventLoginRequiredMixin, EventViewMixin, TemplateView):
|
||||
class EventOrders(LoginRequiredMixin, EventViewMixin, TemplateView):
|
||||
template_name = 'pretixpresale/event/orders.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
@@ -324,7 +297,7 @@ class EventOrders(EventLoginRequiredMixin, EventViewMixin, TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
class EventAccountSettings(EventLoginRequiredMixin, EventViewMixin, UpdateView):
|
||||
class EventAccountSettings(LoginRequiredMixin, EventViewMixin, UpdateView):
|
||||
model = User
|
||||
form_class = UserSettingsForm
|
||||
template_name = 'pretixpresale/event/account_settings.html'
|
||||
|
||||
@@ -15,7 +15,7 @@ from pretix.base.signals import (
|
||||
register_payment_providers, register_ticket_outputs,
|
||||
)
|
||||
from pretix.presale.views import (
|
||||
CartDisplayMixin, EventLoginRequiredMixin, EventViewMixin,
|
||||
CartDisplayMixin, EventViewMixin, LoginRequiredMixin,
|
||||
)
|
||||
from pretix.presale.views.checkout import QuestionsViewMixin
|
||||
|
||||
@@ -49,7 +49,7 @@ class OrderDetailMixin:
|
||||
})
|
||||
|
||||
|
||||
class OrderDetails(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
class OrderDetails(EventViewMixin, LoginRequiredMixin, OrderDetailMixin,
|
||||
CartDisplayMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/order.html"
|
||||
|
||||
@@ -102,7 +102,7 @@ class OrderDetails(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
return ctx
|
||||
|
||||
|
||||
class OrderPay(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin, TemplateView):
|
||||
class OrderPay(EventViewMixin, LoginRequiredMixin, OrderDetailMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/order_pay.html"
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
@@ -145,7 +145,7 @@ class OrderPay(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin, Templa
|
||||
})
|
||||
|
||||
|
||||
class OrderPayDo(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin, TemplateView):
|
||||
class OrderPayDo(EventViewMixin, LoginRequiredMixin, OrderDetailMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/order_pay_confirm.html"
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
@@ -185,7 +185,7 @@ class OrderPayDo(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin, Temp
|
||||
})
|
||||
|
||||
|
||||
class OrderModify(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
class OrderModify(EventViewMixin, LoginRequiredMixin, OrderDetailMixin,
|
||||
QuestionsViewMixin, TemplateView):
|
||||
template_name = "pretixpresale/event/order_modify.html"
|
||||
|
||||
@@ -227,7 +227,7 @@ class OrderModify(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
return ctx
|
||||
|
||||
|
||||
class OrderCancel(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
class OrderCancel(EventViewMixin, LoginRequiredMixin, OrderDetailMixin,
|
||||
TemplateView):
|
||||
template_name = "pretixpresale/event/order_cancel.html"
|
||||
|
||||
@@ -255,7 +255,7 @@ class OrderCancel(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
return ctx
|
||||
|
||||
|
||||
class OrderDownload(EventViewMixin, EventLoginRequiredMixin, OrderDetailMixin,
|
||||
class OrderDownload(EventViewMixin, LoginRequiredMixin, OrderDetailMixin,
|
||||
View):
|
||||
|
||||
@cached_property
|
||||
|
||||
Reference in New Issue
Block a user