add plan to member plans
This commit is contained in:
@@ -483,6 +483,7 @@ class Rower(models.Model):
|
|||||||
plans = (
|
plans = (
|
||||||
('basic','basic'),
|
('basic','basic'),
|
||||||
('pro','pro'),
|
('pro','pro'),
|
||||||
|
('plan','plan'),
|
||||||
('coach','coach')
|
('coach','coach')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -752,7 +752,20 @@ def iscoachmember(user):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
# Check if a user can create planned sessions
|
||||||
|
def hasplannedsessions(user):
|
||||||
|
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')
|
||||||
|
else:
|
||||||
|
result = False
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def getrower(user):
|
def getrower(user):
|
||||||
try:
|
try:
|
||||||
@@ -774,7 +787,7 @@ def ispromember(user):
|
|||||||
r = Rower(user=user)
|
r = Rower(user=user)
|
||||||
r.save()
|
r.save()
|
||||||
|
|
||||||
result = user.is_authenticated() and (r.rowerplan=='pro' or r.rowerplan=='coach')
|
result = user.is_authenticated() and (r.rowerplan=='pro' or r.rowerplan=='coach' or r.rowerplan=='plan')
|
||||||
else:
|
else:
|
||||||
result = False
|
result = False
|
||||||
return result
|
return result
|
||||||
@@ -11679,3 +11692,6 @@ def agegrouprecordview(request,sex='male',weightcategory='hwt',
|
|||||||
'the_div':div,
|
'the_div':div,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@user_passes_test(hasplannedsessions,login_url="/",redirect_field_name=None)
|
||||||
|
def session_create_view(request):
|
||||||
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user