mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Merge branch 'django110'
This commit is contained in:
@@ -5,13 +5,14 @@ from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||
from django.core.urlresolvers import get_script_prefix, resolve
|
||||
from django.http import Http404
|
||||
from django.shortcuts import redirect, resolve_url
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from pretix.base.models import Event, EventPermission, Organizer
|
||||
|
||||
|
||||
class PermissionMiddleware:
|
||||
class PermissionMiddleware(MiddlewareMixin):
|
||||
"""
|
||||
This middleware enforces all requests to the control app to require login.
|
||||
Additionally, it enforces all requests to "control:event." URLs
|
||||
@@ -36,7 +37,7 @@ class PermissionMiddleware:
|
||||
return redirect(urljoin(settings.SITE_URL, request.get_full_path()))
|
||||
if url_name in self.EXCEPTIONS:
|
||||
return
|
||||
if not request.user.is_authenticated():
|
||||
if not request.user.is_authenticated:
|
||||
# Taken from django/contrib/auth/decorators.py
|
||||
path = request.build_absolute_uri()
|
||||
# urlparse chokes on lazy objects in Python 3, force to str
|
||||
|
||||
@@ -11,7 +11,7 @@ def event_permission_required(permission):
|
||||
"""
|
||||
def decorator(function):
|
||||
def wrapper(request, *args, **kw):
|
||||
if not request.user.is_authenticated(): # NOQA
|
||||
if not request.user.is_authenticated: # NOQA
|
||||
# just a double check, should not ever happen
|
||||
raise PermissionDenied()
|
||||
try:
|
||||
@@ -55,7 +55,7 @@ def organizer_permission_required(permission):
|
||||
"""
|
||||
def decorator(function):
|
||||
def wrapper(request, *args, **kw):
|
||||
if not request.user.is_authenticated(): # NOQA
|
||||
if not request.user.is_authenticated: # NOQA
|
||||
# just a double check, should not ever happen
|
||||
raise PermissionDenied()
|
||||
try:
|
||||
|
||||
@@ -24,7 +24,7 @@ def login(request):
|
||||
parameter "next" for redirection after successful login
|
||||
"""
|
||||
ctx = {}
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return redirect(request.GET.get("next", 'control:index'))
|
||||
if request.method == 'POST':
|
||||
form = LoginForm(data=request.POST)
|
||||
@@ -56,7 +56,7 @@ def register(request):
|
||||
if not settings.PRETIX_REGISTRATION:
|
||||
raise PermissionDenied('Registration is disabled')
|
||||
ctx = {}
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return redirect(request.GET.get("next", 'control:index'))
|
||||
if request.method == 'POST':
|
||||
form = RegistrationForm(data=request.POST)
|
||||
@@ -85,7 +85,7 @@ class Forgot(TemplateView):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return redirect(request.GET.get("next", 'control:index'))
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
@@ -149,7 +149,7 @@ class Recover(TemplateView):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if request.user.is_authenticated():
|
||||
if request.user.is_authenticated:
|
||||
return redirect(request.GET.get("next", 'control:index'))
|
||||
try:
|
||||
user = User.objects.get(id=self.request.GET.get('id'))
|
||||
|
||||
@@ -394,7 +394,8 @@ class QuestionView(EventPermissionRequiredMixin, QuestionMixin, ChartContainingV
|
||||
if self.request.GET.get("status", "") != "":
|
||||
s = self.request.GET.get("status", "")
|
||||
if s == 'o':
|
||||
qs = qs.filter(orderposition__order__status=Order.STATUS_PENDING, expires__lt=now().date())
|
||||
qs = qs.filter(orderposition__order__status=Order.STATUS_PENDING,
|
||||
expires__lt=now().replace(hour=0, minute=0, second=0))
|
||||
elif s == 'ne':
|
||||
qs = qs.filter(orderposition__order__status__in=[Order.STATUS_PENDING, Order.STATUS_EXPIRED])
|
||||
else:
|
||||
|
||||
@@ -59,7 +59,7 @@ class OrderList(EventPermissionRequiredMixin, ListView):
|
||||
if self.request.GET.get("status", "") != "":
|
||||
s = self.request.GET.get("status", "")
|
||||
if s == 'o':
|
||||
qs = qs.filter(status=Order.STATUS_PENDING, expires__lt=now().date())
|
||||
qs = qs.filter(status=Order.STATUS_PENDING, expires__lt=now().replace(hour=0, minute=0, second=0))
|
||||
elif s == 'ne':
|
||||
qs = qs.filter(status__in=[Order.STATUS_PENDING, Order.STATUS_EXPIRED])
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user