Private
Public Access
1
0

passing checks with django 2.1.7

This commit is contained in:
Sander Roosendaal
2019-03-22 10:59:49 +01:00
parent bec008d429
commit da0842fc8b
16 changed files with 570 additions and 571 deletions

View File

@@ -60,10 +60,7 @@ from rowers.forms import (
disqualifiers,SearchForm,BillingForm,PlanSelectForm
)
try:
from django.core.urlresolvers import reverse, reverse_lazy
except ModuleNotFoundError:
from django.urls import reverse, reverse_lazy
from django.urls import reverse, reverse_lazy
from django.core.exceptions import PermissionDenied
from django.template import RequestContext
@@ -187,7 +184,7 @@ from rowers.tasks import (
)
from scipy.signal import savgol_filter
from django.shortcuts import render_to_response
#from django.shortcuts import render_to_response
try:
from Cookie import SimpleCookie
except ModuleNotFoundError:
@@ -268,7 +265,7 @@ def getfavorites(r,row):
return favorites,maxfav
def get_workout_default_page(request,id):
if request.user.is_anonymous():
if request.user.is_anonymous:
return reverse('workout_view',kwargs={'id':id})
else:
r = Rower.objects.get(user=request.user)
@@ -346,10 +343,10 @@ def getrequestplanrower(request,rowerid=0,userid=0,notpermanent=False):
def getrower(user):
try:
if user.is_anonymous():
if user.is_anonymous:
return None
except AttributeError:
if User.objects.get(id=user).is_anonymous():
if User.objects.get(id=user).is_anonymous:
return None
try:
r = Rower.objects.get(user=user)
@@ -767,7 +764,7 @@ def get_thumbnails(request,id):
r = getrower(request.user)
result = request.user.is_authenticated() and ispromember(request.user)
result = request.user.is_authenticated and ispromember(request.user)
if result:
promember=1
if request.user == row.user.user:
@@ -998,21 +995,21 @@ from rowers.models import (
# Check if a user is a Coach member
def iscoachmember(user):
if not user.is_anonymous():
if not user.is_anonymous:
try:
r = Rower.objects.get(user=user)
except Rower.DoesNotExist:
r = Rower(user=user)
r.save()
result = user.is_authenticated() and (r.rowerplan=='coach')
result = user.is_authenticated and (r.rowerplan=='coach')
else:
result = False
return result
def cancreateteam(user):
if user.is_anonymous():
if user.is_anonymous:
return False
try:
@@ -1021,7 +1018,7 @@ def cancreateteam(user):
r = Rower(user=user)
r.save()
if user.is_authenticated() and (r.rowerplan=='coach'):
if user.is_authenticated and (r.rowerplan=='coach'):
return True
elif user.is_athenticated() and r.rowerplan in ['plan','pro']:
ts = Team.objects.filter(manager=user)
@@ -1030,16 +1027,16 @@ def cancreateteam(user):
# Check if a user can create planned sessions
def hasplannedsessions(user):
if not user.is_anonymous():
if not user.is_anonymous:
try:
r = Rower.objects.get(user=user)
except Rower.DoesNotExist:
r = Rower(user=user)
r.save()
result = user.is_authenticated() and (r.rowerplan=='coach' or r.rowerplan=='plan')
result = user.is_authenticated and (r.rowerplan=='coach' or r.rowerplan=='plan')
if not result and r.plantrialexpires:
result = user.is_authenticated() and r.plantrialexpires >= datetime.date.today()
result = user.is_authenticated and r.plantrialexpires >= datetime.date.today()
else:
result = False
@@ -1049,14 +1046,14 @@ from rowers.utils import isprorower,ProcessorCustomerError
# Check if a user is a Pro member
def ispromember(user):
if not user.is_anonymous():
if not user.is_anonymous:
try:
r = Rower.objects.get(user=user)
except Rower.DoesNotExist:
r = Rower(user=user)
r.save()
result = user.is_authenticated() and isprorower(r)
result = user.is_authenticated and isprorower(r)
else:
result = False
return result