API - return activity shorter id - #57
This commit is contained in:
		@@ -162,7 +162,7 @@
 | 
				
			|||||||
          <span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"distance"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
					          <span class="nt">"distance"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
 | 
					          <span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					          <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"max_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
					          <span class="nt">"max_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
				
			||||||
@@ -176,7 +176,7 @@
 | 
				
			|||||||
          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
					          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
				
			||||||
            <span class="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
@@ -285,11 +285,11 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http get">
 | 
					<dl class="http get">
 | 
				
			||||||
<dt id="get--api-activities-(string-activity_uuid)">
 | 
					<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_uuid</em><span class="sig-paren">)</span><a class="headerlink" href="#get--api-activities-(string-activity_uuid)" title="Permalink to this definition">¶</a></dt>
 | 
					<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>
 | 
					<dd><p>Get an activity</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					</pre></div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
<p><strong>Example responses</strong>:</p>
 | 
					<p><strong>Example responses</strong>:</p>
 | 
				
			||||||
@@ -311,7 +311,7 @@
 | 
				
			|||||||
          <span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"distance"</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
 | 
					          <span class="nt">"distance"</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:45:00"</span><span class="p">,</span>
 | 
					          <span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:45:00"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					          <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"max_speed"</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
 | 
					          <span class="nt">"max_speed"</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span>
 | 
				
			||||||
@@ -355,7 +355,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
<dt class="field-even">Request Headers</dt>
 | 
					<dt class="field-even">Request Headers</dt>
 | 
				
			||||||
@@ -380,11 +380,11 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http get">
 | 
					<dl class="http get">
 | 
				
			||||||
<dt id="get--api-activities-(string-activity_uuid)-gpx">
 | 
					<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_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>
 | 
					<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>
 | 
					<dd><p>Get gpx file for an activity displayed on map with Leaflet</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
 | 
				
			||||||
</pre></div>
 | 
					</pre></div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -405,7 +405,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
<dt class="field-even">Request Headers</dt>
 | 
					<dt class="field-even">Request Headers</dt>
 | 
				
			||||||
@@ -434,11 +434,11 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http get">
 | 
					<dl class="http get">
 | 
				
			||||||
<dt id="get--api-activities-(string-activity_uuid)-chart_data">
 | 
					<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_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>
 | 
					<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>
 | 
					<dd><p>Get chart data from an activity gpx file, to display it with Recharts</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
 | 
				
			||||||
</pre></div>
 | 
					</pre></div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -478,7 +478,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
<dt class="field-even">Request Headers</dt>
 | 
					<dt class="field-even">Request Headers</dt>
 | 
				
			||||||
@@ -507,12 +507,11 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http get">
 | 
					<dl class="http get">
 | 
				
			||||||
<dt id="get--api-activities-(string-activity_uuid)-chart_data-segment-(int-segment_id)">
 | 
					<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_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>
 | 
					<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>
 | 
					<dd><p>Get chart data from an activity gpx file, to display it with Recharts</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					<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="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>
 | 
					<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
 | 
				
			||||||
</pre></div>
 | 
					</pre></div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -552,7 +551,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					<li><p><strong>segment_id</strong> (<em>integer</em>) – segment id</p></li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
@@ -579,12 +578,11 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http get">
 | 
					<dl class="http get">
 | 
				
			||||||
<dt id="get--api-activities-(string-activity_uuid)-gpx-segment-(int-segment_id)">
 | 
					<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_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>
 | 
					<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>
 | 
					<dd><p>Get gpx file for an activity segment displayed on map with Leaflet</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					<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="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>
 | 
					<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
 | 
				
			||||||
</pre></div>
 | 
					</pre></div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -605,7 +603,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					<li><p><strong>segment_id</strong> (<em>integer</em>) – segment id</p></li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
@@ -718,7 +716,7 @@
 | 
				
			|||||||
          <span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"descent"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"distance"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
					          <span class="nt">"distance"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
 | 
					          <span class="nt">"duration"</span><span class="p">:</span> <span class="s2">"0:17:04"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					          <span class="nt">"id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"map"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"max_alt"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"max_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
					          <span class="nt">"max_speed"</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">,</span>
 | 
				
			||||||
@@ -732,7 +730,7 @@
 | 
				
			|||||||
          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
					          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
				
			||||||
            <span class="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
@@ -859,7 +857,7 @@
 | 
				
			|||||||
          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
					          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
				
			||||||
            <span class="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
@@ -898,7 +896,7 @@
 | 
				
			|||||||
          <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					          <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"title"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"title"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"user"</span><span class="p">:</span> <span class="s2">"admin"</span><span class="p">,</span>
 | 
					          <span class="nt">"user"</span><span class="p">:</span> <span class="s2">"admin"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"uuid"</span><span class="p">:</span> <span class="nt">"f03265f69fe0489b812fc7dc4deff55e"</span>
 | 
					          <span class="nt">"uuid"</span><span class="p">:</span> <span class="nt">"kjxavSTUrJvoAh2wvCeGEF"</span>
 | 
				
			||||||
          <span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"with_gpx"</span><span class="p">:</span> <span class="kc">false</span>
 | 
					          <span class="nt">"with_gpx"</span><span class="p">:</span> <span class="kc">false</span>
 | 
				
			||||||
@@ -947,8 +945,8 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http patch">
 | 
					<dl class="http patch">
 | 
				
			||||||
<dt id="patch--api-activities-(string-activity_uuid)">
 | 
					<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_uuid</em><span class="sig-paren">)</span><a class="headerlink" href="#patch--api-activities-(string-activity_uuid)" title="Permalink to this definition">¶</a></dt>
 | 
					<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>
 | 
					<dd><p>Update an activity</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					<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">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
					          <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
				
			||||||
            <span class="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">3</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</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="p">{</span>
 | 
					            <span class="p">{</span>
 | 
				
			||||||
              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Mon, 01 Jan 2018 00:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"f03265f69fe0489b812fc7dc4deff55e"</span><span class="p">,</span>
 | 
					              <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"kjxavSTUrJvoAh2wvCeGEF"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
					              <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
				
			||||||
              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					              <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
@@ -1023,7 +1021,7 @@
 | 
				
			|||||||
          <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					          <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"title"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"title"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"user"</span><span class="p">:</span> <span class="s2">"admin"</span><span class="p">,</span>
 | 
					          <span class="nt">"user"</span><span class="p">:</span> <span class="s2">"admin"</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"uuid"</span><span class="p">:</span> <span class="nt">"f03265f69fe0489b812fc7dc4deff55e"</span>
 | 
					          <span class="nt">"uuid"</span><span class="p">:</span> <span class="nt">"kjxavSTUrJvoAh2wvCeGEF"</span>
 | 
				
			||||||
          <span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"weather_end"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
					          <span class="nt">"weather_start"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
 | 
				
			||||||
          <span class="nt">"with_gpx"</span><span class="p">:</span> <span class="kc">false</span>
 | 
					          <span class="nt">"with_gpx"</span><span class="p">:</span> <span class="kc">false</span>
 | 
				
			||||||
@@ -1038,7 +1036,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
<dt class="field-even">Request JSON Object</dt>
 | 
					<dt class="field-even">Request JSON Object</dt>
 | 
				
			||||||
@@ -1077,11 +1075,11 @@
 | 
				
			|||||||
</dd></dl>
 | 
					</dd></dl>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<dl class="http delete">
 | 
					<dl class="http delete">
 | 
				
			||||||
<dt id="delete--api-activities-(string-activity_uuid)">
 | 
					<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_uuid</em><span class="sig-paren">)</span><a class="headerlink" href="#delete--api-activities-(string-activity_uuid)" title="Permalink to this definition">¶</a></dt>
 | 
					<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>
 | 
					<dd><p>Delete an activity</p>
 | 
				
			||||||
<p><strong>Example request</strong>:</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>
 | 
					<span class="na">Content-Type</span><span class="o">:</span> <span class="l">application/json</span>
 | 
				
			||||||
</pre></div>
 | 
					</pre></div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -1094,7 +1092,7 @@
 | 
				
			|||||||
<dt class="field-odd">Parameters</dt>
 | 
					<dt class="field-odd">Parameters</dt>
 | 
				
			||||||
<dd class="field-odd"><ul class="simple">
 | 
					<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>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>
 | 
					</ul>
 | 
				
			||||||
</dd>
 | 
					</dd>
 | 
				
			||||||
<dt class="field-even">Request Headers</dt>
 | 
					<dt class="field-even">Request Headers</dt>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,7 +156,7 @@
 | 
				
			|||||||
    <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
					    <span class="nt">"records"</span><span class="p">:</span> <span class="p">[</span>
 | 
				
			||||||
      <span class="p">{</span>
 | 
					      <span class="p">{</span>
 | 
				
			||||||
        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"e060bde05e3f4906a32913b102c814cb"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"hvYBqYBRa7wwXpaStWR4V2"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">9</span><span class="p">,</span>
 | 
					        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">9</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
					        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"AS"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					        <span class="nt">"sport_id"</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="p">{</span>
 | 
					      <span class="p">{</span>
 | 
				
			||||||
        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"e060bde05e3f4906a32913b102c814cb"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"hvYBqYBRa7wwXpaStWR4V2"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
 | 
					        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
					        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"FD"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					        <span class="nt">"sport_id"</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="p">{</span>
 | 
					      <span class="p">{</span>
 | 
				
			||||||
        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"e060bde05e3f4906a32913b102c814cb"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"hvYBqYBRa7wwXpaStWR4V2"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
 | 
					        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">11</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
					        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"LD"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					        <span class="nt">"sport_id"</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="p">{</span>
 | 
					      <span class="p">{</span>
 | 
				
			||||||
        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_date"</span><span class="p">:</span> <span class="s2">"Sun, 07 Jul 2019 08:00:00 GMT"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"e060bde05e3f4906a32913b102c814cb"</span><span class="p">,</span>
 | 
					        <span class="nt">"activity_id"</span><span class="p">:</span> <span class="s2">"hvYBqYBRa7wwXpaStWR4V2"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
 | 
					        <span class="nt">"id"</span><span class="p">:</span> <span class="mi">12</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
					        <span class="nt">"record_type"</span><span class="p">:</span> <span class="s2">"MS"</span><span class="p">,</span>
 | 
				
			||||||
        <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
					        <span class="nt">"sport_id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,27 +133,27 @@
 | 
				
			|||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></td>
 | 
				
			||||||
@@ -273,7 +273,7 @@
 | 
				
			|||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></td>
 | 
				
			||||||
@@ -288,7 +288,7 @@
 | 
				
			|||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></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>
 | 
					       <em></em></td></tr>
 | 
				
			||||||
     <tr>
 | 
					     <tr>
 | 
				
			||||||
       <td></td>
 | 
					       <td></td>
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										
											BIN
										
									
								
								docs/objects.inv
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/objects.inv
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -29,6 +29,7 @@ from .utils_gpx import (
 | 
				
			|||||||
    extract_segment_from_gpx_file,
 | 
					    extract_segment_from_gpx_file,
 | 
				
			||||||
    get_chart_data,
 | 
					    get_chart_data,
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					from .utils_id import decode_short_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
activities_blueprint = Blueprint('activities', __name__)
 | 
					activities_blueprint = Blueprint('activities', __name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -76,7 +77,7 @@ def get_activities(auth_user_id):
 | 
				
			|||||||
                "descent": null,
 | 
					                "descent": null,
 | 
				
			||||||
                "distance": 10.0,
 | 
					                "distance": 10.0,
 | 
				
			||||||
                "duration": "0:17:04",
 | 
					                "duration": "0:17:04",
 | 
				
			||||||
                "id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                "id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                "map": null,
 | 
					                "map": null,
 | 
				
			||||||
                "max_alt": null,
 | 
					                "max_alt": null,
 | 
				
			||||||
                "max_speed": 10.0,
 | 
					                "max_speed": 10.0,
 | 
				
			||||||
@@ -90,7 +91,7 @@ def get_activities(auth_user_id):
 | 
				
			|||||||
                "records": [
 | 
					                "records": [
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 4,
 | 
					                    "id": 4,
 | 
				
			||||||
                    "record_type": "MS",
 | 
					                    "record_type": "MS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -99,7 +100,7 @@ def get_activities(auth_user_id):
 | 
				
			|||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 3,
 | 
					                    "id": 3,
 | 
				
			||||||
                    "record_type": "LD",
 | 
					                    "record_type": "LD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -108,7 +109,7 @@ def get_activities(auth_user_id):
 | 
				
			|||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 2,
 | 
					                    "id": 2,
 | 
				
			||||||
                    "record_type": "FD",
 | 
					                    "record_type": "FD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -117,7 +118,7 @@ def get_activities(auth_user_id):
 | 
				
			|||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 1,
 | 
					                    "id": 1,
 | 
				
			||||||
                    "record_type": "AS",
 | 
					                    "record_type": "AS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -270,10 +271,10 @@ def get_activities(auth_user_id):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@activities_blueprint.route(
 | 
					@activities_blueprint.route(
 | 
				
			||||||
    '/activities/<string:activity_uuid>', methods=['GET']
 | 
					    '/activities/<string:activity_short_id>', methods=['GET']
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@authenticate
 | 
				
			||||||
def get_activity(auth_user_id, activity_uuid):
 | 
					def get_activity(auth_user_id, activity_short_id):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Get an activity
 | 
					    Get an activity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -281,7 +282,7 @@ def get_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    .. sourcecode:: http
 | 
					    .. sourcecode:: http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      GET /api/activities/f03265f69fe0489b812fc7dc4deff55e HTTP/1.1
 | 
					      GET /api/activities/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    **Example responses**:
 | 
					    **Example responses**:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -304,7 +305,7 @@ def get_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
                "descent": null,
 | 
					                "descent": null,
 | 
				
			||||||
                "distance": 12,
 | 
					                "distance": 12,
 | 
				
			||||||
                "duration": "0:45:00",
 | 
					                "duration": "0:45:00",
 | 
				
			||||||
                "id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                "id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                "map": null,
 | 
					                "map": null,
 | 
				
			||||||
                "max_alt": null,
 | 
					                "max_alt": null,
 | 
				
			||||||
                "max_speed": 16,
 | 
					                "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 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
 | 
					    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -357,6 +358,7 @@ def get_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
    :statuscode 404: activity not found
 | 
					    :statuscode 404: activity not found
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					    activity_uuid = decode_short_id(activity_short_id)
 | 
				
			||||||
    activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
					    activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
				
			||||||
    activities_list = []
 | 
					    activities_list = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -381,8 +383,11 @@ def get_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
    return jsonify(response_object), code
 | 
					    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"""
 | 
					    """Get data from an activity gpx file"""
 | 
				
			||||||
 | 
					    activity_uuid = decode_short_id(activity_short_id)
 | 
				
			||||||
    activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
					    activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
				
			||||||
    content = ''
 | 
					    content = ''
 | 
				
			||||||
    if activity:
 | 
					    if activity:
 | 
				
			||||||
@@ -392,7 +397,9 @@ def get_activity_data(auth_user_id, activity_uuid, data_type, segment_id=None):
 | 
				
			|||||||
        if response_object:
 | 
					        if response_object:
 | 
				
			||||||
            return jsonify(response_object), code
 | 
					            return jsonify(response_object), code
 | 
				
			||||||
        if not activity.gpx or activity.gpx == '':
 | 
					        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}
 | 
					            response_object = {'status': 'error', 'message': message}
 | 
				
			||||||
            return jsonify(response_object), 404
 | 
					            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
 | 
					        code = 200
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        status = 'not found'
 | 
					        status = 'not found'
 | 
				
			||||||
        message = f'Activity not found (id: {activity_uuid})'
 | 
					        message = f'Activity not found (id: {activity_short_id})'
 | 
				
			||||||
        code = 404
 | 
					        code = 404
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    response_object = {
 | 
					    response_object = {
 | 
				
			||||||
@@ -438,10 +445,10 @@ def get_activity_data(auth_user_id, activity_uuid, data_type, segment_id=None):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@activities_blueprint.route(
 | 
					@activities_blueprint.route(
 | 
				
			||||||
    '/activities/<string:activity_uuid>/gpx', methods=['GET']
 | 
					    '/activities/<string:activity_short_id>/gpx', methods=['GET']
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@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
 | 
					    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
 | 
					    .. sourcecode:: http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx HTTP/1.1
 | 
					      GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx HTTP/1.1
 | 
				
			||||||
      Content-Type: application/json
 | 
					      Content-Type: application/json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    **Example response**:
 | 
					    **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 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
 | 
					    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -483,14 +490,14 @@ def get_activity_gpx(auth_user_id, activity_uuid):
 | 
				
			|||||||
    :statuscode 500:
 | 
					    :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_blueprint.route(
 | 
				
			||||||
    '/activities/<string:activity_uuid>/chart_data', methods=['GET']
 | 
					    '/activities/<string:activity_short_id>/chart_data', methods=['GET']
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@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
 | 
					    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
 | 
					    .. sourcecode:: http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/chart HTTP/1.1
 | 
					      GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/chart HTTP/1.1
 | 
				
			||||||
      Content-Type: application/json
 | 
					      Content-Type: application/json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    **Example response**:
 | 
					    **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 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
 | 
					    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -551,15 +558,15 @@ def get_activity_chart_data(auth_user_id, activity_uuid):
 | 
				
			|||||||
    :statuscode 500:
 | 
					    :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_blueprint.route(
 | 
				
			||||||
    '/activities/<string:activity_uuid>/gpx/segment/<int:segment_id>',
 | 
					    '/activities/<string:activity_short_id>/gpx/segment/<int:segment_id>',
 | 
				
			||||||
    methods=['GET'],
 | 
					    methods=['GET'],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@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
 | 
					    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
 | 
					    .. sourcecode:: http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/gpx/segment/0
 | 
					      GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/gpx/segment/0 HTTP/1.1
 | 
				
			||||||
        HTTP/1.1
 | 
					 | 
				
			||||||
      Content-Type: application/json
 | 
					      Content-Type: application/json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    **Example response**:
 | 
					    **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 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
 | 
					    :param integer segment_id: segment id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
					    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
				
			||||||
@@ -602,15 +608,18 @@ def get_segment_gpx(auth_user_id, activity_uuid, segment_id):
 | 
				
			|||||||
    :statuscode 500:
 | 
					    :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_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'],
 | 
					    methods=['GET'],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@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
 | 
					    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
 | 
					    .. sourcecode:: http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      GET /api/activities/f03265f69fe0489b812fc7dc4deff55e/chart/segment/0
 | 
					      GET /api/activities/kjxavSTUrJvoAh2wvCeGEF/chart/segment/0 HTTP/1.1
 | 
				
			||||||
        HTTP/1.1
 | 
					 | 
				
			||||||
      Content-Type: application/json
 | 
					      Content-Type: application/json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    **Example response**:
 | 
					    **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 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
 | 
					    :param integer segment_id: segment id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
					    :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:
 | 
					    :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'])
 | 
					@activities_blueprint.route('/activities/map/<map_id>', methods=['GET'])
 | 
				
			||||||
@@ -794,7 +804,7 @@ def post_activity(auth_user_id):
 | 
				
			|||||||
                "descent": null,
 | 
					                "descent": null,
 | 
				
			||||||
                "distance": 10.0,
 | 
					                "distance": 10.0,
 | 
				
			||||||
                "duration": "0:17:04",
 | 
					                "duration": "0:17:04",
 | 
				
			||||||
                "id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                "id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                "map": null,
 | 
					                "map": null,
 | 
				
			||||||
                "max_alt": null,
 | 
					                "max_alt": null,
 | 
				
			||||||
                "max_speed": 10.0,
 | 
					                "max_speed": 10.0,
 | 
				
			||||||
@@ -808,7 +818,7 @@ def post_activity(auth_user_id):
 | 
				
			|||||||
                "records": [
 | 
					                "records": [
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 4,
 | 
					                    "id": 4,
 | 
				
			||||||
                    "record_type": "MS",
 | 
					                    "record_type": "MS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -817,7 +827,7 @@ def post_activity(auth_user_id):
 | 
				
			|||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 3,
 | 
					                    "id": 3,
 | 
				
			||||||
                    "record_type": "LD",
 | 
					                    "record_type": "LD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -826,7 +836,7 @@ def post_activity(auth_user_id):
 | 
				
			|||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 2,
 | 
					                    "id": 2,
 | 
				
			||||||
                    "record_type": "FD",
 | 
					                    "record_type": "FD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -835,7 +845,7 @@ def post_activity(auth_user_id):
 | 
				
			|||||||
                  },
 | 
					                  },
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 1,
 | 
					                    "id": 1,
 | 
				
			||||||
                    "record_type": "AS",
 | 
					                    "record_type": "AS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -883,7 +893,7 @@ def post_activity(auth_user_id):
 | 
				
			|||||||
    if response_object['status'] != 'success':
 | 
					    if response_object['status'] != 'success':
 | 
				
			||||||
        return jsonify(response_object), response_code
 | 
					        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:
 | 
					    if not activity_data or activity_data.get('sport_id') is None:
 | 
				
			||||||
        response_object = {'status': 'error', 'message': 'Invalid payload.'}
 | 
					        response_object = {'status': 'error', 'message': 'Invalid payload.'}
 | 
				
			||||||
        return jsonify(response_object), 400
 | 
					        return jsonify(response_object), 400
 | 
				
			||||||
@@ -972,7 +982,7 @@ def post_activity_no_gpx(auth_user_id):
 | 
				
			|||||||
                "records": [
 | 
					                "records": [
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 4,
 | 
					                    "id": 4,
 | 
				
			||||||
                    "record_type": "MS",
 | 
					                    "record_type": "MS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "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_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 3,
 | 
					                    "id": 3,
 | 
				
			||||||
                    "record_type": "LD",
 | 
					                    "record_type": "LD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "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_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 2,
 | 
					                    "id": 2,
 | 
				
			||||||
                    "record_type": "FD",
 | 
					                    "record_type": "FD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "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_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 1,
 | 
					                    "id": 1,
 | 
				
			||||||
                    "record_type": "AS",
 | 
					                    "record_type": "AS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -1011,7 +1021,7 @@ def post_activity_no_gpx(auth_user_id):
 | 
				
			|||||||
                "sport_id": 1,
 | 
					                "sport_id": 1,
 | 
				
			||||||
                "title": null,
 | 
					                "title": null,
 | 
				
			||||||
                "user": "admin",
 | 
					                "user": "admin",
 | 
				
			||||||
                "uuid": "f03265f69fe0489b812fc7dc4deff55e"
 | 
					                "uuid": "kjxavSTUrJvoAh2wvCeGEF"
 | 
				
			||||||
                "weather_end": null,
 | 
					                "weather_end": null,
 | 
				
			||||||
                "weather_start": null,
 | 
					                "weather_start": null,
 | 
				
			||||||
                "with_gpx": false
 | 
					                "with_gpx": false
 | 
				
			||||||
@@ -1075,10 +1085,10 @@ def post_activity_no_gpx(auth_user_id):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@activities_blueprint.route(
 | 
					@activities_blueprint.route(
 | 
				
			||||||
    '/activities/<string:activity_uuid>', methods=['PATCH']
 | 
					    '/activities/<string:activity_short_id>', methods=['PATCH']
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@authenticate
 | 
				
			||||||
def update_activity(auth_user_id, activity_uuid):
 | 
					def update_activity(auth_user_id, activity_short_id):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Update an activity
 | 
					    Update an activity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1121,7 +1131,7 @@ def update_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
                "records": [
 | 
					                "records": [
 | 
				
			||||||
                  {
 | 
					                  {
 | 
				
			||||||
                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
					                    "activity_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 4,
 | 
					                    "id": 4,
 | 
				
			||||||
                    "record_type": "MS",
 | 
					                    "record_type": "MS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "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_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 3,
 | 
					                    "id": 3,
 | 
				
			||||||
                    "record_type": "LD",
 | 
					                    "record_type": "LD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "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_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 2,
 | 
					                    "id": 2,
 | 
				
			||||||
                    "record_type": "FD",
 | 
					                    "record_type": "FD",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "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_date": "Mon, 01 Jan 2018 00:00:00 GMT",
 | 
				
			||||||
                    "activity_id": "f03265f69fe0489b812fc7dc4deff55e",
 | 
					                    "activity_id": "kjxavSTUrJvoAh2wvCeGEF",
 | 
				
			||||||
                    "id": 1,
 | 
					                    "id": 1,
 | 
				
			||||||
                    "record_type": "AS",
 | 
					                    "record_type": "AS",
 | 
				
			||||||
                    "sport_id": 1,
 | 
					                    "sport_id": 1,
 | 
				
			||||||
@@ -1160,7 +1170,7 @@ def update_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
                "sport_id": 1,
 | 
					                "sport_id": 1,
 | 
				
			||||||
                "title": null,
 | 
					                "title": null,
 | 
				
			||||||
                "user": "admin",
 | 
					                "user": "admin",
 | 
				
			||||||
                "uuid": "f03265f69fe0489b812fc7dc4deff55e"
 | 
					                "uuid": "kjxavSTUrJvoAh2wvCeGEF"
 | 
				
			||||||
                "weather_end": null,
 | 
					                "weather_end": null,
 | 
				
			||||||
                "weather_start": null,
 | 
					                "weather_start": null,
 | 
				
			||||||
                "with_gpx": false
 | 
					                "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 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``)
 | 
					    :<json string activity_date: activity date  (format: ``%Y-%m-%d %H:%M``)
 | 
				
			||||||
        (only for activity without gpx)
 | 
					        (only for activity without gpx)
 | 
				
			||||||
@@ -1201,6 +1211,7 @@ def update_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
        return jsonify(response_object), 400
 | 
					        return jsonify(response_object), 400
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
 | 
					        activity_uuid = decode_short_id(activity_short_id)
 | 
				
			||||||
        activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
					        activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
				
			||||||
        if activity:
 | 
					        if activity:
 | 
				
			||||||
            response_object, code = can_view_activity(
 | 
					            response_object, code = can_view_activity(
 | 
				
			||||||
@@ -1234,10 +1245,10 @@ def update_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@activities_blueprint.route(
 | 
					@activities_blueprint.route(
 | 
				
			||||||
    '/activities/<string:activity_uuid>', methods=['DELETE']
 | 
					    '/activities/<string:activity_short_id>', methods=['DELETE']
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@authenticate
 | 
					@authenticate
 | 
				
			||||||
def delete_activity(auth_user_id, activity_uuid):
 | 
					def delete_activity(auth_user_id, activity_short_id):
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Delete an activity
 | 
					    Delete an activity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1245,7 +1256,7 @@ def delete_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    .. sourcecode:: http
 | 
					    .. sourcecode:: http
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      DELETE /api/activities/f03265f69fe0489b812fc7dc4deff55e HTTP/1.1
 | 
					      DELETE /api/activities/kjxavSTUrJvoAh2wvCeGEF HTTP/1.1
 | 
				
			||||||
      Content-Type: application/json
 | 
					      Content-Type: application/json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    **Example response**:
 | 
					    **Example response**:
 | 
				
			||||||
@@ -1256,7 +1267,7 @@ def delete_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
      Content-Type: application/json
 | 
					      Content-Type: application/json
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    :param integer auth_user_id: authenticate user id (from JSON Web Token)
 | 
					    :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
 | 
					    :reqheader Authorization: OAuth 2.0 Bearer Token
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1271,6 +1282,7 @@ def delete_activity(auth_user_id, activity_uuid):
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
 | 
					        activity_uuid = decode_short_id(activity_short_id)
 | 
				
			||||||
        activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
					        activity = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
				
			||||||
        if activity:
 | 
					        if activity:
 | 
				
			||||||
            response_object, code = can_view_activity(
 | 
					            response_object, code = can_view_activity(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@ from sqlalchemy.types import JSON, Enum
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from .utils_files import get_absolute_file_path
 | 
					from .utils_files import get_absolute_file_path
 | 
				
			||||||
from .utils_format import convert_in_duration, convert_value_to_integer
 | 
					from .utils_format import convert_in_duration, convert_value_to_integer
 | 
				
			||||||
 | 
					from .utils_id import encode_uuid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
record_types = [
 | 
					record_types = [
 | 
				
			||||||
    'AS',  # 'Best Average Speed'
 | 
					    'AS',  # 'Best Average Speed'
 | 
				
			||||||
@@ -147,6 +148,10 @@ class Activity(db.Model):
 | 
				
			|||||||
        self.distance = distance
 | 
					        self.distance = distance
 | 
				
			||||||
        self.duration = duration
 | 
					        self.duration = duration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @property
 | 
				
			||||||
 | 
					    def short_id(self):
 | 
				
			||||||
 | 
					        return encode_uuid(self.uuid)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def serialize(self, params=None):
 | 
					    def serialize(self, params=None):
 | 
				
			||||||
        date_from = params.get('from') if params else None
 | 
					        date_from = params.get('from') if params else None
 | 
				
			||||||
        date_to = params.get('to') if params else None
 | 
					        date_to = params.get('to') if params else None
 | 
				
			||||||
@@ -234,7 +239,7 @@ class Activity(db.Model):
 | 
				
			|||||||
            .first()
 | 
					            .first()
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        return {
 | 
					        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,
 | 
					            "user": self.user.username,
 | 
				
			||||||
            "sport_id": self.sport_id,
 | 
					            "sport_id": self.sport_id,
 | 
				
			||||||
            "title": self.title,
 | 
					            "title": self.title,
 | 
				
			||||||
@@ -255,10 +260,10 @@ class Activity(db.Model):
 | 
				
			|||||||
            "bounds": [float(bound) for bound in self.bounds]
 | 
					            "bounds": [float(bound) for bound in self.bounds]
 | 
				
			||||||
            if self.bounds
 | 
					            if self.bounds
 | 
				
			||||||
            else [],  # noqa
 | 
					            else [],  # noqa
 | 
				
			||||||
            "previous_activity": previous_activity.uuid.hex
 | 
					            "previous_activity": previous_activity.short_id
 | 
				
			||||||
            if previous_activity
 | 
					            if previous_activity
 | 
				
			||||||
            else None,  # noqa
 | 
					            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],
 | 
					            "segments": [segment.serialize() for segment in self.segments],
 | 
				
			||||||
            "records": [record.serialize() for record in self.records],
 | 
					            "records": [record.serialize() for record in self.records],
 | 
				
			||||||
            "map": self.map_id if self.map else None,
 | 
					            "map": self.map_id if self.map else None,
 | 
				
			||||||
@@ -351,7 +356,7 @@ class ActivitySegment(db.Model):
 | 
				
			|||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return (
 | 
					        return (
 | 
				
			||||||
            f'<Segment \'{self.segment_id}\' '
 | 
					            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):
 | 
					    def __init__(self, segment_id, activity_id, activity_uuid):
 | 
				
			||||||
@@ -361,7 +366,7 @@ class ActivitySegment(db.Model):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def serialize(self):
 | 
					    def serialize(self):
 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            "activity_id": self.activity_uuid.hex,
 | 
					            "activity_id": encode_uuid(self.activity_uuid),
 | 
				
			||||||
            "segment_id": self.segment_id,
 | 
					            "segment_id": self.segment_id,
 | 
				
			||||||
            "duration": str(self.duration) if self.duration else None,
 | 
					            "duration": str(self.duration) if self.duration else None,
 | 
				
			||||||
            "pauses": str(self.pauses) if self.pauses else None,
 | 
					            "pauses": str(self.pauses) if self.pauses else None,
 | 
				
			||||||
@@ -438,7 +443,7 @@ class Record(db.Model):
 | 
				
			|||||||
            "id": self.id,
 | 
					            "id": self.id,
 | 
				
			||||||
            "user": self.user.username,
 | 
					            "user": self.user.username,
 | 
				
			||||||
            "sport_id": self.sport_id,
 | 
					            "sport_id": self.sport_id,
 | 
				
			||||||
            "activity_id": self.activity_uuid.hex,
 | 
					            "activity_id": encode_uuid(self.activity_uuid),
 | 
				
			||||||
            "record_type": self.record_type,
 | 
					            "record_type": self.record_type,
 | 
				
			||||||
            "activity_date": self.activity_date,
 | 
					            "activity_date": self.activity_date,
 | 
				
			||||||
            "value": value,
 | 
					            "value": value,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,7 @@ def get_records(auth_user_id):
 | 
				
			|||||||
          "records": [
 | 
					          "records": [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
					              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
				
			||||||
              "activity_id": "e060bde05e3f4906a32913b102c814cb",
 | 
					              "activity_id": "hvYBqYBRa7wwXpaStWR4V2",
 | 
				
			||||||
              "id": 9,
 | 
					              "id": 9,
 | 
				
			||||||
              "record_type": "AS",
 | 
					              "record_type": "AS",
 | 
				
			||||||
              "sport_id": 1,
 | 
					              "sport_id": 1,
 | 
				
			||||||
@@ -48,7 +48,7 @@ def get_records(auth_user_id):
 | 
				
			|||||||
            },
 | 
					            },
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
					              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
				
			||||||
              "activity_id": "e060bde05e3f4906a32913b102c814cb",
 | 
					              "activity_id": "hvYBqYBRa7wwXpaStWR4V2",
 | 
				
			||||||
              "id": 10,
 | 
					              "id": 10,
 | 
				
			||||||
              "record_type": "FD",
 | 
					              "record_type": "FD",
 | 
				
			||||||
              "sport_id": 1,
 | 
					              "sport_id": 1,
 | 
				
			||||||
@@ -57,7 +57,7 @@ def get_records(auth_user_id):
 | 
				
			|||||||
            },
 | 
					            },
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
					              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
				
			||||||
              "activity_id": "e060bde05e3f4906a32913b102c814cb",
 | 
					              "activity_id": "hvYBqYBRa7wwXpaStWR4V2",
 | 
				
			||||||
              "id": 11,
 | 
					              "id": 11,
 | 
				
			||||||
              "record_type": "LD",
 | 
					              "record_type": "LD",
 | 
				
			||||||
              "sport_id": 1,
 | 
					              "sport_id": 1,
 | 
				
			||||||
@@ -66,7 +66,7 @@ def get_records(auth_user_id):
 | 
				
			|||||||
            },
 | 
					            },
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
					              "activity_date": "Sun, 07 Jul 2019 08:00:00 GMT",
 | 
				
			||||||
              "activity_id": "e060bde05e3f4906a32913b102c814cb",
 | 
					              "activity_id": "hvYBqYBRa7wwXpaStWR4V2",
 | 
				
			||||||
              "id": 12,
 | 
					              "id": 12,
 | 
				
			||||||
              "record_type": "MS",
 | 
					              "record_type": "MS",
 | 
				
			||||||
              "sport_id": 1,
 | 
					              "sport_id": 1,
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								fittrackee/activities/utils_id.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								fittrackee/activities/utils_id.py
									
									
									
									
									
										Normal 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)
 | 
				
			||||||
@@ -1,6 +1,8 @@
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
from uuid import uuid4
 | 
					from uuid import uuid4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from .utils import get_random_short_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestGetActivities:
 | 
					class TestGetActivities:
 | 
				
			||||||
    def test_it_gets_all_activities_for_authenticated_user(
 | 
					    def test_it_gets_all_activities_for_authenticated_user(
 | 
				
			||||||
@@ -695,7 +697,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_1.uuid.hex}',
 | 
					            f'/api/activities/{activity_cycling_user_1.short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -727,7 +729,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_2.uuid.hex}',
 | 
					            f'/api/activities/{activity_cycling_user_2.short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -748,7 +750,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{uuid4().hex}',
 | 
					            f'/api/activities/{get_random_short_id()}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + 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(
 | 
					    def test_it_returns_404_on_getting_gpx_if_activity_does_not_exist(
 | 
				
			||||||
        self, app, user_1
 | 
					        self, app, user_1
 | 
				
			||||||
    ):
 | 
					    ):
 | 
				
			||||||
        random_uuid = uuid4().hex
 | 
					        random_short_id = get_random_short_id()
 | 
				
			||||||
        client = app.test_client()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -772,7 +774,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{random_uuid}/gpx',
 | 
					            f'/api/activities/{random_short_id}/gpx',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -782,13 +784,13 @@ class TestGetActivity:
 | 
				
			|||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        assert response.status_code == 404
 | 
					        assert response.status_code == 404
 | 
				
			||||||
        assert 'not found' in data['status']
 | 
					        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'] == ''
 | 
					        assert data['data']['gpx'] == ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_it_returns_404_on_getting_chart_data_if_activity_does_not_exist(
 | 
					    def test_it_returns_404_on_getting_chart_data_if_activity_does_not_exist(
 | 
				
			||||||
        self, app, user_1
 | 
					        self, app, user_1
 | 
				
			||||||
    ):
 | 
					    ):
 | 
				
			||||||
        random_uuid = uuid4().hex
 | 
					        random_short_id = get_random_short_id()
 | 
				
			||||||
        client = app.test_client()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -797,7 +799,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{random_uuid}/chart_data',
 | 
					            f'/api/activities/{random_short_id}/chart_data',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -807,13 +809,13 @@ class TestGetActivity:
 | 
				
			|||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        assert response.status_code == 404
 | 
					        assert response.status_code == 404
 | 
				
			||||||
        assert 'not found' in data['status']
 | 
					        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'] == ''
 | 
					        assert data['data']['chart_data'] == ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_it_returns_404_on_getting_gpx_if_activity_have_no_gpx(
 | 
					    def test_it_returns_404_on_getting_gpx_if_activity_have_no_gpx(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, activity_cycling_user_1
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -822,7 +824,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/gpx',
 | 
					            f'/api/activities/{activity_short_id}/gpx',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -833,14 +835,14 @@ class TestGetActivity:
 | 
				
			|||||||
        assert response.status_code == 404
 | 
					        assert response.status_code == 404
 | 
				
			||||||
        assert 'error' in data['status']
 | 
					        assert 'error' in data['status']
 | 
				
			||||||
        assert (
 | 
					        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']
 | 
					            in data['message']
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_it_returns_404_if_activity_have_no_chart_data(
 | 
					    def test_it_returns_404_if_activity_have_no_chart_data(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, activity_cycling_user_1
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -849,7 +851,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/chart_data',
 | 
					            f'/api/activities/{activity_short_id}/chart_data',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -860,7 +862,7 @@ class TestGetActivity:
 | 
				
			|||||||
        assert response.status_code == 404
 | 
					        assert response.status_code == 404
 | 
				
			||||||
        assert 'error' in data['status']
 | 
					        assert 'error' in data['status']
 | 
				
			||||||
        assert (
 | 
					        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']
 | 
					            in data['message']
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -876,7 +878,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        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(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -901,7 +903,7 @@ class TestGetActivity:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        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(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@ from datetime import datetime
 | 
				
			|||||||
from io import BytesIO
 | 
					from io import BytesIO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from fittrackee.activities.models import Activity
 | 
					from fittrackee.activities.models import Activity
 | 
				
			||||||
 | 
					from fittrackee.activities.utils_id import decode_short_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def assert_activity_data_with_gpx(data):
 | 
					def assert_activity_data_with_gpx(data):
 | 
				
			||||||
@@ -782,10 +783,10 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
        else:
 | 
					        else:
 | 
				
			||||||
            assert_activity_data_with_gpx(data)
 | 
					            assert_activity_data_with_gpx(data)
 | 
				
			||||||
        map_id = data['data']['activities'][0]['map']
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/gpx',
 | 
					            f'/api/activities/{activity_short_id}/gpx',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -799,7 +800,7 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
        assert len(data['data']['gpx']) != ''
 | 
					        assert len(data['data']['gpx']) != ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/gpx/segment/1',
 | 
					            f'/api/activities/{activity_short_id}/gpx/segment/1',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -822,6 +823,7 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
        assert response.status_code == 200
 | 
					        assert response.status_code == 200
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # error case in the same test to avoid generate a new map file
 | 
					        # 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 = Activity.query.filter_by(uuid=activity_uuid).first()
 | 
				
			||||||
        activity.map = 'incorrect path'
 | 
					        activity.map = 'incorrect path'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -876,9 +878,9 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/chart_data',
 | 
					            f'/api/activities/{activity_short_id}/chart_data',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -914,9 +916,9 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/chart_data/segment/1',
 | 
					            f'/api/activities/{activity_short_id}/chart_data/segment/1',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -951,7 +953,7 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -959,7 +961,7 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/chart_data',
 | 
					            f'/api/activities/{activity_short_id}/chart_data',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -994,9 +996,9 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/chart_data/segment/0',
 | 
					            f'/api/activities/{activity_short_id}/chart_data/segment/0',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -1032,9 +1034,9 @@ class TestPostAndGetActivityWithGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}/chart_data/segment/999999',
 | 
					            f'/api/activities/{activity_short_id}/chart_data/segment/999999',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -1076,9 +1078,9 @@ class TestPostAndGetActivityWithoutGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -1119,9 +1121,9 @@ class TestPostAndGetActivityWithoutGpx:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -1164,9 +1166,9 @@ class TestPostAndGetActivityUsingTimezones:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        data = json.loads(response.data.decode())
 | 
				
			||||||
        activity_uuid = data['data']['activities'][0]['id']
 | 
					        activity_short_id = data['data']['activities'][0]['id']
 | 
				
			||||||
        response = client.get(
 | 
					        response = client.get(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,9 @@
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
from uuid import uuid4
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from fittrackee.activities.models import Activity
 | 
					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):
 | 
					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(
 | 
					    def test_it_updates_title_for_an_activity_with_gpx(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, sport_2_running, gpx_file
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(sport_id=2, title="Activity test")),
 | 
					            data=json.dumps(dict(sport_id=2, title="Activity test")),
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
@@ -74,11 +74,11 @@ class TestEditActivityWithGpx:
 | 
				
			|||||||
    def test_it_adds_notes_for_an_activity_with_gpx(
 | 
					    def test_it_adds_notes_for_an_activity_with_gpx(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, sport_2_running, gpx_file
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(notes="test notes")),
 | 
					            data=json.dumps(dict(notes="test notes")),
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
@@ -94,7 +94,7 @@ class TestEditActivityWithGpx:
 | 
				
			|||||||
    def test_it_raises_403_when_editing_an_activity_from_different_user(
 | 
					    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
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -103,7 +103,7 @@ class TestEditActivityWithGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(sport_id=2, title="Activity test")),
 | 
					            data=json.dumps(dict(sport_id=2, title="Activity test")),
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -120,11 +120,11 @@ class TestEditActivityWithGpx:
 | 
				
			|||||||
    def test_it_updates_sport(
 | 
					    def test_it_updates_sport(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, sport_2_running, gpx_file
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(sport_id=2)),
 | 
					            data=json.dumps(dict(sport_id=2)),
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
@@ -141,11 +141,11 @@ class TestEditActivityWithGpx:
 | 
				
			|||||||
    def test_it_returns_400_if_payload_is_empty(
 | 
					    def test_it_returns_400_if_payload_is_empty(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, gpx_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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict()),
 | 
					            data=json.dumps(dict()),
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
@@ -159,11 +159,11 @@ class TestEditActivityWithGpx:
 | 
				
			|||||||
    def test_it_raises_500_if_sport_does_not_exists(
 | 
					    def test_it_raises_500_if_sport_does_not_exists(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, gpx_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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(sport_id=2)),
 | 
					            data=json.dumps(dict(sport_id=2)),
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
@@ -187,7 +187,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        sport_2_running,
 | 
					        sport_2_running,
 | 
				
			||||||
        activity_cycling_user_1,
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -196,7 +196,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(
 | 
					            data=json.dumps(
 | 
				
			||||||
                dict(
 | 
					                dict(
 | 
				
			||||||
@@ -245,22 +245,22 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        records = data['data']['activities'][0]['records']
 | 
					        records = data['data']['activities'][0]['records']
 | 
				
			||||||
        assert len(records) == 4
 | 
					        assert len(records) == 4
 | 
				
			||||||
        assert records[0]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'MS'
 | 
				
			||||||
        assert records[0]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
					        assert records[0]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
				
			||||||
        assert records[0]['value'] == 8.0
 | 
					        assert records[0]['value'] == 8.0
 | 
				
			||||||
        assert records[1]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'LD'
 | 
				
			||||||
        assert records[1]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
					        assert records[1]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
				
			||||||
        assert records[1]['value'] == '1:00:00'
 | 
					        assert records[1]['value'] == '1:00:00'
 | 
				
			||||||
        assert records[2]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'FD'
 | 
				
			||||||
        assert records[2]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
					        assert records[2]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
				
			||||||
        assert records[2]['value'] == 8.0
 | 
					        assert records[2]['value'] == 8.0
 | 
				
			||||||
        assert records[3]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'AS'
 | 
				
			||||||
        assert records[3]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
					        assert records[3]['activity_date'] == 'Tue, 15 May 2018 15:05:00 GMT'
 | 
				
			||||||
        assert records[3]['value'] == 8.0
 | 
					        assert records[3]['value'] == 8.0
 | 
				
			||||||
@@ -268,7 +268,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
    def test_it_adds_notes_to_an_activity_wo_gpx(
 | 
					    def test_it_adds_notes_to_an_activity_wo_gpx(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, activity_cycling_user_1
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -277,7 +277,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(notes='test notes')),
 | 
					            data=json.dumps(dict(notes='test notes')),
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -317,22 +317,22 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        records = data['data']['activities'][0]['records']
 | 
					        records = data['data']['activities'][0]['records']
 | 
				
			||||||
        assert len(records) == 4
 | 
					        assert len(records) == 4
 | 
				
			||||||
        assert records[0]['sport_id'] == sport_1_cycling.id
 | 
					        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]['record_type'] == 'MS'
 | 
				
			||||||
        assert records[0]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[0]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[0]['value'] == 10.0
 | 
					        assert records[0]['value'] == 10.0
 | 
				
			||||||
        assert records[1]['sport_id'] == sport_1_cycling.id
 | 
					        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]['record_type'] == 'LD'
 | 
				
			||||||
        assert records[1]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[1]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[1]['value'] == '1:00:00'
 | 
					        assert records[1]['value'] == '1:00:00'
 | 
				
			||||||
        assert records[2]['sport_id'] == sport_1_cycling.id
 | 
					        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]['record_type'] == 'FD'
 | 
				
			||||||
        assert records[2]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[2]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[2]['value'] == 10.0
 | 
					        assert records[2]['value'] == 10.0
 | 
				
			||||||
        assert records[3]['sport_id'] == sport_1_cycling.id
 | 
					        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]['record_type'] == 'AS'
 | 
				
			||||||
        assert records[3]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[3]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[3]['value'] == 10.0
 | 
					        assert records[3]['value'] == 10.0
 | 
				
			||||||
@@ -348,7 +348,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_2.uuid}',
 | 
					            f'/api/activities/{activity_cycling_user_2.short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(
 | 
					            data=json.dumps(
 | 
				
			||||||
                dict(
 | 
					                dict(
 | 
				
			||||||
@@ -378,7 +378,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        sport_2_running,
 | 
					        sport_2_running,
 | 
				
			||||||
        activity_cycling_user_1,
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -387,7 +387,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(
 | 
					            data=json.dumps(
 | 
				
			||||||
                dict(
 | 
					                dict(
 | 
				
			||||||
@@ -431,22 +431,22 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        records = data['data']['activities'][0]['records']
 | 
					        records = data['data']['activities'][0]['records']
 | 
				
			||||||
        assert len(records) == 4
 | 
					        assert len(records) == 4
 | 
				
			||||||
        assert records[0]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'MS'
 | 
				
			||||||
        assert records[0]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
					        assert records[0]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
				
			||||||
        assert records[0]['value'] == 8.0
 | 
					        assert records[0]['value'] == 8.0
 | 
				
			||||||
        assert records[1]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'LD'
 | 
				
			||||||
        assert records[1]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
					        assert records[1]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
				
			||||||
        assert records[1]['value'] == '1:00:00'
 | 
					        assert records[1]['value'] == '1:00:00'
 | 
				
			||||||
        assert records[2]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'FD'
 | 
				
			||||||
        assert records[2]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
					        assert records[2]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
				
			||||||
        assert records[2]['value'] == 8.0
 | 
					        assert records[2]['value'] == 8.0
 | 
				
			||||||
        assert records[3]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'AS'
 | 
				
			||||||
        assert records[3]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
					        assert records[3]['activity_date'] == 'Tue, 15 May 2018 13:05:00 GMT'
 | 
				
			||||||
        assert records[3]['value'] == 8.0
 | 
					        assert records[3]['value'] == 8.0
 | 
				
			||||||
@@ -459,7 +459,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        sport_2_running,
 | 
					        sport_2_running,
 | 
				
			||||||
        activity_cycling_user_1,
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -468,7 +468,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(sport_id=2, distance=20)),
 | 
					            data=json.dumps(dict(sport_id=2, distance=20)),
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -504,22 +504,22 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        records = data['data']['activities'][0]['records']
 | 
					        records = data['data']['activities'][0]['records']
 | 
				
			||||||
        assert len(records) == 4
 | 
					        assert len(records) == 4
 | 
				
			||||||
        assert records[0]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'MS'
 | 
				
			||||||
        assert records[0]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[0]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[0]['value'] == 20.0
 | 
					        assert records[0]['value'] == 20.0
 | 
				
			||||||
        assert records[1]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'LD'
 | 
				
			||||||
        assert records[1]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[1]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[1]['value'] == '1:00:00'
 | 
					        assert records[1]['value'] == '1:00:00'
 | 
				
			||||||
        assert records[2]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'FD'
 | 
				
			||||||
        assert records[2]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[2]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[2]['value'] == 20.0
 | 
					        assert records[2]['value'] == 20.0
 | 
				
			||||||
        assert records[3]['sport_id'] == sport_2_running.id
 | 
					        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]['record_type'] == 'AS'
 | 
				
			||||||
        assert records[3]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
					        assert records[3]['activity_date'] == 'Mon, 01 Jan 2018 00:00:00 GMT'
 | 
				
			||||||
        assert records[3]['value'] == 20.0
 | 
					        assert records[3]['value'] == 20.0
 | 
				
			||||||
@@ -535,7 +535,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_1.uuid}',
 | 
					            f'/api/activities/{activity_cycling_user_1.short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict()),
 | 
					            data=json.dumps(dict()),
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -559,7 +559,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_1.uuid}',
 | 
					            f'/api/activities/{activity_cycling_user_1.short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(
 | 
					            data=json.dumps(
 | 
				
			||||||
                dict(
 | 
					                dict(
 | 
				
			||||||
@@ -594,7 +594,7 @@ class TestEditActivityWithoutGpx:
 | 
				
			|||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{uuid4().hex}',
 | 
					            f'/api/activities/{get_random_short_id()}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(
 | 
					            data=json.dumps(
 | 
				
			||||||
                dict(
 | 
					                dict(
 | 
				
			||||||
@@ -620,7 +620,8 @@ class TestRefreshActivityWithGpx:
 | 
				
			|||||||
    def test_refresh_an_activity_with_gpx(
 | 
					    def test_refresh_an_activity_with_gpx(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, sport_2_running, gpx_file
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Edit some activity data
 | 
					        # Edit some activity data
 | 
				
			||||||
@@ -629,7 +630,7 @@ class TestRefreshActivityWithGpx:
 | 
				
			|||||||
        activity.min_alt = -100
 | 
					        activity.min_alt = -100
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.patch(
 | 
					        response = client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(refresh=True)),
 | 
					            data=json.dumps(dict(refresh=True)),
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,11 +1,10 @@
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
from uuid import uuid4
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
from fittrackee.activities.models import Activity
 | 
					from fittrackee.activities.models import Activity
 | 
				
			||||||
from fittrackee.activities.utils import get_absolute_file_path
 | 
					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):
 | 
					def get_gpx_filepath(activity_id):
 | 
				
			||||||
@@ -17,11 +16,11 @@ class TestDeleteActivityWithGpx:
 | 
				
			|||||||
    def test_it_deletes_an_activity_with_gpx(
 | 
					    def test_it_deletes_an_activity_with_gpx(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, gpx_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()
 | 
					        client = app.test_client()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.delete(
 | 
					        response = client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -30,7 +29,7 @@ class TestDeleteActivityWithGpx:
 | 
				
			|||||||
    def test_it_returns_403_when_deleting_an_activity_from_different_user(
 | 
					    def test_it_returns_403_when_deleting_an_activity_from_different_user(
 | 
				
			||||||
        self, app, user_1, user_2, sport_1_cycling, gpx_file
 | 
					        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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        resp_login = client.post(
 | 
					        resp_login = client.post(
 | 
				
			||||||
            '/api/auth/login',
 | 
					            '/api/auth/login',
 | 
				
			||||||
@@ -39,7 +38,7 @@ class TestDeleteActivityWithGpx:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.delete(
 | 
					        response = client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -60,7 +59,7 @@ class TestDeleteActivityWithGpx:
 | 
				
			|||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        response = client.delete(
 | 
					        response = client.delete(
 | 
				
			||||||
            f'/api/activities/{uuid4().hex}',
 | 
					            f'/api/activities/{get_random_short_id()}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + 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(
 | 
					    def test_it_returns_500_when_deleting_an_activity_with_gpx_invalid_file(
 | 
				
			||||||
        self, app, user_1, sport_1_cycling, gpx_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()
 | 
					        client = app.test_client()
 | 
				
			||||||
        gpx_filepath = get_gpx_filepath(1)
 | 
					        gpx_filepath = get_gpx_filepath(1)
 | 
				
			||||||
        gpx_filepath = get_absolute_file_path(gpx_filepath)
 | 
					        gpx_filepath = get_absolute_file_path(gpx_filepath)
 | 
				
			||||||
        os.remove(gpx_filepath)
 | 
					        os.remove(gpx_filepath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        response = client.delete(
 | 
					        response = client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_uuid}',
 | 
					            f'/api/activities/{activity_short_id}',
 | 
				
			||||||
            headers=dict(Authorization=f'Bearer {token}'),
 | 
					            headers=dict(Authorization=f'Bearer {token}'),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -105,7 +104,7 @@ class TestDeleteActivityWithoutGpx:
 | 
				
			|||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        response = client.delete(
 | 
					        response = client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_1.uuid}',
 | 
					            f'/api/activities/{activity_cycling_user_1.short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -123,7 +122,7 @@ class TestDeleteActivityWithoutGpx:
 | 
				
			|||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        response = client.delete(
 | 
					        response = client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_cycling_user_1.uuid}',
 | 
					            f'/api/activities/{activity_cycling_user_1.short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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:
 | 
					class TestActivityModel:
 | 
				
			||||||
@@ -22,7 +24,7 @@ class TestActivityModel:
 | 
				
			|||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        serialized_activity = activity_cycling_user_1.serialize()
 | 
					        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 'test' == serialized_activity['user']
 | 
				
			||||||
        assert 1 == serialized_activity['sport_id']
 | 
					        assert 1 == serialized_activity['sport_id']
 | 
				
			||||||
        assert serialized_activity['title'] == 'Test'
 | 
					        assert serialized_activity['title'] == 'Test'
 | 
				
			||||||
@@ -61,6 +63,6 @@ class TestActivityModel:
 | 
				
			|||||||
    ):
 | 
					    ):
 | 
				
			||||||
        assert (
 | 
					        assert (
 | 
				
			||||||
            f'<Segment \'{activity_cycling_user_1_segment.segment_id}\' '
 | 
					            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)
 | 
					            == str(activity_cycling_user_1_segment)
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,7 +38,7 @@ class TestGetRecords:
 | 
				
			|||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
				
			||||||
        assert (
 | 
					        assert (
 | 
				
			||||||
            activity_cycling_user_1.uuid.hex
 | 
					            activity_cycling_user_1.short_id
 | 
				
			||||||
            == data['data']['records'][0]['activity_id']
 | 
					            == data['data']['records'][0]['activity_id']
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        assert 'AS' == data['data']['records'][0]['record_type']
 | 
					        assert 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
@@ -51,7 +51,7 @@ class TestGetRecords:
 | 
				
			|||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
				
			||||||
        assert (
 | 
					        assert (
 | 
				
			||||||
            activity_cycling_user_1.uuid.hex
 | 
					            activity_cycling_user_1.short_id
 | 
				
			||||||
            == data['data']['records'][1]['activity_id']
 | 
					            == data['data']['records'][1]['activity_id']
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        assert 'FD' == data['data']['records'][1]['record_type']
 | 
					        assert 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
@@ -64,7 +64,7 @@ class TestGetRecords:
 | 
				
			|||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
				
			||||||
        assert (
 | 
					        assert (
 | 
				
			||||||
            activity_cycling_user_1.uuid.hex
 | 
					            activity_cycling_user_1.short_id
 | 
				
			||||||
            == data['data']['records'][2]['activity_id']
 | 
					            == data['data']['records'][2]['activity_id']
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        assert 'LD' == data['data']['records'][2]['record_type']
 | 
					        assert 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
@@ -77,7 +77,7 @@ class TestGetRecords:
 | 
				
			|||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
				
			||||||
        assert (
 | 
					        assert (
 | 
				
			||||||
            activity_cycling_user_1.uuid.hex
 | 
					            activity_cycling_user_1.short_id
 | 
				
			||||||
            == data['data']['records'][3]['activity_id']
 | 
					            == data['data']['records'][3]['activity_id']
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        assert 'MS' == data['data']['records'][3]['record_type']
 | 
					        assert 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
@@ -177,7 +177,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            '/api/records',
 | 
					            '/api/records',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -197,7 +197,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][0]['value']
 | 
					        assert 7.0 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -207,7 +207,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -217,7 +217,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:00:00' == data['data']['records'][2]['value']
 | 
					        assert '1:00:00' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -227,7 +227,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][3]['value']
 | 
					        assert 7.0 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -251,7 +251,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            '/api/records',
 | 
					            '/api/records',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -271,7 +271,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 8.4 == data['data']['records'][0]['value']
 | 
					        assert 8.4 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -281,7 +281,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -291,7 +291,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:00:00' == data['data']['records'][2]['value']
 | 
					        assert '1:00:00' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -301,7 +301,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 8.4 == data['data']['records'][3]['value']
 | 
					        assert 8.4 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -324,7 +324,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            '/api/records',
 | 
					            '/api/records',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -344,7 +344,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 8.4 == data['data']['records'][0]['value']
 | 
					        assert 8.4 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -354,7 +354,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -364,7 +364,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:00:00' == data['data']['records'][2]['value']
 | 
					        assert '1:00:00' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -374,14 +374,14 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 8.4 == data['data']['records'][3]['value']
 | 
					        assert 8.4 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Edit last activity
 | 
					        # Edit last activity
 | 
				
			||||||
        # 1 new record: Longest duration
 | 
					        # 1 new record: Longest duration
 | 
				
			||||||
        client.patch(
 | 
					        client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_3_uuid}',
 | 
					            f'/api/activities/{activity_3_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(duration=4000)),
 | 
					            data=json.dumps(dict(duration=4000)),
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -408,7 +408,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 8.4 == data['data']['records'][0]['value']
 | 
					        assert 8.4 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -418,7 +418,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -428,7 +428,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:06:40' == data['data']['records'][2]['value']
 | 
					        assert '1:06:40' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -438,13 +438,13 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 8.4 == data['data']['records'][3]['value']
 | 
					        assert 8.4 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # delete activity 2 => AS and MS record update
 | 
					        # delete activity 2 => AS and MS record update
 | 
				
			||||||
        client.delete(
 | 
					        client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_2_uuid}',
 | 
					            f'/api/activities/{activity_2_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -469,7 +469,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][0]['value']
 | 
					        assert 7.0 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -479,7 +479,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -489,7 +489,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:06:40' == data['data']['records'][2]['value']
 | 
					        assert '1:06:40' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -499,7 +499,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][3]['value']
 | 
					        assert 7.0 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -523,7 +523,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            '/api/records',
 | 
					            '/api/records',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -543,7 +543,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][0]['value']
 | 
					        assert 7.0 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -553,7 +553,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -563,7 +563,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:06:40' == data['data']['records'][2]['value']
 | 
					        assert '1:06:40' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -573,7 +573,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][3]['value']
 | 
					        assert 7.0 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -599,7 +599,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            '/api/records',
 | 
					            '/api/records',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -619,7 +619,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][0]['value']
 | 
					        assert 7.0 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -629,7 +629,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -639,7 +639,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:06:40' == data['data']['records'][2]['value']
 | 
					        assert '1:06:40' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -649,34 +649,34 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][3]['value']
 | 
					        assert 7.0 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # delete all activities - no more records
 | 
					        # delete all activities - no more records
 | 
				
			||||||
        client.delete(
 | 
					        client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_1_uuid}',
 | 
					            f'/api/activities/{activity_1_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        client.delete(
 | 
					        client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_3_uuid}',
 | 
					            f'/api/activities/{activity_3_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        client.delete(
 | 
					        client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_4_uuid}',
 | 
					            f'/api/activities/{activity_4_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        client.delete(
 | 
					        client.delete(
 | 
				
			||||||
            f'/api/activities/{activity_5_uuid}',
 | 
					            f'/api/activities/{activity_5_short_id}',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
                Authorization='Bearer '
 | 
					                Authorization='Bearer '
 | 
				
			||||||
                + json.loads(resp_login.data.decode())['auth_token']
 | 
					                + json.loads(resp_login.data.decode())['auth_token']
 | 
				
			||||||
@@ -722,7 +722,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.post(
 | 
				
			||||||
            '/api/activities/no_gpx',
 | 
					            '/api/activities/no_gpx',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
@@ -741,7 +741,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        client.post(
 | 
				
			||||||
            '/api/activities/no_gpx',
 | 
					            '/api/activities/no_gpx',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
@@ -777,7 +777,7 @@ class TestGetRecords:
 | 
				
			|||||||
            ),
 | 
					            ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        data = json.loads(response.data.decode())
 | 
					        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(
 | 
					        response = client.get(
 | 
				
			||||||
            '/api/records',
 | 
					            '/api/records',
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -797,7 +797,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][0]['value']
 | 
					        assert 7.0 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -807,7 +807,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][1]['value']
 | 
					        assert 7.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -817,7 +817,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:00:00' == data['data']['records'][2]['value']
 | 
					        assert '1:00:00' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -827,7 +827,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 7.0 == data['data']['records'][3]['value']
 | 
					        assert 7.0 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -837,7 +837,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][4]['user']
 | 
					        assert 'test' == data['data']['records'][4]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][4]['sport_id']
 | 
					        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 'AS' == data['data']['records'][4]['record_type']
 | 
				
			||||||
        assert 20.0 == data['data']['records'][4]['value']
 | 
					        assert 20.0 == data['data']['records'][4]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -847,7 +847,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][5]['user']
 | 
					        assert 'test' == data['data']['records'][5]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][5]['sport_id']
 | 
					        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 'FD' == data['data']['records'][5]['record_type']
 | 
				
			||||||
        assert 20.0 == data['data']['records'][5]['value']
 | 
					        assert 20.0 == data['data']['records'][5]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -857,7 +857,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][6]['user']
 | 
					        assert 'test' == data['data']['records'][6]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][6]['sport_id']
 | 
					        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 'LD' == data['data']['records'][6]['record_type']
 | 
				
			||||||
        assert '1:00:00' == data['data']['records'][6]['value']
 | 
					        assert '1:00:00' == data['data']['records'][6]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -867,12 +867,12 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][7]['user']
 | 
					        assert 'test' == data['data']['records'][7]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][7]['sport_id']
 | 
					        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 'MS' == data['data']['records'][7]['record_type']
 | 
				
			||||||
        assert 20.0 == data['data']['records'][7]['value']
 | 
					        assert 20.0 == data['data']['records'][7]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        client.patch(
 | 
					        client.patch(
 | 
				
			||||||
            f'/api/activities/{activity_2_uuid}',
 | 
					            f'/api/activities/{activity_2_short_id}',
 | 
				
			||||||
            content_type='application/json',
 | 
					            content_type='application/json',
 | 
				
			||||||
            data=json.dumps(dict(sport_id=1)),
 | 
					            data=json.dumps(dict(sport_id=1)),
 | 
				
			||||||
            headers=dict(
 | 
					            headers=dict(
 | 
				
			||||||
@@ -899,7 +899,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][0]['user']
 | 
					        assert 'test' == data['data']['records'][0]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][0]['sport_id']
 | 
					        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 'AS' == data['data']['records'][0]['record_type']
 | 
				
			||||||
        assert 20.0 == data['data']['records'][0]['value']
 | 
					        assert 20.0 == data['data']['records'][0]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -909,7 +909,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][1]['user']
 | 
					        assert 'test' == data['data']['records'][1]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][1]['sport_id']
 | 
					        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 'FD' == data['data']['records'][1]['record_type']
 | 
				
			||||||
        assert 20.0 == data['data']['records'][1]['value']
 | 
					        assert 20.0 == data['data']['records'][1]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -919,7 +919,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][2]['user']
 | 
					        assert 'test' == data['data']['records'][2]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][2]['sport_id']
 | 
					        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 'LD' == data['data']['records'][2]['record_type']
 | 
				
			||||||
        assert '1:00:00' == data['data']['records'][2]['value']
 | 
					        assert '1:00:00' == data['data']['records'][2]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -929,7 +929,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][3]['user']
 | 
					        assert 'test' == data['data']['records'][3]['user']
 | 
				
			||||||
        assert sport_1_cycling.id == data['data']['records'][3]['sport_id']
 | 
					        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 'MS' == data['data']['records'][3]['record_type']
 | 
				
			||||||
        assert 20.0 == data['data']['records'][3]['value']
 | 
					        assert 20.0 == data['data']['records'][3]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -939,7 +939,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][4]['user']
 | 
					        assert 'test' == data['data']['records'][4]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][4]['sport_id']
 | 
					        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 'AS' == data['data']['records'][4]['record_type']
 | 
				
			||||||
        assert 12.0 == data['data']['records'][4]['value']
 | 
					        assert 12.0 == data['data']['records'][4]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -949,7 +949,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][5]['user']
 | 
					        assert 'test' == data['data']['records'][5]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][5]['sport_id']
 | 
					        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 'FD' == data['data']['records'][5]['record_type']
 | 
				
			||||||
        assert 10.0 == data['data']['records'][5]['value']
 | 
					        assert 10.0 == data['data']['records'][5]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -959,7 +959,7 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][6]['user']
 | 
					        assert 'test' == data['data']['records'][6]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][6]['sport_id']
 | 
					        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 'LD' == data['data']['records'][6]['record_type']
 | 
				
			||||||
        assert '0:50:00' == data['data']['records'][6]['value']
 | 
					        assert '0:50:00' == data['data']['records'][6]['value']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -969,6 +969,6 @@ class TestGetRecords:
 | 
				
			|||||||
        )  # noqa
 | 
					        )  # noqa
 | 
				
			||||||
        assert 'test' == data['data']['records'][7]['user']
 | 
					        assert 'test' == data['data']['records'][7]['user']
 | 
				
			||||||
        assert sport_2_running.id == data['data']['records'][7]['sport_id']
 | 
					        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 'MS' == data['data']['records'][7]['record_type']
 | 
				
			||||||
        assert 12.0 == data['data']['records'][7]['value']
 | 
					        assert 12.0 == data['data']['records'][7]['value']
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,12 @@
 | 
				
			|||||||
import json
 | 
					import json
 | 
				
			||||||
from io import BytesIO
 | 
					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):
 | 
					def get_random_short_id():
 | 
				
			||||||
    try:
 | 
					    return encode_uuid(uuid4())
 | 
				
			||||||
        UUID(string, version=4)
 | 
					 | 
				
			||||||
    except ValueError:
 | 
					 | 
				
			||||||
        return False
 | 
					 | 
				
			||||||
    return True
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def post_an_activity(app, gpx_file):
 | 
					def post_an_activity(app, gpx_file):
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								poetry.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										14
									
								
								poetry.lock
									
									
									
										generated
									
									
									
								
							@@ -889,6 +889,14 @@ python-versions = "*"
 | 
				
			|||||||
[package.dependencies]
 | 
					[package.dependencies]
 | 
				
			||||||
urllib3 = "*"
 | 
					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]]
 | 
					[[package]]
 | 
				
			||||||
name = "six"
 | 
					name = "six"
 | 
				
			||||||
version = "1.15.0"
 | 
					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]
 | 
					[metadata]
 | 
				
			||||||
lock-version = "1.0"
 | 
					lock-version = "1.0"
 | 
				
			||||||
python-versions = "^3.7"
 | 
					python-versions = "^3.7"
 | 
				
			||||||
content-hash = "94d589f7d4810e10acf98513037953027e13374bf13a62207570d9caca3f9ab0"
 | 
					content-hash = "b5c7cbb6e449c8c6cc94a7413ae2fc0b8889d738e3fc802566efc45cc5096287"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[metadata.files]
 | 
					[metadata.files]
 | 
				
			||||||
alabaster = [
 | 
					alabaster = [
 | 
				
			||||||
@@ -1674,6 +1682,10 @@ selenium = [
 | 
				
			|||||||
    {file = "selenium-3.141.0-py2.py3-none-any.whl", hash = "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c"},
 | 
					    {file = "selenium-3.141.0-py2.py3-none-any.whl", hash = "sha256:2d7131d7bc5a5b99a2d9b04aaf2612c411b03b8ca1b1ee8d3de5845a9be2cb3c"},
 | 
				
			||||||
    {file = "selenium-3.141.0.tar.gz", hash = "sha256:deaf32b60ad91a4611b98d8002757f29e6f2c2d5fcaf202e1c9ad06d6772300d"},
 | 
					    {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 = [
 | 
					six = [
 | 
				
			||||||
    {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
 | 
					    {file = "six-1.15.0-py2.py3-none-any.whl", hash = "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"},
 | 
				
			||||||
    {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
 | 
					    {file = "six-1.15.0.tar.gz", hash = "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259"},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,6 +35,7 @@ psycopg2-binary = "^2.8"
 | 
				
			|||||||
pyjwt = "^2.0"
 | 
					pyjwt = "^2.0"
 | 
				
			||||||
python-forecastio = "^1.4"
 | 
					python-forecastio = "^1.4"
 | 
				
			||||||
pytz = "^2020.5"
 | 
					pytz = "^2020.5"
 | 
				
			||||||
 | 
					shortuuid = "^1.0.1"
 | 
				
			||||||
staticmap = "^0.5.4"
 | 
					staticmap = "^0.5.4"
 | 
				
			||||||
tqdm = "^4.55"
 | 
					tqdm = "^4.55"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user