Private
Public Access
1
0

some connection with the lisp server, commit 2

This commit is contained in:
2025-05-07 20:50:59 +02:00
parent 237e52f9ab
commit e24b2f0d4a
6 changed files with 78 additions and 38 deletions

View File

@@ -4211,30 +4211,67 @@ def planmacrocyclebymonth(request, id=0, userid=0): # pragma: no cover
return HttpResponseRedirect(url)
@user_passes_test(can_plan, login_url="/rowers/paidplans",
message="This functionality requires a Pro plan",
redirect_field_name=None)
def currentweekplan_view(request):
r = getrower(request.user)
post_data = {
'secret': 'noot', # to be replaced
'plan': 'zwolsche', # to be replaced
}
url = "http://localhost:8898/current-week-plan/"
response = requests.post(url, data=post_data)
data = response.json()
create_next_week_from_json(data, r, startdate=timezone.now()-timezone.timedelta(days=timezone.now().weekday()))
messages.info(request,"Your planned sessions were created")
url = reverse("plannedsessions_view")
return HttpResponseRedirect(url)
@user_passes_test(can_plan, login_url="/rowers/paidplans",
message="This functionality requires a Pro plan",
redirect_field_name=None)
def nextweekplan_view(request):
r = getrower(request.user)
form = NextWeekJsonForm()
fitness, fatigue = calculate_fitness(r)
form = NextWeekJsonForm(
initial={
'fitness': round(fitness),
'fatigue': round(fatigue),
}
)
if request.method == "POST":
form = NextWeekJsonForm(request.POST, request.FILES)
form = NextWeekJsonForm(request.POST)
if form.is_valid():
f = form.cleaned_data['file']
if f is not None:
filename, path_and_filename = handle_uploaded_file(f)
try:
with open(path_and_filename,'r') as ff:
data = json.load(ff)
except:
messages.error(request,"Hmm, invalid file")
fitness = form.cleaned_data['fitness']
fatigue = form.cleaned_data['fatigue']
post_data = {
'fitness':fitness,
'fatigue':fatigue,
'plan':'zwolsche', # to be replaced
'secret':'noot', # to be replaced
}
# post form.cleaned_data to localhost:8898/next-week-plan
url = "http://localhost:8898/next-week-plan/"
response = requests.post(url, data=post_data)
data = response.json()
create_next_week_from_json(data, r)
messages.info(request,"Your planned sessions were created")
create_next_week_from_json(data, r)
messages.info(request,"Your planned sessions were created")
# remove path_and_filename
os.remove(path_and_filename)
active = 'nav-plan'

View File

@@ -13,6 +13,7 @@ from rowers.utils import (
my_dict_from_instance, wavg, NoTokenError,
request_is_ajax, dologging
)
from rowers.fitness import calculate_fitness
from rowers.celery import result as celery_result
from rowers.interactiveplots import *
from scipy.interpolate import griddata