Changeset 42baca4 in OpenWorkouts-current for ow/templates/add_workout.pt


Ignore:
Timestamp:
Apr 22, 2019, 6:14:53 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current
Children:
0dedfbe
Parents:
e52a502
Message:

(#39) Do not allow duplicated workouts by default when uploading track files.
We still allow users to add duplicates if they want, by checking a checkbox
we show in the upload workout form when we find a possible duplicate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/templates/add_workout.pt

    re52a502 r42baca4  
    2525        ${form.csrf_token()}
    2626
    27         <fieldset>
    28           <p>
    29               <label for="title" i18n:translate="">Title</label>
    30               ${form.errorlist('title')}
    31               ${form.text('title')}
    32           </p>
    33           <p>
    34               <label for="notes" i18n:translate="">Notes</label>
    35               ${form.errorlist('notes')}
    36               ${form.textarea('notes', rows=10, cols=50)}
    37           </p>
    38           <p>
    39             <label for="tracking_file" i18n:translate="">
    40               Workout file (gpx, fit)</label>
    41             ${form.errorlist('tracking_file')}
    42             ${form.file('tracking_file')}
    43           </p>
    44         </fieldset>
     27      <tal:is_duplicate tal:condition="duplicate is not None">
     28        <article class="workout-resume">
    4529
    46         <tal:with-localizer tal:define="localizer get_localizer(request)">
    47           ${form.submit("submit", localizer.translate(_('Save')),  **{'class':"button button-normal"})}
    48         </tal:with-localizer>
     30          <h2 class="workout-title">
     31            <tal:warning i18n:translate="">THIS MAY BE A DUPLICATE OF:</tal:warning>
     32            <a href="" tal:content="duplicate.title"
     33               tal:attributes="href request.resource_url(duplicate)"></a>
     34          </h2>
     35
     36          <ul class="workout-info">
     37            <li>
     38              <tal:c tal:content="duplicate.sport"></tal:c>
     39            </li>
     40            <li>
     41              <tal:c tal:content="duplicate.start_in_timezone(context.timezone)"></tal:c>
     42            </li>
     43            <li>
     44              <!--! use the properly formatted duration instead of the timedelta object -->
     45              <tal:c tal:content="duplicate._duration"></tal:c>
     46            </li>
     47            <li tal:condition="duplicate.distance">
     48              <tal:c tal:content="duplicate.rounded_distance"></tal:c> km
     49            </li>
     50            <li tal:condition="duplicate.uphill">
     51              +<tal:c tal:content="duplicate.uphill"></tal:c> m
     52            </li>
     53          </ul>
     54
     55          <div class="workout-map" tal:condition="duplicate.has_gpx">
     56            <a href="" tal:attributes="href request.resource_url(duplicate)">
     57              <tal:has-screenshot tal:condition="duplicate.map_screenshot is not None">
     58                <img src="" tal:attributes="src request.static_url(duplicate.map_screenshot);
     59                          alt duplicate.title; title duplicate.title">
     60              </tal:has-screenshot>
     61              <tal:has-not-screenshot tal:condition="duplicate.map_screenshot is None">
     62                <img src="" tal:attributes="src request.static_url('ow:static/media/img/no_map.gif');
     63                          alt duplicate.title; title duplicate.title; class 'js-needs-map'">
     64              </tal:has-not-screenshot>
     65            </a>
     66          </div>
     67
     68        </article>
     69
     70        <div>
     71      </tal:is_duplicate>
     72
     73      <fieldset>
     74
     75        <p>
     76          <label for="title" i18n:translate="">Title</label>
     77          ${form.errorlist('title')}
     78          ${form.text('title')}
     79        </p>
     80
     81        <p>
     82          <label for="notes" i18n:translate="">Notes</label>
     83          ${form.errorlist('notes')}
     84          ${form.textarea('notes', rows=10, cols=50)}
     85        </p>
     86
     87        <p>
     88          <label for="tracking_file" i18n:translate="">
     89            Workout file (gpx, fit)</label>
     90          ${form.errorlist('tracking_file')}
     91          ${form.file('tracking_file')}
     92        </p>
     93
     94        <p tal:condition="duplicate is not None">
     95          <label for="allow_duplicates" i18n:translate="">Allow duplicated workouts</label>
     96          <small i18n:translate="">
     97            Mark this checkbox if you want to add to override the mechanism not allowing duplicated workouts
     98          </small>
     99          <input type="checkbox" name="allow_duplicates">
     100        </p>
     101
     102      </fieldset>
     103
     104      <tal:with-localizer tal:define="localizer get_localizer(request)">
     105        ${form.submit("submit", localizer.translate(_('Save')),  **{'class':"button button-normal"})}
     106      </tal:with-localizer>
    49107
    50108      ${form.end()}
Note: See TracChangeset for help on using the changeset viewer.