Clearer message on user-passes-test
This commit is contained in:
@@ -20,7 +20,7 @@ from rowers.tasks import (
|
||||
handle_send_email_subscription_create,
|
||||
handle_send_email_failed_cancel,
|
||||
)
|
||||
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from rowsandall_app.settings import (
|
||||
@@ -70,7 +70,7 @@ def create_customer(rower,force=False):
|
||||
else:
|
||||
return rower.customer_id
|
||||
|
||||
|
||||
|
||||
|
||||
def get_client_token(rower):
|
||||
try:
|
||||
@@ -79,10 +79,10 @@ def get_client_token(rower):
|
||||
})
|
||||
except ValueError:
|
||||
customer_id = create_customer(rower,force=True)
|
||||
|
||||
|
||||
client_token = gateway.client_token.generate({
|
||||
"customer_id": customer_id,
|
||||
})
|
||||
})
|
||||
|
||||
return client_token
|
||||
|
||||
@@ -90,7 +90,7 @@ def get_plans_costs():
|
||||
plans = gateway.plan.all()
|
||||
|
||||
localplans = PaidPlan.object.filter(paymentprocessor='braintree')
|
||||
|
||||
|
||||
for plan in localplans:
|
||||
for btplan in btplans:
|
||||
if int(btplan.id) == plan.external_id:
|
||||
@@ -108,7 +108,7 @@ def make_payment(rower,data):
|
||||
|
||||
amount = data['amount']
|
||||
amount = '{amount:.f2}'.format(amount=amount)
|
||||
|
||||
|
||||
result = gateway.transaction.sale({
|
||||
"amount": amount,
|
||||
"payment_method_nonce": nonce_from_the_client,
|
||||
@@ -123,7 +123,7 @@ def make_payment(rower,data):
|
||||
f = rower.user.first_name,
|
||||
l = rower.user.last_name,
|
||||
)
|
||||
|
||||
|
||||
|
||||
job = myqueue(queuehigh,handle_send_email_transaction,
|
||||
name, rower.user.email, amount)
|
||||
@@ -143,7 +143,7 @@ def update_subscription(rower,data,method='up'):
|
||||
amount = data['amount']
|
||||
amount = '{amount:.2f}'.format(amount=amount)
|
||||
|
||||
|
||||
|
||||
gatewaydata = {
|
||||
"price": amount,
|
||||
"plan_id": plan.external_id,
|
||||
@@ -192,7 +192,7 @@ def update_subscription(rower,data,method='up'):
|
||||
coachgroup.save()
|
||||
rower.mycoachgroup = coachgroup
|
||||
rower.save()
|
||||
|
||||
|
||||
athletes = Rower.objects.filter(coachinggroups__in=[rower.mycoachgroup]).distinct()
|
||||
for athlete in athletes:
|
||||
athlete.coachinggroups.remove(rower.mycoachgroup)
|
||||
@@ -217,7 +217,7 @@ def update_subscription(rower,data,method='up'):
|
||||
amount,
|
||||
result.subscription.billing_period_end_date.strftime('%Y-%m-%d'),
|
||||
method)
|
||||
|
||||
|
||||
return True,amount
|
||||
else:
|
||||
errors = result.errors.for_object("subscription")
|
||||
@@ -230,12 +230,12 @@ def update_subscription(rower,data,method='up'):
|
||||
|
||||
if create_new:
|
||||
return create_subscription(rower,data)
|
||||
|
||||
|
||||
return False,0
|
||||
|
||||
return False,0
|
||||
|
||||
|
||||
|
||||
|
||||
def create_subscription(rower,data):
|
||||
nonce_from_the_client = data['payment_method_nonce']
|
||||
nonce = gateway.payment_method_nonce.find(nonce_from_the_client)
|
||||
@@ -249,8 +249,8 @@ def create_subscription(rower,data):
|
||||
|
||||
planid = data['plan']
|
||||
plan = PaidPlan.objects.get(id=planid)
|
||||
|
||||
|
||||
|
||||
|
||||
# create or find payment method
|
||||
result = gateway.payment_method.create({
|
||||
"customer_id": rower.customer_id,
|
||||
@@ -270,6 +270,7 @@ def create_subscription(rower,data):
|
||||
|
||||
|
||||
if result.is_success:
|
||||
yesterday = (timezone.now()-datetime.timedelta(days=1)).date()
|
||||
rower.paidplan = plan
|
||||
rower.planexpires = result.subscription.billing_period_end_date
|
||||
rower.teamplanexpires = result.subscription.billing_period_end_date
|
||||
@@ -277,6 +278,8 @@ def create_subscription(rower,data):
|
||||
rower.paymenttype = plan.paymenttype
|
||||
rower.rowerplan = plan.shortname
|
||||
rower.subscription_id = result.subscription.id
|
||||
rower.protrialexpires = yesterday
|
||||
rower.plantrialexpires = yesterday
|
||||
|
||||
rower.save()
|
||||
name = '{f} {l}'.format(
|
||||
@@ -286,7 +289,7 @@ def create_subscription(rower,data):
|
||||
|
||||
|
||||
recurring = plan.paymenttype
|
||||
|
||||
|
||||
job = myqueue(
|
||||
queuehigh,
|
||||
handle_send_email_subscription_create,
|
||||
@@ -312,15 +315,15 @@ def cancel_subscription(rower,id):
|
||||
themessages.append("Subscription canceled")
|
||||
except:
|
||||
errormessages.append("We could not find the subscription record in our customer database. We have notified the site owner, who will contact you.")
|
||||
|
||||
|
||||
|
||||
name = '{f} {l}'.format(f = rower.user.first_name, l = rower.user.last_name)
|
||||
|
||||
|
||||
|
||||
|
||||
job = myqueue(queuehigh,
|
||||
handle_send_email_failed_cancel,
|
||||
name, rower.user.email,rower.user.username,id)
|
||||
|
||||
|
||||
return False, themessages, errormessages
|
||||
|
||||
basicplans = PaidPlan.objects.filter(price=0,paymentprocessor='braintree')
|
||||
@@ -343,7 +346,7 @@ def find_subscriptions(rower):
|
||||
raise ProcessorCustomerError("We could not find the customer in the database")
|
||||
|
||||
active_subscriptions = []
|
||||
|
||||
|
||||
cards = result.credit_cards
|
||||
for card in cards:
|
||||
for subscription in card.subscriptions:
|
||||
@@ -360,12 +363,12 @@ def find_subscriptions(rower):
|
||||
pass
|
||||
|
||||
result = []
|
||||
|
||||
|
||||
for subscription in active_subscriptions:
|
||||
|
||||
plan = PaidPlan.objects.filter(paymentprocessor="braintree",
|
||||
external_id=subscription.plan_id)[0]
|
||||
|
||||
|
||||
thedict = {
|
||||
'end_date': subscription.billing_period_end_date,
|
||||
'plan_id': subscription.plan_id,
|
||||
@@ -444,7 +447,7 @@ def get_transactions(start_date,end_date):
|
||||
transaction.credit_card_details.country_of_issuance)
|
||||
statuses.append(transaction.status)
|
||||
|
||||
|
||||
|
||||
df = pd.DataFrame({
|
||||
'name':names,
|
||||
'email':emails,
|
||||
|
||||
@@ -31,7 +31,7 @@ defaultoptions = {
|
||||
|
||||
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def analysis_new(request,userid=0,function='boxplot',teamid=0):
|
||||
r = getrequestrower(request, userid=userid)
|
||||
@@ -667,7 +667,7 @@ def boxplotdata(workouts,options):
|
||||
return(script,div)
|
||||
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def analysis_view_data(request,userid=0):
|
||||
if not request.is_ajax():
|
||||
@@ -725,7 +725,7 @@ def analysis_view_data(request,userid=0):
|
||||
|
||||
# Histogram for a date/time range
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def histo(request,theuser=0,
|
||||
startdate=timezone.now()-datetime.timedelta(days=365),
|
||||
@@ -2148,7 +2148,7 @@ def rankings_view2(request,theuser=0,
|
||||
|
||||
# Show ranking distances including predicted paces
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def otwrankings_view(request,theuser=0,
|
||||
startdate=timezone.now()-datetime.timedelta(days=365),
|
||||
@@ -2553,7 +2553,7 @@ def otwcp_toadmin_view(request,theuser=0,
|
||||
|
||||
# Show ranking distances including predicted paces
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def oterankings_view(request,theuser=0,
|
||||
startdate=timezone.now()-datetime.timedelta(days=365),
|
||||
@@ -2904,7 +2904,7 @@ def oterankings_view(request,theuser=0,
|
||||
|
||||
# Multi Flex Chart with Grouping
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def user_multiflex_select(request,
|
||||
startdatestring="",
|
||||
@@ -3110,7 +3110,7 @@ def user_multiflex_select(request,
|
||||
})
|
||||
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def multiflex_data(request,userid=0,
|
||||
options={
|
||||
@@ -3363,7 +3363,7 @@ def multiflex_data(request,userid=0,
|
||||
|
||||
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def multiflex_view(request,userid=0,
|
||||
options={
|
||||
@@ -3530,7 +3530,7 @@ def multiflex_view(request,userid=0,
|
||||
|
||||
# Box plots
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def user_boxplot_select(request,
|
||||
startdatestring="",
|
||||
@@ -3738,7 +3738,7 @@ def user_boxplot_select(request,
|
||||
})
|
||||
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def boxplot_view_data(request,userid=0,
|
||||
options={
|
||||
@@ -3855,7 +3855,7 @@ def boxplot_view_data(request,userid=0,
|
||||
})
|
||||
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def boxplot_view(request,userid=0,
|
||||
options={
|
||||
@@ -3974,7 +3974,7 @@ def boxplot_view(request,userid=0,
|
||||
|
||||
|
||||
# Cumulative stats page
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher",redirect_field_name=None)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",redirect_field_name=None)
|
||||
def cumstats(request,theuser=0,
|
||||
startdate=timezone.now()-datetime.timedelta(days=30),
|
||||
enddate=timezone.now(),
|
||||
@@ -4323,7 +4323,7 @@ def agegrouprecordview(request,sex='male',weightcategory='hwt',
|
||||
|
||||
# alert overview view
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def alerts_view(request,userid=0):
|
||||
r = getrequestrower(request,userid=userid)
|
||||
@@ -4357,7 +4357,7 @@ def alerts_view(request,userid=0):
|
||||
|
||||
# alert create view
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def alert_create_view(request,userid=0):
|
||||
r = getrequestrower(request,userid=userid)
|
||||
@@ -4437,7 +4437,7 @@ def alert_create_view(request,userid=0):
|
||||
|
||||
# alert report view
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def alert_report_view(request,id=0,userid=0,nperiod=0):
|
||||
r = getrequestrower(request,userid=userid)
|
||||
@@ -4494,7 +4494,7 @@ def alert_report_view(request,id=0,userid=0,nperiod=0):
|
||||
|
||||
# alert edit view
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def alert_edit_view(request,id=0,userid=0):
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
@@ -8,7 +8,7 @@ import rowers.teams as teams
|
||||
|
||||
# Show the EMpower Oarlock generated Stroke Profile
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans/",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
||||
row = get_workout(id)
|
||||
@@ -336,8 +336,9 @@ def fitness_metric_view(request,mode='rower',days=42):
|
||||
return HttpResponse("job queued")
|
||||
|
||||
|
||||
@login_required()
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_update_cp_view(request,id=0):
|
||||
row = get_workout(id)
|
||||
@@ -400,7 +401,7 @@ def workout_recalcsummary_view(request,id=0):
|
||||
|
||||
# Joining workout
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workouts_join_view(request):
|
||||
promember=0
|
||||
@@ -446,7 +447,7 @@ def workouts_join_view(request):
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workouts_join_select(request,
|
||||
startdatestring="",
|
||||
@@ -604,7 +605,7 @@ def workouts_join_select(request,
|
||||
|
||||
# Team comparison
|
||||
@user_passes_test(ispromember,login_url='/rowers/paidplans/',
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def team_comparison_select(request,
|
||||
startdatestring="",
|
||||
@@ -1387,7 +1388,7 @@ def workouts_view(request,message='',successmessage='',
|
||||
|
||||
# List of workouts to compare a selected workout to
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_fusion_list(request,id=0,message='',successmessage='',
|
||||
startdatestring="",enddatestring="",
|
||||
@@ -1593,7 +1594,7 @@ def workout_view(request,id=0):
|
||||
|
||||
# Resets stroke data to raw data (pace)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_undo_smoothenpace_view(
|
||||
request,id=0,message="",successmessage=""
|
||||
@@ -1632,7 +1633,7 @@ def workout_undo_smoothenpace_view(
|
||||
|
||||
# Data smoothing of pace data
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_smoothenpace_view(request,id=0,message="",successmessage=""):
|
||||
row = get_workout(id)
|
||||
@@ -1685,7 +1686,7 @@ def workout_smoothenpace_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
# Process CrewNerd Summary CSV and update summary
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_crewnerd_summary_view(request,id=0,message="",successmessage=""):
|
||||
row = get_workout(id)
|
||||
@@ -1762,7 +1763,7 @@ def workout_crewnerd_summary_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
# Get weather for given location and date/time
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_downloadwind_view(request,id=0,
|
||||
airportcode=None,
|
||||
@@ -1836,7 +1837,7 @@ def workout_downloadwind_view(request,id=0,
|
||||
return response
|
||||
|
||||
# Get weather for given location and date/time
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher",redirect_field_name=None)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",redirect_field_name=None)
|
||||
def workout_downloadmetar_view(request,id=0,
|
||||
airportcode=None,
|
||||
message="",successmessage=""):
|
||||
@@ -1911,7 +1912,7 @@ def workout_downloadmetar_view(request,id=0,
|
||||
|
||||
|
||||
# Show form to update wind data
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher",redirect_field_name=None)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",redirect_field_name=None)
|
||||
def workout_wind_view(request,id=0,message="",successmessage=""):
|
||||
row = get_workout(id)
|
||||
r = getrower(request.user)
|
||||
@@ -2047,7 +2048,7 @@ def workout_wind_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# Show form to update River stream data (for river dwellers)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher",redirect_field_name=None)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",redirect_field_name=None)
|
||||
def workout_stream_view(request,id=0,message="",successmessage=""):
|
||||
row = get_workout(id)
|
||||
r = getrower(request.user)
|
||||
@@ -4628,7 +4629,7 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
|
||||
|
||||
# Split a workout
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher",
|
||||
message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workout_split_view(request,id=0):
|
||||
row = get_workout_permitted(request.user,id)
|
||||
@@ -4724,7 +4725,7 @@ def workout_split_view(request,id=0):
|
||||
|
||||
|
||||
# Fuse two workouts
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher",redirect_field_name=None)
|
||||
@user_passes_test(ispromember,login_url="/rowers/paidplans",message="This functionality requires a Pro plan or higher. If you are already a Pro user, please log in to access this functionality",redirect_field_name=None)
|
||||
def workout_fusion_view(request,id1=0,id2=1):
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user