API - return activity shorter id - #57

This commit is contained in:
Sam 2020-12-30 22:07:43 +01:00
parent 3c6bc54c79
commit 480bdd330e
18 changed files with 336 additions and 295 deletions

View File

@ -162,7 +162,7 @@
<span class="nt">&quot;descent&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;distance&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
<span class="nt">&quot;duration&quot;</span><span class="p">:</span> <span class="s2">&quot;0:17:04&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;map&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_alt&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_speed&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
@ -176,7 +176,7 @@
<span class="nt">&quot;records&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;MS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -185,7 +185,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;LD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -194,7 +194,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;FD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -203,7 +203,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;AS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -285,11 +285,11 @@
</dd></dl>
<dl class="http get">
<dt id="get--api-activities-(string-activity_uuid)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_uuid)" title="Permalink to this definition"></a></dt>
<dt id="get--api-activities-(string-activity_short_id)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_short_id)" title="Permalink to this definition"></a></dt>
<dd><p>Get an activity</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/f03265f69fe0489b812fc7dc4deff55e</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/kjxavSTUrJvoAh2wvCeGEF</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
</pre></div>
</div>
<p><strong>Example responses</strong>:</p>
@ -311,7 +311,7 @@
<span class="nt">&quot;descent&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;distance&quot;</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
<span class="nt">&quot;duration&quot;</span><span class="p">:</span> <span class="s2">&quot;0:45:00&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;map&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_alt&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_speed&quot;</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
@ -355,7 +355,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
@ -380,11 +380,11 @@
</dd></dl>
<dl class="http get">
<dt id="get--api-activities-(string-activity_uuid)-gpx">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><code class="sig-name descname">/gpx</code><a class="headerlink" href="#get--api-activities-(string-activity_uuid)-gpx" title="Permalink to this definition"></a></dt>
<dt id="get--api-activities-(string-activity_short_id)-gpx">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><code class="sig-name descname">/gpx</code><a class="headerlink" href="#get--api-activities-(string-activity_short_id)-gpx" title="Permalink to this definition"></a></dt>
<dd><p>Get gpx file for an activity displayed on map with Leaflet</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
@ -405,7 +405,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
@ -434,11 +434,11 @@
</dd></dl>
<dl class="http get">
<dt id="get--api-activities-(string-activity_uuid)-chart_data">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><code class="sig-name descname">/chart_data</code><a class="headerlink" href="#get--api-activities-(string-activity_uuid)-chart_data" title="Permalink to this definition"></a></dt>
<dt id="get--api-activities-(string-activity_short_id)-chart_data">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><code class="sig-name descname">/chart_data</code><a class="headerlink" href="#get--api-activities-(string-activity_short_id)-chart_data" title="Permalink to this definition"></a></dt>
<dd><p>Get chart data from an activity gpx file, to display it with Recharts</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/f03265f69fe0489b812fc7dc4deff55e/chart</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/kjxavSTUrJvoAh2wvCeGEF/chart</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
@ -478,7 +478,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>
@ -507,12 +507,11 @@
</dd></dl>
<dl class="http get">
<dt id="get--api-activities-(string-activity_uuid)-chart_data-segment-(int-segment_id)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><code class="sig-name descname">/chart_data/segment/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">segment_id</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_uuid)-chart_data-segment-(int-segment_id)" title="Permalink to this definition"></a></dt>
<dt id="get--api-activities-(string-activity_short_id)-chart_data-segment-(int-segment_id)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><code class="sig-name descname">/chart_data/segment/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">segment_id</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_short_id)-chart_data-segment-(int-segment_id)" title="Permalink to this definition"></a></dt>
<dd><p>Get chart data from an activity gpx file, to display it with Recharts</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/f03265f69fe0489b812fc7dc4deff55e/chart/segment/0</span>
<span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/kjxavSTUrJvoAh2wvCeGEF/chart/segment/0</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
@ -552,7 +551,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
<li><p><strong>segment_id</strong> (<em>integer</em>) segment id</p></li>
</ul>
</dd>
@ -579,12 +578,11 @@
</dd></dl>
<dl class="http get">
<dt id="get--api-activities-(string-activity_uuid)-gpx-segment-(int-segment_id)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><code class="sig-name descname">/gpx/segment/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">segment_id</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_uuid)-gpx-segment-(int-segment_id)" title="Permalink to this definition"></a></dt>
<dt id="get--api-activities-(string-activity_short_id)-gpx-segment-(int-segment_id)">
<code class="sig-name descname">GET </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><code class="sig-name descname">/gpx/segment/</code><span class="sig-paren">(</span><em class="property">int: </em><em class="sig-param">segment_id</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_short_id)-gpx-segment-(int-segment_id)" title="Permalink to this definition"></a></dt>
<dd><p>Get gpx file for an activity segment displayed on map with Leaflet</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx/segment/0</span>
<span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">GET</span> <span class="nn">/api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx/segment/0</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
@ -605,7 +603,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
<li><p><strong>segment_id</strong> (<em>integer</em>) segment id</p></li>
</ul>
</dd>
@ -718,7 +716,7 @@
<span class="nt">&quot;descent&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;distance&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
<span class="nt">&quot;duration&quot;</span><span class="p">:</span> <span class="s2">&quot;0:17:04&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;map&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_alt&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;max_speed&quot;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
@ -732,7 +730,7 @@
<span class="nt">&quot;records&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;MS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -741,7 +739,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;LD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -750,7 +748,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;FD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -759,7 +757,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;AS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -859,7 +857,7 @@
<span class="nt">&quot;records&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;MS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -868,7 +866,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;LD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -877,7 +875,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;FD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -886,7 +884,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;AS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -898,7 +896,7 @@
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;title&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;admin&quot;</span><span class="p">,</span>
<span class="nt">&quot;uuid&quot;</span><span class="p">:</span> <span class="nt">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span>
<span class="nt">&quot;uuid&quot;</span><span class="p">:</span> <span class="nt">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span>
<span class="nt">&quot;weather_end&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;weather_start&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;with_gpx&quot;</span><span class="p">:</span> <span class="kc">false</span>
@ -947,8 +945,8 @@
</dd></dl>
<dl class="http patch">
<dt id="patch--api-activities-(string-activity_uuid)">
<code class="sig-name descname">PATCH </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><a class="headerlink" href="#patch--api-activities-(string-activity_uuid)" title="Permalink to this definition"></a></dt>
<dt id="patch--api-activities-(string-activity_short_id)">
<code class="sig-name descname">PATCH </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><a class="headerlink" href="#patch--api-activities-(string-activity_short_id)" title="Permalink to this definition"></a></dt>
<dd><p>Update an activity</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">PATCH</span> <span class="nn">/api/activities/1</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
@ -984,7 +982,7 @@
<span class="nt">&quot;records&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;MS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -993,7 +991,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;LD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -1002,7 +1000,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;FD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -1011,7 +1009,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Mon, 01 Jan 2018 00:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;AS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -1023,7 +1021,7 @@
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;title&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;user&quot;</span><span class="p">:</span> <span class="s2">&quot;admin&quot;</span><span class="p">,</span>
<span class="nt">&quot;uuid&quot;</span><span class="p">:</span> <span class="nt">&quot;f03265f69fe0489b812fc7dc4deff55e&quot;</span>
<span class="nt">&quot;uuid&quot;</span><span class="p">:</span> <span class="nt">&quot;kjxavSTUrJvoAh2wvCeGEF&quot;</span>
<span class="nt">&quot;weather_end&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;weather_start&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;with_gpx&quot;</span><span class="p">:</span> <span class="kc">false</span>
@ -1038,7 +1036,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
</ul>
</dd>
<dt class="field-even">Request JSON Object</dt>
@ -1077,11 +1075,11 @@
</dd></dl>
<dl class="http delete">
<dt id="delete--api-activities-(string-activity_uuid)">
<code class="sig-name descname">DELETE </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_uuid</em><span class="sig-paren">)</span><a class="headerlink" href="#delete--api-activities-(string-activity_uuid)" title="Permalink to this definition"></a></dt>
<dt id="delete--api-activities-(string-activity_short_id)">
<code class="sig-name descname">DELETE </code><code class="sig-name descname">/api/activities/</code><span class="sig-paren">(</span><em class="property">string: </em><em class="sig-param">activity_short_id</em><span class="sig-paren">)</span><a class="headerlink" href="#delete--api-activities-(string-activity_short_id)" title="Permalink to this definition"></a></dt>
<dd><p>Delete an activity</p>
<p><strong>Example request</strong>:</p>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">DELETE</span> <span class="nn">/api/activities/f03265f69fe0489b812fc7dc4deff55e</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<div class="highlight-http notranslate"><div class="highlight"><pre><span></span><span class="nf">DELETE</span> <span class="nn">/api/activities/kjxavSTUrJvoAh2wvCeGEF</span> <span class="kr">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
</pre></div>
</div>
@ -1094,7 +1092,7 @@
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>auth_user_id</strong> (<em>integer</em>) authenticate user id (from JSON Web Token)</p></li>
<li><p><strong>activity_uuid</strong> (<em>integer</em>) activity uuid</p></li>
<li><p><strong>activity_short_id</strong> (<em>string</em>) activity short id</p></li>
</ul>
</dd>
<dt class="field-even">Request Headers</dt>

View File

@ -156,7 +156,7 @@
<span class="nt">&quot;records&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Sun, 07 Jul 2019 08:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;e060bde05e3f4906a32913b102c814cb&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;hvYBqYBRa7wwXpaStWR4V2&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">9</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;AS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -165,7 +165,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Sun, 07 Jul 2019 08:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;e060bde05e3f4906a32913b102c814cb&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;hvYBqYBRa7wwXpaStWR4V2&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;FD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -174,7 +174,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Sun, 07 Jul 2019 08:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;e060bde05e3f4906a32913b102c814cb&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;hvYBqYBRa7wwXpaStWR4V2&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;LD&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
@ -183,7 +183,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;activity_date&quot;</span><span class="p">:</span> <span class="s2">&quot;Sun, 07 Jul 2019 08:00:00 GMT&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;e060bde05e3f4906a32913b102c814cb&quot;</span><span class="p">,</span>
<span class="nt">&quot;activity_id&quot;</span><span class="p">:</span> <span class="s2">&quot;hvYBqYBRa7wwXpaStWR4V2&quot;</span><span class="p">,</span>
<span class="nt">&quot;id&quot;</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
<span class="nt">&quot;record_type&quot;</span><span class="p">:</span> <span class="s2">&quot;MS&quot;</span><span class="p">,</span>
<span class="nt">&quot;sport_id&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>

View File

@ -133,27 +133,27 @@
<tr>
<td></td>
<td>
<a href="api/activities.html#get--api-activities-(string-activity_uuid)"><code class="xref">GET /api/activities/(string:activity_uuid)</code></a></td><td>
<a href="api/activities.html#get--api-activities-(string-activity_short_id)"><code class="xref">GET /api/activities/(string:activity_short_id)</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="api/activities.html#get--api-activities-(string-activity_uuid)-chart_data"><code class="xref">GET /api/activities/(string:activity_uuid)/chart_data</code></a></td><td>
<a href="api/activities.html#get--api-activities-(string-activity_short_id)-chart_data"><code class="xref">GET /api/activities/(string:activity_short_id)/chart_data</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="api/activities.html#get--api-activities-(string-activity_uuid)-chart_data-segment-(int-segment_id)"><code class="xref">GET /api/activities/(string:activity_uuid)/chart_data/segment/(int:segment_id)</code></a></td><td>
<a href="api/activities.html#get--api-activities-(string-activity_short_id)-chart_data-segment-(int-segment_id)"><code class="xref">GET /api/activities/(string:activity_short_id)/chart_data/segment/(int:segment_id)</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="api/activities.html#get--api-activities-(string-activity_uuid)-gpx"><code class="xref">GET /api/activities/(string:activity_uuid)/gpx</code></a></td><td>
<a href="api/activities.html#get--api-activities-(string-activity_short_id)-gpx"><code class="xref">GET /api/activities/(string:activity_short_id)/gpx</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
<td>
<a href="api/activities.html#get--api-activities-(string-activity_uuid)-gpx-segment-(int-segment_id)"><code class="xref">GET /api/activities/(string:activity_uuid)/gpx/segment/(int:segment_id)</code></a></td><td>
<a href="api/activities.html#get--api-activities-(string-activity_short_id)-gpx-segment-(int-segment_id)"><code class="xref">GET /api/activities/(string:activity_short_id)/gpx/segment/(int:segment_id)</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
@ -273,7 +273,7 @@
<tr>
<td></td>
<td>
<a href="api/activities.html#delete--api-activities-(string-activity_uuid)"><code class="xref">DELETE /api/activities/(string:activity_uuid)</code></a></td><td>
<a href="api/activities.html#delete--api-activities-(string-activity_short_id)"><code class="xref">DELETE /api/activities/(string:activity_short_id)</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>
@ -288,7 +288,7 @@
<tr>
<td></td>
<td>
<a href="api/activities.html#patch--api-activities-(string-activity_uuid)"><code class="xref">PATCH /api/activities/(string:activity_uuid)</code></a></td><td>
<a href="api/activities.html#patch--api-activities-(string-activity_short_id)"><code class="xref">PATCH /api/activities/(string:activity_short_id)</code></a></td><td>
<em></em></td></tr>
<tr>
<td></td>

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -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/<string:activity_uuid>', methods=['GET']
'/activities/<string:activity_short_id>', 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/<string:activity_uuid>/gpx', methods=['GET']
'/activities/<string:activity_short_id>/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/<string:activity_uuid>/chart_data', methods=['GET']
'/activities/<string:activity_short_id>/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/<string:activity_uuid>/gpx/segment/<int:segment_id>',
'/activities/<string:activity_short_id>/gpx/segment/<int:segment_id>',
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/<string:activity_uuid>/chart_data/segment/<int:segment_id>',
'/activities/<string:activity_short_id>/chart_data/segment/'
'<int:segment_id>',
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/<map_id>', 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/<string:activity_uuid>', methods=['PATCH']
'/activities/<string:activity_short_id>', 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
:<json string activity_date: activity date (format: ``%Y-%m-%d %H:%M``)
(only for activity without gpx)
@ -1201,6 +1211,7 @@ def update_activity(auth_user_id, activity_uuid):
return jsonify(response_object), 400
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(
@ -1234,10 +1245,10 @@ def update_activity(auth_user_id, activity_uuid):
@activities_blueprint.route(
'/activities/<string:activity_uuid>', methods=['DELETE']
'/activities/<string:activity_short_id>', 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(

View File

@ -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'<Segment \'{self.segment_id}\' '
f'for activity \'{self.activity_uuid.hex}\'>'
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,

View File

@ -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,

View File

@ -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)

View File

@ -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']

View File

@ -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']

View File

@ -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}'),

View File

@ -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']

View File

@ -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'<Segment \'{activity_cycling_user_1_segment.segment_id}\' '
f'for activity \'{activity_cycling_user_1.uuid.hex}\'>'
f'for activity \'{activity_cycling_user_1.short_id}\'>'
== str(activity_cycling_user_1_segment)
)

View File

@ -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']

View File

@ -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):

14
poetry.lock generated
View File

@ -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"},

View File

@ -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"