From dfb8a3de75da29a5acf7ff3716f6344c88d3cfd5 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 28 Feb 2020 14:15:07 +0100 Subject: [PATCH] fixed C2 import of workout not owned --- rowers/c2stuff.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index 83d18ae7..6bd2a38d 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -33,6 +33,8 @@ queuehigh = django_rq.get_queue('low') from rowers.utils import myqueue from rowers.models import C2WorldClassAgePerformance +from django.core.exceptions import PermissionDenied + def getagegrouprecord(age,sex='male',weightcategory='hwt', distance=2000,duration=None,indf=pd.DataFrame()): @@ -717,6 +719,12 @@ def get_workout(user,c2id): url = "https://log.concept2.com/api/users/me/results/"+str(c2id) s = requests.get(url,headers=headers) + if s.status_code != 200: + if s.status_code == 404: + raise PermissionDenied("You have no access to this resource") + else: + s = "Something went wrong with the import" + return custom_exception_handler(401,s), 0 data = s.json()['data'] splitdata = None