From 480bdd330e19bd0d1bc3695700b8f59bd8b366f9 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 30 Dec 2020 22:07:43 +0100 Subject: [PATCH] API - return activity shorter id - #57 --- docs/api/activities.html | 98 +++++++------- docs/api/records.html | 8 +- docs/http-routingtable.html | 14 +- docs/objects.inv | Bin 1279 -> 1282 bytes docs/searchindex.js | 2 +- fittrackee/activities/activities.py | 128 ++++++++++-------- fittrackee/activities/models.py | 17 ++- fittrackee/activities/records.py | 8 +- fittrackee/activities/utils_id.py | 9 ++ .../activities/test_activities_api_0_get.py | 36 ++--- .../activities/test_activities_api_1_post.py | 40 +++--- .../activities/test_activities_api_2_patch.py | 89 ++++++------ .../test_activities_api_3_delete.py | 21 ++- .../tests/activities/test_activities_model.py | 8 +- .../tests/activities/test_records_api.py | 126 ++++++++--------- fittrackee/tests/activities/utils.py | 12 +- poetry.lock | 14 +- pyproject.toml | 1 + 18 files changed, 336 insertions(+), 295 deletions(-) create mode 100644 fittrackee/activities/utils_id.py diff --git a/docs/api/activities.html b/docs/api/activities.html index 6df48bed..c3784f18 100644 --- a/docs/api/activities.html +++ b/docs/api/activities.html @@ -162,7 +162,7 @@ "descent": null, "distance": 10.0, "duration": "0:17:04", - "id": "f03265f69fe0489b812fc7dc4deff55e", + "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 10.0, @@ -176,7 +176,7 @@ "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -185,7 +185,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -194,7 +194,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -203,7 +203,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -285,11 +285,11 @@
-
-GET /api/activities/(string: activity_uuid)
+
+GET /api/activities/(string: activity_short_id)

Get an activity

Example request:

-
GET /api/activities/f03265f69fe0489b812fc7dc4deff55e HTTP/1.1
+
GET /api/activities/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1
 

Example responses:

@@ -311,7 +311,7 @@ "descent": null, "distance": 12, "duration": "0:45:00", - "id": "f03265f69fe0489b812fc7dc4deff55e", + "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 16, @@ -355,7 +355,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

Request Headers
@@ -380,11 +380,11 @@
-
-GET /api/activities/(string: activity_uuid)/gpx
+
+GET /api/activities/(string: activity_short_id)/gpx

Get gpx file for an activity displayed on map with Leaflet

Example request:

-
GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx HTTP/1.1
+
GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx HTTP/1.1
 Content-Type: application/json
 
@@ -405,7 +405,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

Request Headers
@@ -434,11 +434,11 @@
-
-GET /api/activities/(string: activity_uuid)/chart_data
+
+GET /api/activities/(string: activity_short_id)/chart_data

Get chart data from an activity gpx file, to display it with Recharts

Example request:

-
GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/chart HTTP/1.1
+
GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/chart HTTP/1.1
 Content-Type: application/json
 
@@ -478,7 +478,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

Request Headers
@@ -507,12 +507,11 @@
-
-GET /api/activities/(string: activity_uuid)/chart_data/segment/(int: segment_id)
+
+GET /api/activities/(string: activity_short_id)/chart_data/segment/(int: segment_id)

Get chart data from an activity gpx file, to display it with Recharts

Example request:

-
GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/chart/segment/0
-  HTTP/1.1
+
GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/chart/segment/0 HTTP/1.1
 Content-Type: application/json
 
@@ -552,7 +551,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

  • segment_id (integer) – segment id

@@ -579,12 +578,11 @@
-
-GET /api/activities/(string: activity_uuid)/gpx/segment/(int: segment_id)
+
+GET /api/activities/(string: activity_short_id)/gpx/segment/(int: segment_id)

Get gpx file for an activity segment displayed on map with Leaflet

Example request:

-
GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx/segment/0
-  HTTP/1.1
+
GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx/segment/0 HTTP/1.1
 Content-Type: application/json
 
@@ -605,7 +603,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

  • segment_id (integer) – segment id

@@ -718,7 +716,7 @@ "descent": null, "distance": 10.0, "duration": "0:17:04", - "id": "f03265f69fe0489b812fc7dc4deff55e", + "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 10.0, @@ -732,7 +730,7 @@ "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -741,7 +739,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -750,7 +748,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -759,7 +757,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -859,7 +857,7 @@ "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -868,7 +866,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -877,7 +875,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -886,7 +884,7 @@ }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -898,7 +896,7 @@ "sport_id": 1, "title": null, "user": "admin", - "uuid": "f03265f69fe0489b812fc7dc4deff55e" + "uuid": "kjxavSTUrJvoAh2wvCeGEF" "weather_end": null, "weather_start": null, "with_gpx": false @@ -947,8 +945,8 @@
-
-PATCH /api/activities/(string: activity_uuid)
+
+PATCH /api/activities/(string: activity_short_id)

Update an activity

Example request:

PATCH /api/activities/1 HTTP/1.1
@@ -984,7 +982,7 @@
           "records": [
             {
               "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
-              "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
+              "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
               "id": 4,
               "record_type": "MS",
               "sport_id": 1,
@@ -993,7 +991,7 @@
             },
             {
               "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
-              "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
+              "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
               "id": 3,
               "record_type": "LD",
               "sport_id": 1,
@@ -1002,7 +1000,7 @@
             },
             {
               "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
-              "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
+              "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
               "id": 2,
               "record_type": "FD",
               "sport_id": 1,
@@ -1011,7 +1009,7 @@
             },
             {
               "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
-              "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
+              "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
               "id": 1,
               "record_type": "AS",
               "sport_id": 1,
@@ -1023,7 +1021,7 @@
           "sport_id": 1,
           "title": null,
           "user": "admin",
-          "uuid": "f03265f69fe0489b812fc7dc4deff55e"
+          "uuid": "kjxavSTUrJvoAh2wvCeGEF"
           "weather_end": null,
           "weather_start": null,
           "with_gpx": false
@@ -1038,7 +1036,7 @@
 
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

Request JSON Object
@@ -1077,11 +1075,11 @@
-
-DELETE /api/activities/(string: activity_uuid)
+
+DELETE /api/activities/(string: activity_short_id)

Delete an activity

Example request:

-
DELETE /api/activities/f03265f69fe0489b812fc7dc4deff55e HTTP/1.1
+
DELETE /api/activities/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1
 Content-Type: application/json
 
@@ -1094,7 +1092,7 @@
Parameters
  • auth_user_id (integer) – authenticate user id (from JSON Web Token)

  • -
  • activity_uuid (integer) – activity uuid

  • +
  • activity_short_id (string) – activity short id

Request Headers
diff --git a/docs/api/records.html b/docs/api/records.html index ecff4bc8..c6082685 100644 --- a/docs/api/records.html +++ b/docs/api/records.html @@ -156,7 +156,7 @@ "records": [ { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 9, "record_type": "AS", "sport_id": 1, @@ -165,7 +165,7 @@ }, { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 10, "record_type": "FD", "sport_id": 1, @@ -174,7 +174,7 @@ }, { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 11, "record_type": "LD", "sport_id": 1, @@ -183,7 +183,7 @@ }, { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 12, "record_type": "MS", "sport_id": 1, diff --git a/docs/http-routingtable.html b/docs/http-routingtable.html index ef4f3cd8..05e2097d 100644 --- a/docs/http-routingtable.html +++ b/docs/http-routingtable.html @@ -133,27 +133,27 @@ - GET /api/activities/(string:activity_uuid) + GET /api/activities/(string:activity_short_id) - GET /api/activities/(string:activity_uuid)/chart_data + GET /api/activities/(string:activity_short_id)/chart_data - GET /api/activities/(string:activity_uuid)/chart_data/segment/(int:segment_id) + GET /api/activities/(string:activity_short_id)/chart_data/segment/(int:segment_id) - GET /api/activities/(string:activity_uuid)/gpx + GET /api/activities/(string:activity_short_id)/gpx - GET /api/activities/(string:activity_uuid)/gpx/segment/(int:segment_id) + GET /api/activities/(string:activity_short_id)/gpx/segment/(int:segment_id) @@ -273,7 +273,7 @@ - DELETE /api/activities/(string:activity_uuid) + DELETE /api/activities/(string:activity_short_id) @@ -288,7 +288,7 @@ - PATCH /api/activities/(string:activity_uuid) + PATCH /api/activities/(string:activity_short_id) diff --git a/docs/objects.inv b/docs/objects.inv index d84b63dbd628779bc828150053e2861c3403cab6..e1701f0802e2edc6651dea06f324322af46b5397 100644 GIT binary patch delta 1157 zcmV;01bX}b34#icjDK0^GTmlJ5}Yu>fdSmy-VLLGVl=gZf}AFOfWAT3_Z9mHJwgJD z4?C8db`cL8o&WC~9S)L+g)3^|l+jnpC~3@`vFd6~nE8`A9Ql&7?dAsD5QPtYjIk~nR?}jAB~9;1lb1D1Xm%+gWMo4aIS@k(j(?*d$wV_u{RFh?^tquc z%+mZ&dHL9X72Zm73|ARu_;ZVZ6!4h|Sq)ilNx`fOTCgj5^ZAcU$rQ;Th(|1krQ=O_`k{rp>*oD#g%mdKj&rwQq=2b@d=|F0>!zsF8+YOH~4$M{8AO`GsCq! zsK6xx9s(Zfcz@IIMVa(ZUvtSsQrkgyEVnl0nif+U3{5y-L&ALoD0gf!@gA_Bvea{L z6;R=(`Ms<&t0oQj*5tPxY1rv0b$T?^&xY7l@Dh?U*itxv(vaMLr}KBA)}&&RtBxV)Yc@0-kF?{q|Hqt^=W5lB)y9 zk0Ttp!d9cb{s>krtqN9ZdK}F#C+`|kCk5V;OY0d{f9^F&n|qG4<~F3LQLjG6XLL)> z#<$`D9e-~&r_;EzRCDg+DYwRvQaGwAbw)FbkOEOxq1LR<=L6;mS!vMJR#A9Lr<_h4 zuA7>9Dr=}61c~S0nSX!(^Dnbu*%c{XUvUjITEO$#Y?Rkr453aU#F29oI&t#g{BolF z$6gr6?&DpgDSPt62Pf1~-P*BzZAVUW>qhpq=YJ%D?|TqgXU+#13Vs!O8d*6@+x0Xx z3(t-o5~zZP=H8ED4fmxTBz7E!?)55m{YRY|jity4{7@%$=-4+gpI%~np8u4D&Yc^@ zq21EX!UV2nh4^ z@P9)mirebwy|$qP?XOwU$l)QAw%s*kaXV2b{28=7phh2#rN~(6w!td!eET+8_#Wi0 z6MHB`#*<^m_mGEvt>rqG1fhT9M3JMj;*I{n#D!UznrQZ8$+Y`>qdTBZB;BFawBZUq zK55!UHYNwcv2uD^G;dT>OQ1zY-p0z-D1UX_ zIkTBjdu{aRmx*tGs4*j+NCR~c?&5$la^LU8=89h$X^x9Efv-T-vp34>w6`YQ8!rU& zU3$RnY{GdV?~FAm_C?&_XR_hWomDuy{L+%peul50fn+i)wD)lwn0}!! zn=!W=lZU2+T2L0(IQ^Ayw|%1yy+;iU`Ry&nw#;TGRK25aKxmd_wu32%sVSo$$bxs4 zLplR>LvWquL!q$ACoaYVye0;N3PBB;yexS|ESzm=0qp=iUDoO>k2=ccR!tM~q{_1n Xf)o#jCM@2M$54EH->$|#SY9YRvc5px delta 1154 zcmV-|1bzF03jYa^jDKF}GIyIDNpQjh2L^C+dp8;aimj;)6hxZz0s01A_Z9mHJwgJD zk0h4sxr=z<==^`@=;$CstfZt?k}~>286~y3Wvsm15N3Wgha+FMY`^;nMi7Dlq)3oq z%|XhdeviV3KF3%WHLGa8xs;|i+%z;>2zo|#gpqgnVsIP*Nq-(1@$>>~)#f}Q%Y>!d z_e#mf&K=fDw@Jltmayb}lST^kghZ^GZ1yB))&ajHjG%>tyT*U#cHqdNjcSy&f;!rv?Wy)C|!`R2rMEe~eD zK)^%5Lmh7#K7TK8zv7x(AClS*+OVy)D>gKr(qL%90UHwTBS6ux$;5lWVaig^y;VS& z)b$@lm01<3!M7s6H>76Ar_|}uP(K@@DdC|bC$Ob(0HrBwDl+$)=y8J=L<^LncR@#G zH3zARXK12h*P(NtL0BZCI^`EC)T&fmMK-i%q&gneD}N*=E%IkNd8UN5sS-wud^9(y zn9-~6wi$x*dK)rInrmgy`b%v^Qs|w@Sx1^j!p>Q0>$0fWL@KN!rF0z#<#x=k=eEHQ zIC6*Wm7inP(yCykrXQnO!pTidDx4>Kvap`saO*Wmn|qG4<~F3LQLp}p&*+|WpSKAqArDLakYy&nL_yveKZbt)lRhPC1@9+&4Az zRQ6Ci2(ahhn*aXu*WYH%vP+V`yd)LSXb$VO+bNH^7($&yh$H7ZbYgt({CcGP=Uy1c z?!#@QDSPz8dneRU-Po~xWk(LaaU=W6b8z7M9)CpEne)301-}kGjjWuN?RuJ;rDsR? z7^~Pd+!(v7ljpIrzu^el1R7@P!cXLWcTNUVN1xwxI*$hAeS??22f6FS9tx51 z=-BZcp`1XeyGvbNVPzT{I4k#n{!@JmA^GhS$Ci#ZISD@6MO{?B$HvGy^G_(429W@xqIE1 zESeH(Nm*Pa>2HL)9U67$J!)Xc?_e?ZMK&{`@(pzZLbEEe2BsjUri^|f3*Oik(iy00 zl2qw-C=@oi;$l2VHpF01A*eyUEec){E6MgWhjxITE-H1FA3DnBR!tM~q{_1nf)o#j UCM@2MAEEg8p diff --git a/docs/searchindex.js b/docs/searchindex.js index b3111626..3aeb09c3 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api/activities","api/auth","api/configuration","api/index","api/records","api/sports","api/stats","api/users","changelog","features","index","installation","troubleshooting/administrator","troubleshooting/index","troubleshooting/user"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,sphinx:56},filenames:["api/activities.rst","api/auth.rst","api/configuration.rst","api/index.rst","api/records.rst","api/sports.rst","api/stats.rst","api/users.rst","changelog.md","features.rst","index.rst","installation.rst","troubleshooting/administrator.rst","troubleshooting/index.rst","troubleshooting/user.rst"],objects:{"":{"/api/activities":[0,1,1,"post--api-activities"],"/api/activities/(string:activity_uuid)":[0,3,1,"patch--api-activities-(string-activity_uuid)"],"/api/activities/(string:activity_uuid)/chart_data":[0,0,1,"get--api-activities-(string-activity_uuid)-chart_data"],"/api/activities/(string:activity_uuid)/chart_data/segment/(int:segment_id)":[0,0,1,"get--api-activities-(string-activity_uuid)-chart_data-segment-(int-segment_id)"],"/api/activities/(string:activity_uuid)/gpx":[0,0,1,"get--api-activities-(string-activity_uuid)-gpx"],"/api/activities/(string:activity_uuid)/gpx/segment/(int:segment_id)":[0,0,1,"get--api-activities-(string-activity_uuid)-gpx-segment-(int-segment_id)"],"/api/activities/map/(map_id)":[0,0,1,"get--api-activities-map-(map_id)"],"/api/activities/no_gpx":[0,1,1,"post--api-activities-no_gpx"],"/api/auth/login":[1,1,1,"post--api-auth-login"],"/api/auth/logout":[1,0,1,"get--api-auth-logout"],"/api/auth/password/reset-request":[1,1,1,"post--api-auth-password-reset-request"],"/api/auth/password/update":[1,1,1,"post--api-auth-password-update"],"/api/auth/picture":[1,1,1,"post--api-auth-picture"],"/api/auth/profile":[1,0,1,"get--api-auth-profile"],"/api/auth/profile/edit":[1,1,1,"post--api-auth-profile-edit"],"/api/auth/register":[1,1,1,"post--api-auth-register"],"/api/config":[2,3,1,"patch--api-config"],"/api/ping":[2,0,1,"get--api-ping"],"/api/records":[4,0,1,"get--api-records"],"/api/sports":[5,0,1,"get--api-sports"],"/api/sports/(int:sport_id)":[5,3,1,"patch--api-sports-(int-sport_id)"],"/api/stats/(user_name)/by_sport":[6,0,1,"get--api-stats-(user_name)-by_sport"],"/api/stats/(user_name)/by_time":[6,0,1,"get--api-stats-(user_name)-by_time"],"/api/stats/all":[6,0,1,"get--api-stats-all"],"/api/users":[7,0,1,"get--api-users"],"/api/users/(user_name)":[7,3,1,"patch--api-users-(user_name)"],"/api/users/(user_name)/picture":[7,0,1,"get--api-users-(user_name)-picture"],"APP_LOG \ud83c\udd95":[11,4,1,"envvar-APP_LOG"],"DATABASE_DISABLE_POOLING \ud83c\udd95":[11,4,1,"envvar-DATABASE_DISABLE_POOLING"],"MAP_ATTRIBUTION \ud83c\udd95":[11,4,1,"envvar-MAP_ATTRIBUTION"],"TILE_SERVER_URL \ud83c\udd95":[11,4,1,"envvar-TILE_SERVER_URL"],"UPLOAD_FOLDER \ud83c\udd95":[11,4,1,"envvar-UPLOAD_FOLDER"],APP_SECRET_KEY:[11,4,1,"-"],APP_SETTINGS:[11,4,1,"-"],APP_WORKERS:[11,4,1,"-"],DATABASE_URL:[11,4,1,"-"],EMAIL_URL:[11,4,1,"-"],FLASK_APP:[11,4,1,"-"],HOST:[11,4,1,"-"],PORT:[11,4,1,"-"],REACT_APP_ALLOW_REGISTRATION:[11,4,1,"-"],REACT_APP_API_URL:[11,4,1,"-"],REACT_APP_GPX_LIMIT_IMPORT:[11,4,1,"-"],REACT_APP_MAX_SINGLE_FILE_SIZE:[11,4,1,"-"],REACT_APP_MAX_ZIP_FILE_SIZE:[11,4,1,"-"],REACT_APP_THUNDERFOREST_API_KEY:[11,4,1,"-"],REDIS_URL:[11,4,1,"-"],SENDER_EMAIL:[11,4,1,"-"],UI_URL:[11,4,1,"-"],WEATHER_API_KEY:[11,4,1,"-"],WORKERS_PROCESSES:[11,4,1,"-"]},"/api/activities/map_tile/(s)/(z)/(x)/(y)":{png:[0,0,1,"get--api-activities-map_tile-(s)-(z)-(x)-(y).png"]}},objnames:{"0":["http","get","HTTP get"],"1":["http","post","HTTP post"],"2":["http","delete","HTTP delete"],"3":["http","patch","HTTP patch"],"4":["std","envvar","environment variable"]},objtypes:{"0":"http:get","1":"http:post","2":"http:delete","3":"http:patch","4":"std:envvar"},terms:{"0mb":[0,1],"1000":6,"1048576":2,"10485760":2,"10mb":11,"1232004":0,"12341":6,"1234538":0,"1267":6,"127":11,"1563529507772":0,"1mb":11,"200":[0,1,2,4,5,6,7],"201":[0,1],"2017":[0,6],"2018":[0,6,10],"2019":[0,1,4,6,7,10],"2020":10,"204":[0,1,7],"279":0,"280":0,"282":6,"2930":0,"2e1ee2c":8,"3000":[11,12],"301":11,"34614d5":8,"400":[0,1,2,5],"401":[0,1,2,4,5,6,7],"403":[0,1,2,5,6,7],"404":[0,1,5,6,7],"4109":0,"413":[0,1],"443":11,"465":11,"4c3fc34":8,"500":[0,1,2,5,7],"5000":11,"5078118":0,"5079733":0,"5432":11,"587":11,"613":6,"7380":0,"895":[1,7],"9960":6,"boolean":[2,7],"default":[0,6,7,8,11],"export":10,"float":0,"import":11,"int":[0,5],"new":[9,11],"null":[0,1,7],"return":[0,4,11],"static":11,"true":[1,2,5,7,11],"try":[0,1,7],For:11,NOT:[0,1,5],Not:[0,1,5,6,7],One:11,That:1,The:[8,9,11],There:11,Use:8,WITH:11,With:11,__main__:11,_blank:11,accord:10,account:[7,8],acit:0,activ:[3,5,6,8,10,11],activities_count:7,activity_d:[0,4],activity_id:[0,4],activity_uuid:0,adapt:11,add:[7,8,9,10],address:11,admin:[0,1,2,4,5,6,7,8,11],administr:[0,1,7,10,13],after:11,again:[0,1,2,4,5,6,7],all:[4,5,6,7,11],allow:[0,1,2,10,11],along:0,alpinequest:10,alreadi:1,also:10,alwai:11,android:10,anoth:[7,11],anymor:8,apach:10,api:[0,1,2,4,5,6,7,8,9,10,11,12],apikei:11,app:10,app_log:11,app_secret_kei:11,app_set:11,app_work:11,applic:[0,1,2,4,5,6,7,8,9,10,11],arch:11,archiv:[2,9,11],archlinux:11,asc:7,ascent:0,attribut:11,auth:[0,1,2,4,5,6,7],auth_token:1,auth_user_id:[0,2,4,5,6,7],authent:[0,2,3,4,5,6,7,10],author:[0,1,2,4,5,6,7],avail:[4,9,10],ave_spe:0,ave_speed_from:0,ave_speed_to:0,averag:[0,4,8,9],axi:0,b862a77:8,background:8,backup:11,bad:[0,1,2,5],bearer:[0,1,2,4,5,6,7],becom:8,been:8,befor:11,bike:[0,5,8,9],bin:11,bio:[1,7],biographi:1,birth:1,birth_dat:[1,7],bound:0,by_sport:6,by_tim:6,calcul:8,calendar:[8,9],can:[7,8,9,10,11],cannot:8,chang:[9,10,11],charact:[1,13],chart:[0,8,9,11],chart_data:0,check:[2,11,12],choos:8,client:[8,11,12],clone:11,code:[0,1,2,4,5,6,7],color:8,column:13,com:[1,7,11],complet:8,config:[2,11,12],configur:[3,10,11],confirm:1,contact:[0,1,7],contain:[8,11],content:[0,1,2,4,5,6,7],contributor:[2,11],coordin:11,copi:[2,11],copyright:[2,11],correctli:[8,12],creat:[0,1,8,9,11],create_app:11,created_at:[1,7],creation:[8,9],creation_d:0,credenti:[1,11],criteria:7,current:8,custom:[11,12],cycl:[5,8,9],dai:8,dark:11,darkski:[8,9],dashboard:[8,10],data:[0,1,2,4,5,6,7,8,10,11,13],databas:[8,11],database_disable_pool:11,database_url:11,date:[0,1,6,8,9],debian:11,defin:9,definit:8,delet:[0,1,7,8,9],depend:[8,11],deploy:10,desc:0,descent:0,describ:11,descript:11,detail:[7,8,10],develop:[10,11],differ:8,directli:11,directori:11,disabl:[1,8,9,11],displai:[0,8,9,10,11],distanc:[0,4,8,9],distance_from:0,distance_to:0,distribut:11,docker:11,document:[8,10,11],doe:[0,1,6,7,8],don:1,down:8,download:11,dramatiq:11,drop:8,durat:[0,4,8,9],duration_from:0,duration_to:0,dure:[0,1],e060bde05e3f4906a32913b102c814cb:4,easi:8,edit:[1,8,9],elev:[0,8,9,11],els:11,email:[1,7,8],email_url:11,empti:8,enabl:[2,9],encount:11,end:[0,6],endpoint:[2,3,13],english:9,enter:[8,9],entiti:[0,1],entri:11,env:11,environ:[8,10],environn:12,error:[0,1,2,5,7,8,11],europ:[1,7],even:[8,9],exampl:[0,1,2,4,5,6,7,10,11,12],exce:[0,1],except:7,execstart:11,exist:[0,1,6,7,9,10,12],exodu:10,expir:[0,1,2,4,5,6,7],extens:[0,1],f03265f69fe0489b812fc7dc4deff55:0,fa33f4d996844a5c73ecd1ae24456ab8:0,fals:[0,1,2,5,7,11],farest:[4,8,9],featur:[10,11],fetch:11,file:[0,1,2,8,9,10,11,12],filter:[8,9],first:[1,10],first_nam:[1,7],fitotrack:10,fittracke:[9,11],fittrackee_init_data:11,fittrackee_upgrade_db:11,fittrackee_work:11,fix:10,flask:11,flask_app:11,flaticon:11,follow:[4,9,11],forbidden:[0,1,2,5,6,7],forecast:11,form:[0,1],format:[0,1,6],former:11,forrunn:10,forward:11,found:[0,1,5,6,7],frame:6,freepik:11,french:[9,10],fri:0,from:[0,2,4,5,6,7,8,10],fullchain:11,gener:11,get:[0,1,2,4,5,6,7],gif:1,git:11,github:11,given:11,gmt:[0,1,4,7],gpl:10,gpx:[0,8,9,10,11],gpx_limit_import:2,gpxpy:11,grant:11,gunicorn:11,handl:1,has:7,has_act:5,have:[0,2,5,6,7,8],header:[0,1,2,4,5,6,7],health:2,heavi:[10,11],hike:[5,8,9],his:[7,8,9],home:11,host:11,href:[2,11],http:[0,1,2,4,5,6,7,11,12],i18n:8,icon:11,imag:[0,1,7,11],img:5,improv:10,incorrect:8,index:0,info:1,inform:[8,10,11],initi:[11,12],instal:[8,10],instanc:[2,11],integ:[0,2,4,5,6,7],integr:2,interceptor:8,intern:[0,1,2,5,7],introduc:8,invalid:[0,1,2,4,5,6,7],is_act:5,is_registration_en:2,issu:[10,11],jan:0,javascript:11,john_do:7,jpeg:7,jpg:1,json:[0,1,2,4,5,6,7,13],jul:[0,1,4,7],keep:[10,11],kei:[8,9,11],label:5,languag:[1,7],larg:[0,1],last:[1,11],last_nam:[1,7],latitud:0,layer:[8,11],leaflet:[0,11],least:0,librari:11,licens:10,limit:[8,9],line:13,link:11,linux:11,list:[8,10,11],listen:11,load:8,local:[8,10,11],localhost:[11,12],locat:[1,7,11],log:[0,1,2,4,5,6,7,10,11],logfil:11,login:1,logout:[1,8],longest:[4,8,9],longitud:0,made:[11,12],mai:[10,11],mailhog:11,major:8,make:11,makefil:[11,12],manag:8,mandatori:[0,8,11],map:[0,8,9,10],map_attribut:[2,11],map_id:0,map_til:0,match:1,max:[0,2,7],max_alt:0,max_single_file_s:2,max_spe:0,max_speed_from:0,max_speed_to:0,max_us:2,max_zip_file_s:2,maxim:0,maximum:[4,8,9,11],mean:12,messag:[0,1,2],method:11,min_alt:0,minim:0,minor:10,mobil:10,modifi:7,modification_d:0,modul:11,mon:0,mondai:[1,6,9],montain:[8,9],month:[6,8,9],more:[8,10,11],morn:0,mountain:5,mous:8,move:[0,8],mpwoadmin:11,multi:11,multipart:[0,1],must:[1,2,5,8,9,11],name:[1,6,7,11],nano:11,nb_activ:[1,6,7],nb_sport:[1,7],necessari:11,need:11,network:[11,12],next_act:0,nginx:11,no_gpx:0,non:5,noopen:11,noreferr:11,note:[0,8,9,11],now:[8,9,11],number:[0,2,7,9,11],oauth:[0,1,2,4,5,6,7],object:[0,1,2,5,7],one:[0,7],onli:[0,7,8,9,11],open:[10,11],openstreetmap:[2,8,11],opentrack:10,option:11,order:[0,7,8],order_bi:7,org:[2,11],other:[7,11],out:1,outdoor:[8,10,11],over:8,own:[7,10],owner:[8,9],packag:[8,11],page:[0,7],pagin:[0,7],par_pag:7,paramet:[0,1,2,4,5,6,7,8,9,11],pari:[1,7],pars:[11,13],part:[0,1],pass:11,password:[1,8,9,11],password_conf:1,patch:[0,2,5,7],path:11,paus:[0,8],payload:[0,1,2,5],pem:11,per:[0,7],per_pag:[0,7],permiss:[0,2,5,6,7],pg_dump:11,pictur:[0,1,7,11],ping:2,pip:11,pipenv:8,pleas:[0,1,2,4,5,6,7,8],png:[0,1,5,11],poetri:[8,11],point:[8,11],pong:2,pool:11,port:11,possibl:[8,10],post:[0,1],postgr:11,postgresql:11,prefer:1,prerequisit:10,previous_act:0,prior:11,privai:10,privileg:11,privkei:11,process:[1,11],productionconfig:11,profil:1,project:11,proprietari:10,provid:[0,1,2,4,5,6,7,8,9,11],proxi:11,proxy_add_x_forwarded_for:11,proxy_pass:11,proxy_redirect:11,proxy_set_head:11,pull:11,pwd:11,pypi:10,python:[8,11],queri:[0,6,7],queue:11,react:11,react_app_allow_registr:11,react_app_api_url:[11,12],react_app_gpx_limit_import:11,react_app_max_single_file_s:11,react_app_max_zip_file_s:11,react_app_thunderforest_api_kei:11,read:8,real:11,rebuild:12,rechart:[0,11],recommend:11,record:[0,3,8,9,10],record_typ:[0,4],redi:[8,11],redis_url:11,redux:11,regist:[1,2,11],registr:[1,2,8,9],rel:11,relat:11,releas:[10,11],remote_addr:11,remov:9,renam:8,replac:[8,11],repo:11,report:10,repositori:11,request:[0,1,2,4,5,6,7,12],request_uri:11,requir:1,reset:[1,8,9],respons:[0,1,2,4,5,6,7],restart:11,restartsec:11,right:[7,9],rout:8,run:[5,8,9,11],runner:10,sam:[1,7],same:8,samr1:11,sat:7,save:9,schema:11,search:8,second:0,secret:11,see:[8,9,10,11,12],segment:[0,8,9],segment_id:0,select:[0,1],send:[8,11],sender:11,sender_email:11,serv:11,server:[0,1,2,5,7,8,10],server_nam:11,servic:11,set:9,sever:[10,11],should:11,show:8,side:8,signatur:[0,1,2,4,5,6,7],simpl:11,simplifi:8,sinc:11,singl:[2,7],size:[0,1,2,8,9,11],sky:11,smtp:11,some:[0,7,8,10,11],sorri:1,sort:[0,7],sourc:10,spawn:11,speed:[0,4,8,9,11],spinner:8,sport:[0,3,6,8,9,10,11],sport_id:[0,4,5,6],sports_list:[1,7],sql:11,sqlalchemi:11,ssl:11,ssl_certif:11,ssl_certificate_kei:11,standard:[8,11],standarderror:11,standardoutput:11,start:[0,1,6,9,11],startlimitintervalsec:11,starttl:11,stat:[6,8],staticmap:11,statist:[3,10],statu:[0,1,2,4,5,6,7],step:11,still:10,stop:11,store:[10,11],street:10,string:[0,1,5,6,7],subdomain:0,success:[0,1,2,4,5,6,7],successfulli:1,sun:[0,1,4,7],sundai:[0,6,9],support:[8,9],syslog:11,syslogidentifi:11,system:11,systemd:11,tab:12,tar:11,target:11,task:11,term:11,test:11,than:8,thei:11,them:10,thi:[0,8,9,10,11],thunderforest:[8,11],tile:[0,8],tile_server_url:11,time:[0,1,6,8,9],timezon:[1,7,8],titl:0,tls:11,todo:14,token:[0,1,2,4,5,6,7],too:[0,1],tooltip:8,total:8,total_dist:[1,6,7],total_dur:[1,6,7],track:10,tracker:10,transport:[5,8,9],troubleshoot:10,type:[0,1,2,4,5,6,7,11],ui_url:11,unauthor:[0,1,2,4,5,6,7],undefin:12,under:[10,11],unencrypt:11,unexpect:13,unit:11,unstabl:[10,11],updat:[0,1,2,5,7,8,9,11],upload:[8,9,11],upload_fold:11,uploads_dir_s:6,url:[8,11],use:11,used:11,user:[0,1,2,3,4,5,6,8,9,10,11,13],user_nam:[6,7],usernam:[1,7,11],usernanm:1,using:[0,7,10,11],uuid:0,valid:[0,1,2,4,5,6,7,11],valu:[0,4],variabl:[8,10,12],venv:11,version:[10,11],view:8,virtualenv:11,wai:11,walk:[5,8,9],wantedbi:11,warn:8,weather:[8,9,11],weather_api:11,weather_api_kei:11,weather_end:0,weather_start:0,web:[0,1,2,4,5,6,7,10,11],week:[1,6,8,9],weekend:8,weekm:[1,6],were:8,wget:11,when:[8,11],where:11,which:9,with_gpx:0,without:[0,6,7,8,9,10],worker:11,workers_process:11,workingdirectori:11,workout:10,written:11,www:[2,11],xxxx:11,xzf:11,yai:11,yarn:11,year:6,yet:10,you:[0,2,5,6,7,10],your:[7,10,11],zip:[0,2,9,11],zone:1,zoom:0},titles:["Activities","Authentication","Configuration","API documentation","Records","Sports","Statistics","Users","Change log","Features","FitTrackee","Installation","Administrator","Troubleshooting","User"],titleterms:{"2018":8,"2019":8,"2020":8,"new":8,account:9,activ:[0,9],administr:[8,9,12],api:3,authent:1,avail:8,bug:8,chang:8,charact:12,close:8,column:12,configur:2,content:10,dashboard:9,data:12,deploy:11,deprec:11,detail:9,dev:11,document:3,email:11,environ:11,featur:[8,9],first:8,fittracke:[8,10],fix:8,french:8,from:11,improv:8,instal:11,issu:8,json:12,line:12,list:9,log:8,map:11,minor:8,misc:8,pars:12,prerequisit:11,prod:11,product:11,pypi:[8,11],record:4,releas:8,server:11,sourc:11,sport:5,statist:[6,8,9],tabl:10,tile:11,translat:9,troubleshoot:13,unexpect:12,upgrad:11,user:[7,14],variabl:11,version:8,workout:9}}) \ No newline at end of file +Search.setIndex({docnames:["api/activities","api/auth","api/configuration","api/index","api/records","api/sports","api/stats","api/users","changelog","features","index","installation","troubleshooting/administrator","troubleshooting/index","troubleshooting/user"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,sphinx:56},filenames:["api/activities.rst","api/auth.rst","api/configuration.rst","api/index.rst","api/records.rst","api/sports.rst","api/stats.rst","api/users.rst","changelog.md","features.rst","index.rst","installation.rst","troubleshooting/administrator.rst","troubleshooting/index.rst","troubleshooting/user.rst"],objects:{"":{"/api/activities":[0,1,1,"post--api-activities"],"/api/activities/(string:activity_short_id)":[0,3,1,"patch--api-activities-(string-activity_short_id)"],"/api/activities/(string:activity_short_id)/chart_data":[0,0,1,"get--api-activities-(string-activity_short_id)-chart_data"],"/api/activities/(string:activity_short_id)/chart_data/segment/(int:segment_id)":[0,0,1,"get--api-activities-(string-activity_short_id)-chart_data-segment-(int-segment_id)"],"/api/activities/(string:activity_short_id)/gpx":[0,0,1,"get--api-activities-(string-activity_short_id)-gpx"],"/api/activities/(string:activity_short_id)/gpx/segment/(int:segment_id)":[0,0,1,"get--api-activities-(string-activity_short_id)-gpx-segment-(int-segment_id)"],"/api/activities/map/(map_id)":[0,0,1,"get--api-activities-map-(map_id)"],"/api/activities/no_gpx":[0,1,1,"post--api-activities-no_gpx"],"/api/auth/login":[1,1,1,"post--api-auth-login"],"/api/auth/logout":[1,0,1,"get--api-auth-logout"],"/api/auth/password/reset-request":[1,1,1,"post--api-auth-password-reset-request"],"/api/auth/password/update":[1,1,1,"post--api-auth-password-update"],"/api/auth/picture":[1,1,1,"post--api-auth-picture"],"/api/auth/profile":[1,0,1,"get--api-auth-profile"],"/api/auth/profile/edit":[1,1,1,"post--api-auth-profile-edit"],"/api/auth/register":[1,1,1,"post--api-auth-register"],"/api/config":[2,3,1,"patch--api-config"],"/api/ping":[2,0,1,"get--api-ping"],"/api/records":[4,0,1,"get--api-records"],"/api/sports":[5,0,1,"get--api-sports"],"/api/sports/(int:sport_id)":[5,3,1,"patch--api-sports-(int-sport_id)"],"/api/stats/(user_name)/by_sport":[6,0,1,"get--api-stats-(user_name)-by_sport"],"/api/stats/(user_name)/by_time":[6,0,1,"get--api-stats-(user_name)-by_time"],"/api/stats/all":[6,0,1,"get--api-stats-all"],"/api/users":[7,0,1,"get--api-users"],"/api/users/(user_name)":[7,3,1,"patch--api-users-(user_name)"],"/api/users/(user_name)/picture":[7,0,1,"get--api-users-(user_name)-picture"],"APP_LOG \ud83c\udd95":[11,4,1,"envvar-APP_LOG"],"DATABASE_DISABLE_POOLING \ud83c\udd95":[11,4,1,"envvar-DATABASE_DISABLE_POOLING"],"MAP_ATTRIBUTION \ud83c\udd95":[11,4,1,"envvar-MAP_ATTRIBUTION"],"TILE_SERVER_URL \ud83c\udd95":[11,4,1,"envvar-TILE_SERVER_URL"],"UPLOAD_FOLDER \ud83c\udd95":[11,4,1,"envvar-UPLOAD_FOLDER"],APP_SECRET_KEY:[11,4,1,"-"],APP_SETTINGS:[11,4,1,"-"],APP_WORKERS:[11,4,1,"-"],DATABASE_URL:[11,4,1,"-"],EMAIL_URL:[11,4,1,"-"],FLASK_APP:[11,4,1,"-"],HOST:[11,4,1,"-"],PORT:[11,4,1,"-"],REACT_APP_ALLOW_REGISTRATION:[11,4,1,"-"],REACT_APP_API_URL:[11,4,1,"-"],REACT_APP_GPX_LIMIT_IMPORT:[11,4,1,"-"],REACT_APP_MAX_SINGLE_FILE_SIZE:[11,4,1,"-"],REACT_APP_MAX_ZIP_FILE_SIZE:[11,4,1,"-"],REACT_APP_THUNDERFOREST_API_KEY:[11,4,1,"-"],REDIS_URL:[11,4,1,"-"],SENDER_EMAIL:[11,4,1,"-"],UI_URL:[11,4,1,"-"],WEATHER_API_KEY:[11,4,1,"-"],WORKERS_PROCESSES:[11,4,1,"-"]},"/api/activities/map_tile/(s)/(z)/(x)/(y)":{png:[0,0,1,"get--api-activities-map_tile-(s)-(z)-(x)-(y).png"]}},objnames:{"0":["http","get","HTTP get"],"1":["http","post","HTTP post"],"2":["http","delete","HTTP delete"],"3":["http","patch","HTTP patch"],"4":["std","envvar","environment variable"]},objtypes:{"0":"http:get","1":"http:post","2":"http:delete","3":"http:patch","4":"std:envvar"},terms:{"0mb":[0,1],"1000":6,"1048576":2,"10485760":2,"10mb":11,"1232004":0,"12341":6,"1234538":0,"1267":6,"127":11,"1563529507772":0,"1mb":11,"200":[0,1,2,4,5,6,7],"201":[0,1],"2017":[0,6],"2018":[0,6,10],"2019":[0,1,4,6,7,10],"2020":10,"204":[0,1,7],"279":0,"280":0,"282":6,"2930":0,"2e1ee2c":8,"3000":[11,12],"301":11,"34614d5":8,"400":[0,1,2,5],"401":[0,1,2,4,5,6,7],"403":[0,1,2,5,6,7],"404":[0,1,5,6,7],"4109":0,"413":[0,1],"443":11,"465":11,"4c3fc34":8,"500":[0,1,2,5,7],"5000":11,"5078118":0,"5079733":0,"5432":11,"587":11,"613":6,"7380":0,"895":[1,7],"9960":6,"boolean":[2,7],"default":[0,6,7,8,11],"export":10,"float":0,"import":11,"int":[0,5],"new":[9,11],"null":[0,1,7],"return":[0,4,11],"short":0,"static":11,"true":[1,2,5,7,11],"try":[0,1,7],For:11,NOT:[0,1,5],Not:[0,1,5,6,7],One:11,That:1,The:[8,9,11],There:11,Use:8,WITH:11,With:11,__main__:11,_blank:11,accord:10,account:[7,8],acit:0,activ:[3,5,6,8,10,11],activities_count:7,activity_d:[0,4],activity_id:[0,4],activity_short_id:0,adapt:11,add:[7,8,9,10],address:11,admin:[0,1,2,4,5,6,7,8,11],administr:[0,1,7,10,13],after:11,again:[0,1,2,4,5,6,7],all:[4,5,6,7,11],allow:[0,1,2,10,11],along:0,alpinequest:10,alreadi:1,also:10,alwai:11,android:10,anoth:[7,11],anymor:8,apach:10,api:[0,1,2,4,5,6,7,8,9,10,11,12],apikei:11,app:10,app_log:11,app_secret_kei:11,app_set:11,app_work:11,applic:[0,1,2,4,5,6,7,8,9,10,11],arch:11,archiv:[2,9,11],archlinux:11,asc:7,ascent:0,attribut:11,auth:[0,1,2,4,5,6,7],auth_token:1,auth_user_id:[0,2,4,5,6,7],authent:[0,2,3,4,5,6,7,10],author:[0,1,2,4,5,6,7],avail:[4,9,10],ave_spe:0,ave_speed_from:0,ave_speed_to:0,averag:[0,4,8,9],axi:0,b862a77:8,background:8,backup:11,bad:[0,1,2,5],bearer:[0,1,2,4,5,6,7],becom:8,been:8,befor:11,bike:[0,5,8,9],bin:11,bio:[1,7],biographi:1,birth:1,birth_dat:[1,7],bound:0,by_sport:6,by_tim:6,calcul:8,calendar:[8,9],can:[7,8,9,10,11],cannot:8,chang:[9,10,11],charact:[1,13],chart:[0,8,9,11],chart_data:0,check:[2,11,12],choos:8,client:[8,11,12],clone:11,code:[0,1,2,4,5,6,7],color:8,column:13,com:[1,7,11],complet:8,config:[2,11,12],configur:[3,10,11],confirm:1,contact:[0,1,7],contain:[8,11],content:[0,1,2,4,5,6,7],contributor:[2,11],coordin:11,copi:[2,11],copyright:[2,11],correctli:[8,12],creat:[0,1,8,9,11],create_app:11,created_at:[1,7],creation:[8,9],creation_d:0,credenti:[1,11],criteria:7,current:8,custom:[11,12],cycl:[5,8,9],dai:8,dark:11,darkski:[8,9],dashboard:[8,10],data:[0,1,2,4,5,6,7,8,10,11,13],databas:[8,11],database_disable_pool:11,database_url:11,date:[0,1,6,8,9],debian:11,defin:9,definit:8,delet:[0,1,7,8,9],depend:[8,11],deploy:10,desc:0,descent:0,describ:11,descript:11,detail:[7,8,10],develop:[10,11],differ:8,directli:11,directori:11,disabl:[1,8,9,11],displai:[0,8,9,10,11],distanc:[0,4,8,9],distance_from:0,distance_to:0,distribut:11,docker:11,document:[8,10,11],doe:[0,1,6,7,8],don:1,down:8,download:11,dramatiq:11,drop:8,durat:[0,4,8,9],duration_from:0,duration_to:0,dure:[0,1],easi:8,edit:[1,8,9],elev:[0,8,9,11],els:11,email:[1,7,8],email_url:11,empti:8,enabl:[2,9],encount:11,end:[0,6],endpoint:[2,3,13],english:9,enter:[8,9],entiti:[0,1],entri:11,env:11,environ:[8,10],environn:12,error:[0,1,2,5,7,8,11],europ:[1,7],even:[8,9],exampl:[0,1,2,4,5,6,7,10,11,12],exce:[0,1],except:7,execstart:11,exist:[0,1,6,7,9,10,12],exodu:10,expir:[0,1,2,4,5,6,7],extens:[0,1],fa33f4d996844a5c73ecd1ae24456ab8:0,fals:[0,1,2,5,7,11],farest:[4,8,9],featur:[10,11],fetch:11,file:[0,1,2,8,9,10,11,12],filter:[8,9],first:[1,10],first_nam:[1,7],fitotrack:10,fittracke:[9,11],fittrackee_init_data:11,fittrackee_upgrade_db:11,fittrackee_work:11,fix:10,flask:11,flask_app:11,flaticon:11,follow:[4,9,11],forbidden:[0,1,2,5,6,7],forecast:11,form:[0,1],format:[0,1,6],former:11,forrunn:10,forward:11,found:[0,1,5,6,7],frame:6,freepik:11,french:[9,10],fri:0,from:[0,2,4,5,6,7,8,10],fullchain:11,gener:11,get:[0,1,2,4,5,6,7],gif:1,git:11,github:11,given:11,gmt:[0,1,4,7],gpl:10,gpx:[0,8,9,10,11],gpx_limit_import:2,gpxpy:11,grant:11,gunicorn:11,handl:1,has:7,has_act:5,have:[0,2,5,6,7,8],header:[0,1,2,4,5,6,7],health:2,heavi:[10,11],hike:[5,8,9],his:[7,8,9],home:11,host:11,href:[2,11],http:[0,1,2,4,5,6,7,11,12],hvybqybra7wwxpastwr4v2:4,i18n:8,icon:11,imag:[0,1,7,11],img:5,improv:10,incorrect:8,index:0,info:1,inform:[8,10,11],initi:[11,12],instal:[8,10],instanc:[2,11],integ:[0,2,4,5,6,7],integr:2,interceptor:8,intern:[0,1,2,5,7],introduc:8,invalid:[0,1,2,4,5,6,7],is_act:5,is_registration_en:2,issu:[10,11],jan:0,javascript:11,john_do:7,jpeg:7,jpg:1,json:[0,1,2,4,5,6,7,13],jul:[0,1,4,7],keep:[10,11],kei:[8,9,11],kjxavsturjvoah2wvcegef:0,label:5,languag:[1,7],larg:[0,1],last:[1,11],last_nam:[1,7],latitud:0,layer:[8,11],leaflet:[0,11],least:0,librari:11,licens:10,limit:[8,9],line:13,link:11,linux:11,list:[8,10,11],listen:11,load:8,local:[8,10,11],localhost:[11,12],locat:[1,7,11],log:[0,1,2,4,5,6,7,10,11],logfil:11,login:1,logout:[1,8],longest:[4,8,9],longitud:0,made:[11,12],mai:[10,11],mailhog:11,major:8,make:11,makefil:[11,12],manag:8,mandatori:[0,8,11],map:[0,8,9,10],map_attribut:[2,11],map_id:0,map_til:0,match:1,max:[0,2,7],max_alt:0,max_single_file_s:2,max_spe:0,max_speed_from:0,max_speed_to:0,max_us:2,max_zip_file_s:2,maxim:0,maximum:[4,8,9,11],mean:12,messag:[0,1,2],method:11,min_alt:0,minim:0,minor:10,mobil:10,modifi:7,modification_d:0,modul:11,mon:0,mondai:[1,6,9],montain:[8,9],month:[6,8,9],more:[8,10,11],morn:0,mountain:5,mous:8,move:[0,8],mpwoadmin:11,multi:11,multipart:[0,1],must:[1,2,5,8,9,11],name:[1,6,7,11],nano:11,nb_activ:[1,6,7],nb_sport:[1,7],necessari:11,need:11,network:[11,12],next_act:0,nginx:11,no_gpx:0,non:5,noopen:11,noreferr:11,note:[0,8,9,11],now:[8,9,11],number:[0,2,7,9,11],oauth:[0,1,2,4,5,6,7],object:[0,1,2,5,7],one:[0,7],onli:[0,7,8,9,11],open:[10,11],openstreetmap:[2,8,11],opentrack:10,option:11,order:[0,7,8],order_bi:7,org:[2,11],other:[7,11],out:1,outdoor:[8,10,11],over:8,own:[7,10],owner:[8,9],packag:[8,11],page:[0,7],pagin:[0,7],par_pag:7,paramet:[0,1,2,4,5,6,7,8,9,11],pari:[1,7],pars:[11,13],part:[0,1],pass:11,password:[1,8,9,11],password_conf:1,patch:[0,2,5,7],path:11,paus:[0,8],payload:[0,1,2,5],pem:11,per:[0,7],per_pag:[0,7],permiss:[0,2,5,6,7],pg_dump:11,pictur:[0,1,7,11],ping:2,pip:11,pipenv:8,pleas:[0,1,2,4,5,6,7,8],png:[0,1,5,11],poetri:[8,11],point:[8,11],pong:2,pool:11,port:11,possibl:[8,10],post:[0,1],postgr:11,postgresql:11,prefer:1,prerequisit:10,previous_act:0,prior:11,privai:10,privileg:11,privkei:11,process:[1,11],productionconfig:11,profil:1,project:11,proprietari:10,provid:[0,1,2,4,5,6,7,8,9,11],proxi:11,proxy_add_x_forwarded_for:11,proxy_pass:11,proxy_redirect:11,proxy_set_head:11,pull:11,pwd:11,pypi:10,python:[8,11],queri:[0,6,7],queue:11,react:11,react_app_allow_registr:11,react_app_api_url:[11,12],react_app_gpx_limit_import:11,react_app_max_single_file_s:11,react_app_max_zip_file_s:11,react_app_thunderforest_api_kei:11,read:8,real:11,rebuild:12,rechart:[0,11],recommend:11,record:[0,3,8,9,10],record_typ:[0,4],redi:[8,11],redis_url:11,redux:11,regist:[1,2,11],registr:[1,2,8,9],rel:11,relat:11,releas:[10,11],remote_addr:11,remov:9,renam:8,replac:[8,11],repo:11,report:10,repositori:11,request:[0,1,2,4,5,6,7,12],request_uri:11,requir:1,reset:[1,8,9],respons:[0,1,2,4,5,6,7],restart:11,restartsec:11,right:[7,9],rout:8,run:[5,8,9,11],runner:10,sam:[1,7],same:8,samr1:11,sat:7,save:9,schema:11,search:8,second:0,secret:11,see:[8,9,10,11,12],segment:[0,8,9],segment_id:0,select:[0,1],send:[8,11],sender:11,sender_email:11,serv:11,server:[0,1,2,5,7,8,10],server_nam:11,servic:11,set:9,sever:[10,11],should:11,show:8,side:8,signatur:[0,1,2,4,5,6,7],simpl:11,simplifi:8,sinc:11,singl:[2,7],size:[0,1,2,8,9,11],sky:11,smtp:11,some:[0,7,8,10,11],sorri:1,sort:[0,7],sourc:10,spawn:11,speed:[0,4,8,9,11],spinner:8,sport:[0,3,6,8,9,10,11],sport_id:[0,4,5,6],sports_list:[1,7],sql:11,sqlalchemi:11,ssl:11,ssl_certif:11,ssl_certificate_kei:11,standard:[8,11],standarderror:11,standardoutput:11,start:[0,1,6,9,11],startlimitintervalsec:11,starttl:11,stat:[6,8],staticmap:11,statist:[3,10],statu:[0,1,2,4,5,6,7],step:11,still:10,stop:11,store:[10,11],street:10,string:[0,1,5,6,7],subdomain:0,success:[0,1,2,4,5,6,7],successfulli:1,sun:[0,1,4,7],sundai:[0,6,9],support:[8,9],syslog:11,syslogidentifi:11,system:11,systemd:11,tab:12,tar:11,target:11,task:11,term:11,test:11,than:8,thei:11,them:10,thi:[0,8,9,10,11],thunderforest:[8,11],tile:[0,8],tile_server_url:11,time:[0,1,6,8,9],timezon:[1,7,8],titl:0,tls:11,todo:14,token:[0,1,2,4,5,6,7],too:[0,1],tooltip:8,total:8,total_dist:[1,6,7],total_dur:[1,6,7],track:10,tracker:10,transport:[5,8,9],troubleshoot:10,type:[0,1,2,4,5,6,7,11],ui_url:11,unauthor:[0,1,2,4,5,6,7],undefin:12,under:[10,11],unencrypt:11,unexpect:13,unit:11,unstabl:[10,11],updat:[0,1,2,5,7,8,9,11],upload:[8,9,11],upload_fold:11,uploads_dir_s:6,url:[8,11],use:11,used:11,user:[0,1,2,3,4,5,6,8,9,10,11,13],user_nam:[6,7],usernam:[1,7,11],usernanm:1,using:[0,7,10,11],uuid:0,valid:[0,1,2,4,5,6,7,11],valu:[0,4],variabl:[8,10,12],venv:11,version:[10,11],view:8,virtualenv:11,wai:11,walk:[5,8,9],wantedbi:11,warn:8,weather:[8,9,11],weather_api:11,weather_api_kei:11,weather_end:0,weather_start:0,web:[0,1,2,4,5,6,7,10,11],week:[1,6,8,9],weekend:8,weekm:[1,6],were:8,wget:11,when:[8,11],where:11,which:9,with_gpx:0,without:[0,6,7,8,9,10],worker:11,workers_process:11,workingdirectori:11,workout:10,written:11,www:[2,11],xxxx:11,xzf:11,yai:11,yarn:11,year:6,yet:10,you:[0,2,5,6,7,10],your:[7,10,11],zip:[0,2,9,11],zone:1,zoom:0},titles:["Activities","Authentication","Configuration","API documentation","Records","Sports","Statistics","Users","Change log","Features","FitTrackee","Installation","Administrator","Troubleshooting","User"],titleterms:{"2018":8,"2019":8,"2020":8,"new":8,account:9,activ:[0,9],administr:[8,9,12],api:3,authent:1,avail:8,bug:8,chang:8,charact:12,close:8,column:12,configur:2,content:10,dashboard:9,data:12,deploy:11,deprec:11,detail:9,dev:11,document:3,email:11,environ:11,featur:[8,9],first:8,fittracke:[8,10],fix:8,french:8,from:11,improv:8,instal:11,issu:8,json:12,line:12,list:9,log:8,map:11,minor:8,misc:8,pars:12,prerequisit:11,prod:11,product:11,pypi:[8,11],record:4,releas:8,server:11,sourc:11,sport:5,statist:[6,8,9],tabl:10,tile:11,translat:9,troubleshoot:13,unexpect:12,upgrad:11,user:[7,14],variabl:11,version:8,workout:9}}) \ No newline at end of file diff --git a/fittrackee/activities/activities.py b/fittrackee/activities/activities.py index 7132b7e9..6061e2e2 100644 --- a/fittrackee/activities/activities.py +++ b/fittrackee/activities/activities.py @@ -29,6 +29,7 @@ from .utils_gpx import ( extract_segment_from_gpx_file, get_chart_data, ) +from .utils_id import decode_short_id activities_blueprint = Blueprint('activities', __name__) @@ -76,7 +77,7 @@ def get_activities(auth_user_id): "descent": null, "distance": 10.0, "duration": "0:17:04", - "id": "f03265f69fe0489b812fc7dc4deff55e", + "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 10.0, @@ -90,7 +91,7 @@ def get_activities(auth_user_id): "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -99,7 +100,7 @@ def get_activities(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -108,7 +109,7 @@ def get_activities(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -117,7 +118,7 @@ def get_activities(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -270,10 +271,10 @@ def get_activities(auth_user_id): @activities_blueprint.route( - '/activities/', methods=['GET'] + '/activities/', methods=['GET'] ) @authenticate -def get_activity(auth_user_id, activity_uuid): +def get_activity(auth_user_id, activity_short_id): """ Get an activity @@ -281,7 +282,7 @@ def get_activity(auth_user_id, activity_uuid): .. sourcecode:: http - GET /api/activities/f03265f69fe0489b812fc7dc4deff55e HTTP/1.1 + GET /api/activities/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1 **Example responses**: @@ -304,7 +305,7 @@ def get_activity(auth_user_id, activity_uuid): "descent": null, "distance": 12, "duration": "0:45:00", - "id": "f03265f69fe0489b812fc7dc4deff55e", + "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 16, @@ -344,7 +345,7 @@ def get_activity(auth_user_id, activity_uuid): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :reqheader Authorization: OAuth 2.0 Bearer Token @@ -357,6 +358,7 @@ def get_activity(auth_user_id, activity_uuid): :statuscode 404: activity not found """ + activity_uuid = decode_short_id(activity_short_id) activity = Activity.query.filter_by(uuid=activity_uuid).first() activities_list = [] @@ -381,8 +383,11 @@ def get_activity(auth_user_id, activity_uuid): return jsonify(response_object), code -def get_activity_data(auth_user_id, activity_uuid, data_type, segment_id=None): +def get_activity_data( + auth_user_id, activity_short_id, data_type, segment_id=None +): """Get data from an activity gpx file""" + activity_uuid = decode_short_id(activity_short_id) activity = Activity.query.filter_by(uuid=activity_uuid).first() content = '' if activity: @@ -392,7 +397,9 @@ def get_activity_data(auth_user_id, activity_uuid, data_type, segment_id=None): if response_object: return jsonify(response_object), code if not activity.gpx or activity.gpx == '': - message = f'No gpx file for this activity (id: {activity_uuid})' + message = ( + f'No gpx file for this activity (id: {activity_short_id})' + ) response_object = {'status': 'error', 'message': message} return jsonify(response_object), 404 @@ -422,7 +429,7 @@ def get_activity_data(auth_user_id, activity_uuid, data_type, segment_id=None): code = 200 else: status = 'not found' - message = f'Activity not found (id: {activity_uuid})' + message = f'Activity not found (id: {activity_short_id})' code = 404 response_object = { @@ -438,10 +445,10 @@ def get_activity_data(auth_user_id, activity_uuid, data_type, segment_id=None): @activities_blueprint.route( - '/activities//gpx', methods=['GET'] + '/activities//gpx', methods=['GET'] ) @authenticate -def get_activity_gpx(auth_user_id, activity_uuid): +def get_activity_gpx(auth_user_id, activity_short_id): """ Get gpx file for an activity displayed on map with Leaflet @@ -449,7 +456,7 @@ def get_activity_gpx(auth_user_id, activity_uuid): .. sourcecode:: http - GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx HTTP/1.1 + GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx HTTP/1.1 Content-Type: application/json **Example response**: @@ -468,7 +475,7 @@ def get_activity_gpx(auth_user_id, activity_uuid): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :reqheader Authorization: OAuth 2.0 Bearer Token @@ -483,14 +490,14 @@ def get_activity_gpx(auth_user_id, activity_uuid): :statuscode 500: """ - return get_activity_data(auth_user_id, activity_uuid, 'gpx') + return get_activity_data(auth_user_id, activity_short_id, 'gpx') @activities_blueprint.route( - '/activities//chart_data', methods=['GET'] + '/activities//chart_data', methods=['GET'] ) @authenticate -def get_activity_chart_data(auth_user_id, activity_uuid): +def get_activity_chart_data(auth_user_id, activity_short_id): """ Get chart data from an activity gpx file, to display it with Recharts @@ -498,7 +505,7 @@ def get_activity_chart_data(auth_user_id, activity_uuid): .. sourcecode:: http - GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/chart HTTP/1.1 + GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/chart HTTP/1.1 Content-Type: application/json **Example response**: @@ -536,7 +543,7 @@ def get_activity_chart_data(auth_user_id, activity_uuid): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :reqheader Authorization: OAuth 2.0 Bearer Token @@ -551,15 +558,15 @@ def get_activity_chart_data(auth_user_id, activity_uuid): :statuscode 500: """ - return get_activity_data(auth_user_id, activity_uuid, 'chart') + return get_activity_data(auth_user_id, activity_short_id, 'chart') @activities_blueprint.route( - '/activities//gpx/segment/', + '/activities//gpx/segment/', methods=['GET'], ) @authenticate -def get_segment_gpx(auth_user_id, activity_uuid, segment_id): +def get_segment_gpx(auth_user_id, activity_short_id, segment_id): """ Get gpx file for an activity segment displayed on map with Leaflet @@ -567,8 +574,7 @@ def get_segment_gpx(auth_user_id, activity_uuid, segment_id): .. sourcecode:: http - GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx/segment/0 - HTTP/1.1 + GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx/segment/0 HTTP/1.1 Content-Type: application/json **Example response**: @@ -587,7 +593,7 @@ def get_segment_gpx(auth_user_id, activity_uuid, segment_id): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :param integer segment_id: segment id :reqheader Authorization: OAuth 2.0 Bearer Token @@ -602,15 +608,18 @@ def get_segment_gpx(auth_user_id, activity_uuid, segment_id): :statuscode 500: """ - return get_activity_data(auth_user_id, activity_uuid, 'gpx', segment_id) + return get_activity_data( + auth_user_id, activity_short_id, 'gpx', segment_id + ) @activities_blueprint.route( - '/activities//chart_data/segment/', + '/activities//chart_data/segment/' + '', methods=['GET'], ) @authenticate -def get_segment_chart_data(auth_user_id, activity_uuid, segment_id): +def get_segment_chart_data(auth_user_id, activity_short_id, segment_id): """ Get chart data from an activity gpx file, to display it with Recharts @@ -618,8 +627,7 @@ def get_segment_chart_data(auth_user_id, activity_uuid, segment_id): .. sourcecode:: http - GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/chart/segment/0 - HTTP/1.1 + GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/chart/segment/0 HTTP/1.1 Content-Type: application/json **Example response**: @@ -657,7 +665,7 @@ def get_segment_chart_data(auth_user_id, activity_uuid, segment_id): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :param integer segment_id: segment id :reqheader Authorization: OAuth 2.0 Bearer Token @@ -672,7 +680,9 @@ def get_segment_chart_data(auth_user_id, activity_uuid, segment_id): :statuscode 500: """ - return get_activity_data(auth_user_id, activity_uuid, 'chart', segment_id) + return get_activity_data( + auth_user_id, activity_short_id, 'chart', segment_id + ) @activities_blueprint.route('/activities/map/', methods=['GET']) @@ -794,7 +804,7 @@ def post_activity(auth_user_id): "descent": null, "distance": 10.0, "duration": "0:17:04", - "id": "f03265f69fe0489b812fc7dc4deff55e", + "id": "kjxavSTUrJvoAh2wvCeGEF", "map": null, "max_alt": null, "max_speed": 10.0, @@ -808,7 +818,7 @@ def post_activity(auth_user_id): "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -817,7 +827,7 @@ def post_activity(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -826,7 +836,7 @@ def post_activity(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -835,7 +845,7 @@ def post_activity(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -883,7 +893,7 @@ def post_activity(auth_user_id): if response_object['status'] != 'success': return jsonify(response_object), response_code - activity_data = json.loads(request.form["data"]) + activity_data = json.loads(request.form['data']) if not activity_data or activity_data.get('sport_id') is None: response_object = {'status': 'error', 'message': 'Invalid payload.'} return jsonify(response_object), 400 @@ -972,7 +982,7 @@ def post_activity_no_gpx(auth_user_id): "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -981,7 +991,7 @@ def post_activity_no_gpx(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -990,7 +1000,7 @@ def post_activity_no_gpx(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -999,7 +1009,7 @@ def post_activity_no_gpx(auth_user_id): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -1011,7 +1021,7 @@ def post_activity_no_gpx(auth_user_id): "sport_id": 1, "title": null, "user": "admin", - "uuid": "f03265f69fe0489b812fc7dc4deff55e" + "uuid": "kjxavSTUrJvoAh2wvCeGEF" "weather_end": null, "weather_start": null, "with_gpx": false @@ -1075,10 +1085,10 @@ def post_activity_no_gpx(auth_user_id): @activities_blueprint.route( - '/activities/', methods=['PATCH'] + '/activities/', methods=['PATCH'] ) @authenticate -def update_activity(auth_user_id, activity_uuid): +def update_activity(auth_user_id, activity_short_id): """ Update an activity @@ -1121,7 +1131,7 @@ def update_activity(auth_user_id, activity_uuid): "records": [ { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 4, "record_type": "MS", "sport_id": 1, @@ -1130,7 +1140,7 @@ def update_activity(auth_user_id, activity_uuid): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 3, "record_type": "LD", "sport_id": 1, @@ -1139,7 +1149,7 @@ def update_activity(auth_user_id, activity_uuid): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 2, "record_type": "FD", "sport_id": 1, @@ -1148,7 +1158,7 @@ def update_activity(auth_user_id, activity_uuid): }, { "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT", - "activity_id": "f03265f69fe0489b812fc7dc4deff55e", + "activity_id": "kjxavSTUrJvoAh2wvCeGEF", "id": 1, "record_type": "AS", "sport_id": 1, @@ -1160,7 +1170,7 @@ def update_activity(auth_user_id, activity_uuid): "sport_id": 1, "title": null, "user": "admin", - "uuid": "f03265f69fe0489b812fc7dc4deff55e" + "uuid": "kjxavSTUrJvoAh2wvCeGEF" "weather_end": null, "weather_start": null, "with_gpx": false @@ -1171,7 +1181,7 @@ def update_activity(auth_user_id, activity_uuid): } :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :', methods=['DELETE'] + '/activities/', methods=['DELETE'] ) @authenticate -def delete_activity(auth_user_id, activity_uuid): +def delete_activity(auth_user_id, activity_short_id): """ Delete an activity @@ -1245,7 +1256,7 @@ def delete_activity(auth_user_id, activity_uuid): .. sourcecode:: http - DELETE /api/activities/f03265f69fe0489b812fc7dc4deff55e HTTP/1.1 + DELETE /api/activities/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1 Content-Type: application/json **Example response**: @@ -1256,7 +1267,7 @@ def delete_activity(auth_user_id, activity_uuid): Content-Type: application/json :param integer auth_user_id: authenticate user id (from JSON Web Token) - :param integer activity_uuid: activity uuid + :param string activity_short_id: activity short id :reqheader Authorization: OAuth 2.0 Bearer Token @@ -1271,6 +1282,7 @@ def delete_activity(auth_user_id, activity_uuid): """ try: + activity_uuid = decode_short_id(activity_short_id) activity = Activity.query.filter_by(uuid=activity_uuid).first() if activity: response_object, code = can_view_activity( diff --git a/fittrackee/activities/models.py b/fittrackee/activities/models.py index 60272dbc..f66fbc44 100644 --- a/fittrackee/activities/models.py +++ b/fittrackee/activities/models.py @@ -11,6 +11,7 @@ from sqlalchemy.types import JSON, Enum from .utils_files import get_absolute_file_path from .utils_format import convert_in_duration, convert_value_to_integer +from .utils_id import encode_uuid record_types = [ 'AS', # 'Best Average Speed' @@ -147,6 +148,10 @@ class Activity(db.Model): self.distance = distance self.duration = duration + @property + def short_id(self): + return encode_uuid(self.uuid) + def serialize(self, params=None): date_from = params.get('from') if params else None date_to = params.get('to') if params else None @@ -234,7 +239,7 @@ class Activity(db.Model): .first() ) return { - "id": self.uuid.hex, # WARNING: client use uuid as id + "id": self.short_id, # WARNING: client use uuid as id "user": self.user.username, "sport_id": self.sport_id, "title": self.title, @@ -255,10 +260,10 @@ class Activity(db.Model): "bounds": [float(bound) for bound in self.bounds] if self.bounds else [], # noqa - "previous_activity": previous_activity.uuid.hex + "previous_activity": previous_activity.short_id if previous_activity else None, # noqa - "next_activity": next_activity.uuid.hex if next_activity else None, + "next_activity": next_activity.short_id if next_activity else None, "segments": [segment.serialize() for segment in self.segments], "records": [record.serialize() for record in self.records], "map": self.map_id if self.map else None, @@ -351,7 +356,7 @@ class ActivitySegment(db.Model): def __str__(self): return ( f'' + f'for activity \'{encode_uuid(self.activity_uuid)}\'>' ) def __init__(self, segment_id, activity_id, activity_uuid): @@ -361,7 +366,7 @@ class ActivitySegment(db.Model): def serialize(self): return { - "activity_id": self.activity_uuid.hex, + "activity_id": encode_uuid(self.activity_uuid), "segment_id": self.segment_id, "duration": str(self.duration) if self.duration else None, "pauses": str(self.pauses) if self.pauses else None, @@ -438,7 +443,7 @@ class Record(db.Model): "id": self.id, "user": self.user.username, "sport_id": self.sport_id, - "activity_id": self.activity_uuid.hex, + "activity_id": encode_uuid(self.activity_uuid), "record_type": self.record_type, "activity_date": self.activity_date, "value": value, diff --git a/fittrackee/activities/records.py b/fittrackee/activities/records.py index 40d85d51..48cb585b 100644 --- a/fittrackee/activities/records.py +++ b/fittrackee/activities/records.py @@ -39,7 +39,7 @@ def get_records(auth_user_id): "records": [ { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 9, "record_type": "AS", "sport_id": 1, @@ -48,7 +48,7 @@ def get_records(auth_user_id): }, { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 10, "record_type": "FD", "sport_id": 1, @@ -57,7 +57,7 @@ def get_records(auth_user_id): }, { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 11, "record_type": "LD", "sport_id": 1, @@ -66,7 +66,7 @@ def get_records(auth_user_id): }, { "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT", - "activity_id": "e060bde05e3f4906a32913b102c814cb", + "activity_id": "hvYBqYBRa7wwXpaStWR4V2", "id": 12, "record_type": "MS", "sport_id": 1, diff --git a/fittrackee/activities/utils_id.py b/fittrackee/activities/utils_id.py new file mode 100644 index 00000000..5ea88bc7 --- /dev/null +++ b/fittrackee/activities/utils_id.py @@ -0,0 +1,9 @@ +import shortuuid + + +def encode_uuid(uuid_value): + return shortuuid.encode(uuid_value) + + +def decode_short_id(short_id): + return shortuuid.decode(short_id) diff --git a/fittrackee/tests/activities/test_activities_api_0_get.py b/fittrackee/tests/activities/test_activities_api_0_get.py index 452ac941..50d83f46 100644 --- a/fittrackee/tests/activities/test_activities_api_0_get.py +++ b/fittrackee/tests/activities/test_activities_api_0_get.py @@ -1,6 +1,8 @@ import json from uuid import uuid4 +from .utils import get_random_short_id + class TestGetActivities: def test_it_gets_all_activities_for_authenticated_user( @@ -695,7 +697,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{activity_cycling_user_1.uuid.hex}', + f'/api/activities/{activity_cycling_user_1.short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -727,7 +729,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{activity_cycling_user_2.uuid.hex}', + f'/api/activities/{activity_cycling_user_2.short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -748,7 +750,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{uuid4().hex}', + f'/api/activities/{get_random_short_id()}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -763,7 +765,7 @@ class TestGetActivity: def test_it_returns_404_on_getting_gpx_if_activity_does_not_exist( self, app, user_1 ): - random_uuid = uuid4().hex + random_short_id = get_random_short_id() client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -772,7 +774,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{random_uuid}/gpx', + f'/api/activities/{random_short_id}/gpx', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -782,13 +784,13 @@ class TestGetActivity: data = json.loads(response.data.decode()) assert response.status_code == 404 assert 'not found' in data['status'] - assert f'Activity not found (id: {random_uuid})' in data['message'] + assert f'Activity not found (id: {random_short_id})' in data['message'] assert data['data']['gpx'] == '' def test_it_returns_404_on_getting_chart_data_if_activity_does_not_exist( self, app, user_1 ): - random_uuid = uuid4().hex + random_short_id = get_random_short_id() client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -797,7 +799,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{random_uuid}/chart_data', + f'/api/activities/{random_short_id}/chart_data', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -807,13 +809,13 @@ class TestGetActivity: data = json.loads(response.data.decode()) assert response.status_code == 404 assert 'not found' in data['status'] - assert f'Activity not found (id: {random_uuid})' in data['message'] + assert f'Activity not found (id: {random_short_id})' in data['message'] assert data['data']['chart_data'] == '' def test_it_returns_404_on_getting_gpx_if_activity_have_no_gpx( self, app, user_1, sport_1_cycling, activity_cycling_user_1 ): - activity_uuid = activity_cycling_user_1.uuid.hex + activity_short_id = activity_cycling_user_1.short_id client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -822,7 +824,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{activity_uuid}/gpx', + f'/api/activities/{activity_short_id}/gpx', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -833,14 +835,14 @@ class TestGetActivity: assert response.status_code == 404 assert 'error' in data['status'] assert ( - f'No gpx file for this activity (id: {activity_uuid})' + f'No gpx file for this activity (id: {activity_short_id})' in data['message'] ) def test_it_returns_404_if_activity_have_no_chart_data( self, app, user_1, sport_1_cycling, activity_cycling_user_1 ): - activity_uuid = activity_cycling_user_1.uuid.hex + activity_short_id = activity_cycling_user_1.short_id client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -849,7 +851,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{activity_uuid}/chart_data', + f'/api/activities/{activity_short_id}/chart_data', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -860,7 +862,7 @@ class TestGetActivity: assert response.status_code == 404 assert 'error' in data['status'] assert ( - f'No gpx file for this activity (id: {activity_uuid})' + f'No gpx file for this activity (id: {activity_short_id})' in data['message'] ) @@ -876,7 +878,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{activity_cycling_user_1.uuid.hex}/gpx', + f'/api/activities/{activity_cycling_user_1.short_id}/gpx', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -901,7 +903,7 @@ class TestGetActivity: ) response = client.get( - f'/api/activities/{activity_cycling_user_1.uuid.hex}/chart_data', + f'/api/activities/{activity_cycling_user_1.short_id}/chart_data', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] diff --git a/fittrackee/tests/activities/test_activities_api_1_post.py b/fittrackee/tests/activities/test_activities_api_1_post.py index 0343c03c..97b4bffc 100644 --- a/fittrackee/tests/activities/test_activities_api_1_post.py +++ b/fittrackee/tests/activities/test_activities_api_1_post.py @@ -4,6 +4,7 @@ from datetime import datetime from io import BytesIO from fittrackee.activities.models import Activity +from fittrackee.activities.utils_id import decode_short_id def assert_activity_data_with_gpx(data): @@ -782,10 +783,10 @@ class TestPostAndGetActivityWithGpx: else: assert_activity_data_with_gpx(data) map_id = data['data']['activities'][0]['map'] - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}/gpx', + f'/api/activities/{activity_short_id}/gpx', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -799,7 +800,7 @@ class TestPostAndGetActivityWithGpx: assert len(data['data']['gpx']) != '' response = client.get( - f'/api/activities/{activity_uuid}/gpx/segment/1', + f'/api/activities/{activity_short_id}/gpx/segment/1', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -822,6 +823,7 @@ class TestPostAndGetActivityWithGpx: assert response.status_code == 200 # error case in the same test to avoid generate a new map file + activity_uuid = decode_short_id(activity_short_id) activity = Activity.query.filter_by(uuid=activity_uuid).first() activity.map = 'incorrect path' @@ -876,9 +878,9 @@ class TestPostAndGetActivityWithGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}/chart_data', + f'/api/activities/{activity_short_id}/chart_data', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -914,9 +916,9 @@ class TestPostAndGetActivityWithGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}/chart_data/segment/1', + f'/api/activities/{activity_short_id}/chart_data/segment/1', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -951,7 +953,7 @@ class TestPostAndGetActivityWithGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] resp_login = client.post( '/api/auth/login', @@ -959,7 +961,7 @@ class TestPostAndGetActivityWithGpx: content_type='application/json', ) response = client.get( - f'/api/activities/{activity_uuid}/chart_data', + f'/api/activities/{activity_short_id}/chart_data', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -994,9 +996,9 @@ class TestPostAndGetActivityWithGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}/chart_data/segment/0', + f'/api/activities/{activity_short_id}/chart_data/segment/0', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -1032,9 +1034,9 @@ class TestPostAndGetActivityWithGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}/chart_data/segment/999999', + f'/api/activities/{activity_short_id}/chart_data/segment/999999', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -1076,9 +1078,9 @@ class TestPostAndGetActivityWithoutGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -1119,9 +1121,9 @@ class TestPostAndGetActivityWithoutGpx: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -1164,9 +1166,9 @@ class TestPostAndGetActivityUsingTimezones: ), ) data = json.loads(response.data.decode()) - activity_uuid = data['data']['activities'][0]['id'] + activity_short_id = data['data']['activities'][0]['id'] response = client.get( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] diff --git a/fittrackee/tests/activities/test_activities_api_2_patch.py b/fittrackee/tests/activities/test_activities_api_2_patch.py index f328128f..f1ffb81c 100644 --- a/fittrackee/tests/activities/test_activities_api_2_patch.py +++ b/fittrackee/tests/activities/test_activities_api_2_patch.py @@ -1,9 +1,9 @@ import json -from uuid import uuid4 from fittrackee.activities.models import Activity +from fittrackee.activities.utils_id import decode_short_id -from .utils import post_an_activity +from .utils import get_random_short_id, post_an_activity def assert_activity_data_with_gpx(data, sport_id): @@ -53,11 +53,11 @@ class TestEditActivityWithGpx: def test_it_updates_title_for_an_activity_with_gpx( self, app, user_1, sport_1_cycling, sport_2_running, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(sport_id=2, title="Activity test")), headers=dict(Authorization=f'Bearer {token}'), @@ -74,11 +74,11 @@ class TestEditActivityWithGpx: def test_it_adds_notes_for_an_activity_with_gpx( self, app, user_1, sport_1_cycling, sport_2_running, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(notes="test notes")), headers=dict(Authorization=f'Bearer {token}'), @@ -94,7 +94,7 @@ class TestEditActivityWithGpx: def test_it_raises_403_when_editing_an_activity_from_different_user( self, app, user_1, user_2, sport_1_cycling, sport_2_running, gpx_file ): - _, activity_uuid = post_an_activity(app, gpx_file) + _, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -103,7 +103,7 @@ class TestEditActivityWithGpx: ) response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(sport_id=2, title="Activity test")), headers=dict( @@ -120,11 +120,11 @@ class TestEditActivityWithGpx: def test_it_updates_sport( self, app, user_1, sport_1_cycling, sport_2_running, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(sport_id=2)), headers=dict(Authorization=f'Bearer {token}'), @@ -141,11 +141,11 @@ class TestEditActivityWithGpx: def test_it_returns_400_if_payload_is_empty( self, app, user_1, sport_1_cycling, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict()), headers=dict(Authorization=f'Bearer {token}'), @@ -159,11 +159,11 @@ class TestEditActivityWithGpx: def test_it_raises_500_if_sport_does_not_exists( self, app, user_1, sport_1_cycling, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(sport_id=2)), headers=dict(Authorization=f'Bearer {token}'), @@ -187,7 +187,7 @@ class TestEditActivityWithoutGpx: sport_2_running, activity_cycling_user_1, ): - activity_uuid = activity_cycling_user_1.uuid.hex + activity_short_id = activity_cycling_user_1.short_id client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -196,7 +196,7 @@ class TestEditActivityWithoutGpx: ) response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps( dict( @@ -245,22 +245,22 @@ class TestEditActivityWithoutGpx: records = data['data']['activities'][0]['records'] assert len(records) == 4 assert records[0]['sport_id'] == sport_2_running.id - assert records[0]['activity_id'] == activity_uuid + assert records[0]['activity_id'] == activity_short_id assert records[0]['record_type'] == 'MS' assert records[0]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT' assert records[0]['value'] == 8.0 assert records[1]['sport_id'] == sport_2_running.id - assert records[1]['activity_id'] == activity_uuid + assert records[1]['activity_id'] == activity_short_id assert records[1]['record_type'] == 'LD' assert records[1]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT' assert records[1]['value'] == '1:00:00' assert records[2]['sport_id'] == sport_2_running.id - assert records[2]['activity_id'] == activity_uuid + assert records[2]['activity_id'] == activity_short_id assert records[2]['record_type'] == 'FD' assert records[2]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT' assert records[2]['value'] == 8.0 assert records[3]['sport_id'] == sport_2_running.id - assert records[3]['activity_id'] == activity_uuid + assert records[3]['activity_id'] == activity_short_id assert records[3]['record_type'] == 'AS' assert records[3]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT' assert records[3]['value'] == 8.0 @@ -268,7 +268,7 @@ class TestEditActivityWithoutGpx: def test_it_adds_notes_to_an_activity_wo_gpx( self, app, user_1, sport_1_cycling, activity_cycling_user_1 ): - activity_uuid = activity_cycling_user_1.uuid.hex + activity_short_id = activity_cycling_user_1.short_id client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -277,7 +277,7 @@ class TestEditActivityWithoutGpx: ) response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(notes='test notes')), headers=dict( @@ -317,22 +317,22 @@ class TestEditActivityWithoutGpx: records = data['data']['activities'][0]['records'] assert len(records) == 4 assert records[0]['sport_id'] == sport_1_cycling.id - assert records[0]['activity_id'] == activity_uuid + assert records[0]['activity_id'] == activity_short_id assert records[0]['record_type'] == 'MS' assert records[0]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[0]['value'] == 10.0 assert records[1]['sport_id'] == sport_1_cycling.id - assert records[1]['activity_id'] == activity_uuid + assert records[1]['activity_id'] == activity_short_id assert records[1]['record_type'] == 'LD' assert records[1]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[1]['value'] == '1:00:00' assert records[2]['sport_id'] == sport_1_cycling.id - assert records[2]['activity_id'] == activity_uuid + assert records[2]['activity_id'] == activity_short_id assert records[2]['record_type'] == 'FD' assert records[2]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[2]['value'] == 10.0 assert records[3]['sport_id'] == sport_1_cycling.id - assert records[3]['activity_id'] == activity_uuid + assert records[3]['activity_id'] == activity_short_id assert records[3]['record_type'] == 'AS' assert records[3]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[3]['value'] == 10.0 @@ -348,7 +348,7 @@ class TestEditActivityWithoutGpx: ) response = client.patch( - f'/api/activities/{activity_cycling_user_2.uuid}', + f'/api/activities/{activity_cycling_user_2.short_id}', content_type='application/json', data=json.dumps( dict( @@ -378,7 +378,7 @@ class TestEditActivityWithoutGpx: sport_2_running, activity_cycling_user_1, ): - activity_uuid = activity_cycling_user_1.uuid.hex + activity_short_id = activity_cycling_user_1.short_id client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -387,7 +387,7 @@ class TestEditActivityWithoutGpx: ) response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps( dict( @@ -431,22 +431,22 @@ class TestEditActivityWithoutGpx: records = data['data']['activities'][0]['records'] assert len(records) == 4 assert records[0]['sport_id'] == sport_2_running.id - assert records[0]['activity_id'] == activity_uuid + assert records[0]['activity_id'] == activity_short_id assert records[0]['record_type'] == 'MS' assert records[0]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT' assert records[0]['value'] == 8.0 assert records[1]['sport_id'] == sport_2_running.id - assert records[1]['activity_id'] == activity_uuid + assert records[1]['activity_id'] == activity_short_id assert records[1]['record_type'] == 'LD' assert records[1]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT' assert records[1]['value'] == '1:00:00' assert records[2]['sport_id'] == sport_2_running.id - assert records[2]['activity_id'] == activity_uuid + assert records[2]['activity_id'] == activity_short_id assert records[2]['record_type'] == 'FD' assert records[2]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT' assert records[2]['value'] == 8.0 assert records[3]['sport_id'] == sport_2_running.id - assert records[3]['activity_id'] == activity_uuid + assert records[3]['activity_id'] == activity_short_id assert records[3]['record_type'] == 'AS' assert records[3]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT' assert records[3]['value'] == 8.0 @@ -459,7 +459,7 @@ class TestEditActivityWithoutGpx: sport_2_running, activity_cycling_user_1, ): - activity_uuid = activity_cycling_user_1.uuid.hex + activity_short_id = activity_cycling_user_1.short_id client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -468,7 +468,7 @@ class TestEditActivityWithoutGpx: ) response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(sport_id=2, distance=20)), headers=dict( @@ -504,22 +504,22 @@ class TestEditActivityWithoutGpx: records = data['data']['activities'][0]['records'] assert len(records) == 4 assert records[0]['sport_id'] == sport_2_running.id - assert records[0]['activity_id'] == activity_uuid + assert records[0]['activity_id'] == activity_short_id assert records[0]['record_type'] == 'MS' assert records[0]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[0]['value'] == 20.0 assert records[1]['sport_id'] == sport_2_running.id - assert records[1]['activity_id'] == activity_uuid + assert records[1]['activity_id'] == activity_short_id assert records[1]['record_type'] == 'LD' assert records[1]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[1]['value'] == '1:00:00' assert records[2]['sport_id'] == sport_2_running.id - assert records[2]['activity_id'] == activity_uuid + assert records[2]['activity_id'] == activity_short_id assert records[2]['record_type'] == 'FD' assert records[2]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[2]['value'] == 20.0 assert records[3]['sport_id'] == sport_2_running.id - assert records[3]['activity_id'] == activity_uuid + assert records[3]['activity_id'] == activity_short_id assert records[3]['record_type'] == 'AS' assert records[3]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT' assert records[3]['value'] == 20.0 @@ -535,7 +535,7 @@ class TestEditActivityWithoutGpx: ) response = client.patch( - f'/api/activities/{activity_cycling_user_1.uuid}', + f'/api/activities/{activity_cycling_user_1.short_id}', content_type='application/json', data=json.dumps(dict()), headers=dict( @@ -559,7 +559,7 @@ class TestEditActivityWithoutGpx: content_type='application/json', ) response = client.patch( - f'/api/activities/{activity_cycling_user_1.uuid}', + f'/api/activities/{activity_cycling_user_1.short_id}', content_type='application/json', data=json.dumps( dict( @@ -594,7 +594,7 @@ class TestEditActivityWithoutGpx: content_type='application/json', ) response = client.patch( - f'/api/activities/{uuid4().hex}', + f'/api/activities/{get_random_short_id()}', content_type='application/json', data=json.dumps( dict( @@ -620,7 +620,8 @@ class TestRefreshActivityWithGpx: def test_refresh_an_activity_with_gpx( self, app, user_1, sport_1_cycling, sport_2_running, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) + activity_uuid = decode_short_id(activity_short_id) client = app.test_client() # Edit some activity data @@ -629,7 +630,7 @@ class TestRefreshActivityWithGpx: activity.min_alt = -100 response = client.patch( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', content_type='application/json', data=json.dumps(dict(refresh=True)), headers=dict(Authorization=f'Bearer {token}'), diff --git a/fittrackee/tests/activities/test_activities_api_3_delete.py b/fittrackee/tests/activities/test_activities_api_3_delete.py index fd1a245a..644def9c 100644 --- a/fittrackee/tests/activities/test_activities_api_3_delete.py +++ b/fittrackee/tests/activities/test_activities_api_3_delete.py @@ -1,11 +1,10 @@ import json import os -from uuid import uuid4 from fittrackee.activities.models import Activity from fittrackee.activities.utils import get_absolute_file_path -from .utils import post_an_activity +from .utils import get_random_short_id, post_an_activity def get_gpx_filepath(activity_id): @@ -17,11 +16,11 @@ class TestDeleteActivityWithGpx: def test_it_deletes_an_activity_with_gpx( self, app, user_1, sport_1_cycling, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() response = client.delete( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', headers=dict(Authorization=f'Bearer {token}'), ) @@ -30,7 +29,7 @@ class TestDeleteActivityWithGpx: def test_it_returns_403_when_deleting_an_activity_from_different_user( self, app, user_1, user_2, sport_1_cycling, gpx_file ): - _, activity_uuid = post_an_activity(app, gpx_file) + _, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() resp_login = client.post( '/api/auth/login', @@ -39,7 +38,7 @@ class TestDeleteActivityWithGpx: ) response = client.delete( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -60,7 +59,7 @@ class TestDeleteActivityWithGpx: content_type='application/json', ) response = client.delete( - f'/api/activities/{uuid4().hex}', + f'/api/activities/{get_random_short_id()}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -73,14 +72,14 @@ class TestDeleteActivityWithGpx: def test_it_returns_500_when_deleting_an_activity_with_gpx_invalid_file( self, app, user_1, sport_1_cycling, gpx_file ): - token, activity_uuid = post_an_activity(app, gpx_file) + token, activity_short_id = post_an_activity(app, gpx_file) client = app.test_client() gpx_filepath = get_gpx_filepath(1) gpx_filepath = get_absolute_file_path(gpx_filepath) os.remove(gpx_filepath) response = client.delete( - f'/api/activities/{activity_uuid}', + f'/api/activities/{activity_short_id}', headers=dict(Authorization=f'Bearer {token}'), ) @@ -105,7 +104,7 @@ class TestDeleteActivityWithoutGpx: content_type='application/json', ) response = client.delete( - f'/api/activities/{activity_cycling_user_1.uuid}', + f'/api/activities/{activity_cycling_user_1.short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -123,7 +122,7 @@ class TestDeleteActivityWithoutGpx: content_type='application/json', ) response = client.delete( - f'/api/activities/{activity_cycling_user_1.uuid}', + f'/api/activities/{activity_cycling_user_1.short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] diff --git a/fittrackee/tests/activities/test_activities_model.py b/fittrackee/tests/activities/test_activities_model.py index 2f35c753..8a85429f 100644 --- a/fittrackee/tests/activities/test_activities_model.py +++ b/fittrackee/tests/activities/test_activities_model.py @@ -1,4 +1,6 @@ -from .utils import is_valid_uuid +from uuid import UUID + +from fittrackee.activities.utils_id import decode_short_id class TestActivityModel: @@ -22,7 +24,7 @@ class TestActivityModel: ) serialized_activity = activity_cycling_user_1.serialize() - assert is_valid_uuid(serialized_activity['id']) + assert isinstance(decode_short_id(serialized_activity['id']), UUID) assert 'test' == serialized_activity['user'] assert 1 == serialized_activity['sport_id'] assert serialized_activity['title'] == 'Test' @@ -61,6 +63,6 @@ class TestActivityModel: ): assert ( f'' + f'for activity \'{activity_cycling_user_1.short_id}\'>' == str(activity_cycling_user_1_segment) ) diff --git a/fittrackee/tests/activities/test_records_api.py b/fittrackee/tests/activities/test_records_api.py index dee01469..9b55859d 100644 --- a/fittrackee/tests/activities/test_records_api.py +++ b/fittrackee/tests/activities/test_records_api.py @@ -38,7 +38,7 @@ class TestGetRecords: assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] assert ( - activity_cycling_user_1.uuid.hex + activity_cycling_user_1.short_id == data['data']['records'][0]['activity_id'] ) assert 'AS' == data['data']['records'][0]['record_type'] @@ -51,7 +51,7 @@ class TestGetRecords: assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] assert ( - activity_cycling_user_1.uuid.hex + activity_cycling_user_1.short_id == data['data']['records'][1]['activity_id'] ) assert 'FD' == data['data']['records'][1]['record_type'] @@ -64,7 +64,7 @@ class TestGetRecords: assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] assert ( - activity_cycling_user_1.uuid.hex + activity_cycling_user_1.short_id == data['data']['records'][2]['activity_id'] ) assert 'LD' == data['data']['records'][2]['record_type'] @@ -77,7 +77,7 @@ class TestGetRecords: assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] assert ( - activity_cycling_user_1.uuid.hex + activity_cycling_user_1.short_id == data['data']['records'][3]['activity_id'] ) assert 'MS' == data['data']['records'][3]['record_type'] @@ -177,7 +177,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_1_uuid = data['data']['activities'][0]['id'] + activity_1_short_id = data['data']['activities'][0]['id'] response = client.get( '/api/records', headers=dict( @@ -197,7 +197,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_1_uuid == data['data']['records'][0]['activity_id'] + assert activity_1_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 7.0 == data['data']['records'][0]['value'] @@ -207,7 +207,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -217,7 +217,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_1_uuid == data['data']['records'][2]['activity_id'] + assert activity_1_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:00:00' == data['data']['records'][2]['value'] @@ -227,7 +227,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] - assert activity_1_uuid == data['data']['records'][3]['activity_id'] + assert activity_1_short_id == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 7.0 == data['data']['records'][3]['value'] @@ -251,7 +251,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_2_uuid = data['data']['activities'][0]['id'] + activity_2_short_id = data['data']['activities'][0]['id'] response = client.get( '/api/records', headers=dict( @@ -271,7 +271,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 8.4 == data['data']['records'][0]['value'] @@ -281,7 +281,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -291,7 +291,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_1_uuid == data['data']['records'][2]['activity_id'] + assert activity_1_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:00:00' == data['data']['records'][2]['value'] @@ -301,7 +301,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 8.4 == data['data']['records'][3]['value'] @@ -324,7 +324,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_3_uuid = data['data']['activities'][0]['id'] + activity_3_short_id = data['data']['activities'][0]['id'] response = client.get( '/api/records', headers=dict( @@ -344,7 +344,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 8.4 == data['data']['records'][0]['value'] @@ -354,7 +354,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -364,7 +364,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_1_uuid == data['data']['records'][2]['activity_id'] + assert activity_1_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:00:00' == data['data']['records'][2]['value'] @@ -374,14 +374,14 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 8.4 == data['data']['records'][3]['value'] # Edit last activity # 1 new record: Longest duration client.patch( - f'/api/activities/{activity_3_uuid}', + f'/api/activities/{activity_3_short_id}', content_type='application/json', data=json.dumps(dict(duration=4000)), headers=dict( @@ -408,7 +408,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 8.4 == data['data']['records'][0]['value'] @@ -418,7 +418,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -428,7 +428,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_3_uuid == data['data']['records'][2]['activity_id'] + assert activity_3_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:06:40' == data['data']['records'][2]['value'] @@ -438,13 +438,13 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 8.4 == data['data']['records'][3]['value'] # delete activity 2 => AS and MS record update client.delete( - f'/api/activities/{activity_2_uuid}', + f'/api/activities/{activity_2_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -469,7 +469,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_1_uuid == data['data']['records'][0]['activity_id'] + assert activity_1_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 7.0 == data['data']['records'][0]['value'] @@ -479,7 +479,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -489,7 +489,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_3_uuid == data['data']['records'][2]['activity_id'] + assert activity_3_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:06:40' == data['data']['records'][2]['value'] @@ -499,7 +499,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] - assert activity_1_uuid == data['data']['records'][3]['activity_id'] + assert activity_1_short_id == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 7.0 == data['data']['records'][3]['value'] @@ -523,7 +523,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_4_uuid = data['data']['activities'][0]['id'] + activity_4_short_id = data['data']['activities'][0]['id'] response = client.get( '/api/records', headers=dict( @@ -543,7 +543,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_1_uuid == data['data']['records'][0]['activity_id'] + assert activity_1_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 7.0 == data['data']['records'][0]['value'] @@ -553,7 +553,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -563,7 +563,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_3_uuid == data['data']['records'][2]['activity_id'] + assert activity_3_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:06:40' == data['data']['records'][2]['value'] @@ -573,7 +573,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] - assert activity_1_uuid == data['data']['records'][3]['activity_id'] + assert activity_1_short_id == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 7.0 == data['data']['records'][3]['value'] @@ -599,7 +599,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_5_uuid = data['data']['activities'][0]['id'] + activity_5_short_id = data['data']['activities'][0]['id'] response = client.get( '/api/records', headers=dict( @@ -619,7 +619,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_5_uuid == data['data']['records'][0]['activity_id'] + assert activity_5_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 7.0 == data['data']['records'][0]['value'] @@ -629,7 +629,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_5_uuid == data['data']['records'][1]['activity_id'] + assert activity_5_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -639,7 +639,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_3_uuid == data['data']['records'][2]['activity_id'] + assert activity_3_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:06:40' == data['data']['records'][2]['value'] @@ -649,34 +649,34 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] - assert activity_5_uuid == data['data']['records'][3]['activity_id'] + assert activity_5_short_id == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 7.0 == data['data']['records'][3]['value'] # delete all activities - no more records client.delete( - f'/api/activities/{activity_1_uuid}', + f'/api/activities/{activity_1_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] ), ) client.delete( - f'/api/activities/{activity_3_uuid}', + f'/api/activities/{activity_3_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] ), ) client.delete( - f'/api/activities/{activity_4_uuid}', + f'/api/activities/{activity_4_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] ), ) client.delete( - f'/api/activities/{activity_5_uuid}', + f'/api/activities/{activity_5_short_id}', headers=dict( Authorization='Bearer ' + json.loads(resp_login.data.decode())['auth_token'] @@ -722,7 +722,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_1_uuid = data['data']['activities'][0]['id'] + activity_1_short_id = data['data']['activities'][0]['id'] response = client.post( '/api/activities/no_gpx', content_type='application/json', @@ -741,7 +741,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_2_uuid = data['data']['activities'][0]['id'] + activity_2_short_id = data['data']['activities'][0]['id'] client.post( '/api/activities/no_gpx', content_type='application/json', @@ -777,7 +777,7 @@ class TestGetRecords: ), ) data = json.loads(response.data.decode()) - activity_4_uuid = data['data']['activities'][0]['id'] + activity_4_short_id = data['data']['activities'][0]['id'] response = client.get( '/api/records', headers=dict( @@ -797,7 +797,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_1_uuid == data['data']['records'][0]['activity_id'] + assert activity_1_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 7.0 == data['data']['records'][0]['value'] @@ -807,7 +807,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_1_uuid == data['data']['records'][1]['activity_id'] + assert activity_1_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 7.0 == data['data']['records'][1]['value'] @@ -817,7 +817,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_1_uuid == data['data']['records'][2]['activity_id'] + assert activity_1_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:00:00' == data['data']['records'][2]['value'] @@ -827,7 +827,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] - assert activity_1_uuid == data['data']['records'][3]['activity_id'] + assert activity_1_short_id == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 7.0 == data['data']['records'][3]['value'] @@ -837,7 +837,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][4]['user'] assert sport_2_running.id == data['data']['records'][4]['sport_id'] - assert activity_2_uuid == data['data']['records'][4]['activity_id'] + assert activity_2_short_id == data['data']['records'][4]['activity_id'] assert 'AS' == data['data']['records'][4]['record_type'] assert 20.0 == data['data']['records'][4]['value'] @@ -847,7 +847,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][5]['user'] assert sport_2_running.id == data['data']['records'][5]['sport_id'] - assert activity_2_uuid == data['data']['records'][5]['activity_id'] + assert activity_2_short_id == data['data']['records'][5]['activity_id'] assert 'FD' == data['data']['records'][5]['record_type'] assert 20.0 == data['data']['records'][5]['value'] @@ -857,7 +857,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][6]['user'] assert sport_2_running.id == data['data']['records'][6]['sport_id'] - assert activity_2_uuid == data['data']['records'][6]['activity_id'] + assert activity_2_short_id == data['data']['records'][6]['activity_id'] assert 'LD' == data['data']['records'][6]['record_type'] assert '1:00:00' == data['data']['records'][6]['value'] @@ -867,12 +867,12 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][7]['user'] assert sport_2_running.id == data['data']['records'][7]['sport_id'] - assert activity_2_uuid == data['data']['records'][7]['activity_id'] + assert activity_2_short_id == data['data']['records'][7]['activity_id'] assert 'MS' == data['data']['records'][7]['record_type'] assert 20.0 == data['data']['records'][7]['value'] client.patch( - f'/api/activities/{activity_2_uuid}', + f'/api/activities/{activity_2_short_id}', content_type='application/json', data=json.dumps(dict(sport_id=1)), headers=dict( @@ -899,7 +899,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][0]['user'] assert sport_1_cycling.id == data['data']['records'][0]['sport_id'] - assert activity_2_uuid == data['data']['records'][0]['activity_id'] + assert activity_2_short_id == data['data']['records'][0]['activity_id'] assert 'AS' == data['data']['records'][0]['record_type'] assert 20.0 == data['data']['records'][0]['value'] @@ -909,7 +909,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][1]['user'] assert sport_1_cycling.id == data['data']['records'][1]['sport_id'] - assert activity_2_uuid == data['data']['records'][1]['activity_id'] + assert activity_2_short_id == data['data']['records'][1]['activity_id'] assert 'FD' == data['data']['records'][1]['record_type'] assert 20.0 == data['data']['records'][1]['value'] @@ -919,7 +919,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][2]['user'] assert sport_1_cycling.id == data['data']['records'][2]['sport_id'] - assert activity_1_uuid == data['data']['records'][2]['activity_id'] + assert activity_1_short_id == data['data']['records'][2]['activity_id'] assert 'LD' == data['data']['records'][2]['record_type'] assert '1:00:00' == data['data']['records'][2]['value'] @@ -929,7 +929,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][3]['user'] assert sport_1_cycling.id == data['data']['records'][3]['sport_id'] - assert activity_2_uuid == data['data']['records'][3]['activity_id'] + assert activity_2_short_id == data['data']['records'][3]['activity_id'] assert 'MS' == data['data']['records'][3]['record_type'] assert 20.0 == data['data']['records'][3]['value'] @@ -939,7 +939,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][4]['user'] assert sport_2_running.id == data['data']['records'][4]['sport_id'] - assert activity_4_uuid == data['data']['records'][4]['activity_id'] + assert activity_4_short_id == data['data']['records'][4]['activity_id'] assert 'AS' == data['data']['records'][4]['record_type'] assert 12.0 == data['data']['records'][4]['value'] @@ -949,7 +949,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][5]['user'] assert sport_2_running.id == data['data']['records'][5]['sport_id'] - assert activity_4_uuid == data['data']['records'][5]['activity_id'] + assert activity_4_short_id == data['data']['records'][5]['activity_id'] assert 'FD' == data['data']['records'][5]['record_type'] assert 10.0 == data['data']['records'][5]['value'] @@ -959,7 +959,7 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][6]['user'] assert sport_2_running.id == data['data']['records'][6]['sport_id'] - assert activity_4_uuid == data['data']['records'][6]['activity_id'] + assert activity_4_short_id == data['data']['records'][6]['activity_id'] assert 'LD' == data['data']['records'][6]['record_type'] assert '0:50:00' == data['data']['records'][6]['value'] @@ -969,6 +969,6 @@ class TestGetRecords: ) # noqa assert 'test' == data['data']['records'][7]['user'] assert sport_2_running.id == data['data']['records'][7]['sport_id'] - assert activity_4_uuid == data['data']['records'][7]['activity_id'] + assert activity_4_short_id == data['data']['records'][7]['activity_id'] assert 'MS' == data['data']['records'][7]['record_type'] assert 12.0 == data['data']['records'][7]['value'] diff --git a/fittrackee/tests/activities/utils.py b/fittrackee/tests/activities/utils.py index d4b262df..906d2b46 100644 --- a/fittrackee/tests/activities/utils.py +++ b/fittrackee/tests/activities/utils.py @@ -1,14 +1,12 @@ import json from io import BytesIO -from uuid import UUID +from uuid import uuid4 + +from fittrackee.activities.utils_id import encode_uuid -def is_valid_uuid(string): - try: - UUID(string, version=4) - except ValueError: - return False - return True +def get_random_short_id(): + return encode_uuid(uuid4()) def post_an_activity(app, gpx_file): diff --git a/poetry.lock b/poetry.lock index a9e956f5..6d839168 100644 --- a/poetry.lock +++ b/poetry.lock @@ -889,6 +889,14 @@ python-versions = "*" [package.dependencies] urllib3 = "*" +[[package]] +name = "shortuuid" +version = "1.0.1" +description = "A generator library for concise, unambiguous and URL-safe UUIDs." +category = "main" +optional = false +python-versions = ">=3.5" + [[package]] name = "six" version = "1.15.0" @@ -1154,7 +1162,7 @@ testing = ["pytest (>=3.5,<3.7.3 || >3.7.3)", "pytest-checkdocs (>=1.2.3)", "pyt [metadata] lock-version = "1.0" python-versions = "^3.7" -content-hash = "94d589f7d4810e10acf98513037953027e13374bf13a62207570d9caca3f9ab0" +content-hash = "b5c7cbb6e449c8c6cc94a7413ae2fc0b8889d738e3fc802566efc45cc5096287" [metadata.files] alabaster = [ @@ -1674,6 +1682,10 @@ selenium = [ {file = "selenium-3.141.0-py2.py3-none-any.whl", hash = "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c"}, {file = "selenium-3.141.0.tar.gz", hash = "sha256:deaf32b60ad91a4611b98d8002757f29e6f2c2d5fcaf202e1c9ad06d6772300d"}, ] +shortuuid = [ + {file = "shortuuid-1.0.1-py3-none-any.whl", hash = "sha256:492c7402ff91beb1342a5898bd61ea953985bf24a41cd9f247409aa2e03c8f77"}, + {file = "shortuuid-1.0.1.tar.gz", hash = "sha256:3c11d2007b915c43bee3e10625f068d8a349e04f0d81f08f5fa08507427ebf1f"}, +] six = [ {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"}, {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"}, diff --git a/pyproject.toml b/pyproject.toml index d0340d52..ca2f143b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ psycopg2-binary = "^2.8" pyjwt = "^2.0" python-forecastio = "^1.4" pytz = "^2020.5" +shortuuid = "^1.0.1" staticmap = "^0.5.4" tqdm = "^4.55"