Changeset 42baca4 in OpenWorkouts-current for ow/models/root.py


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/models/root.py

    re52a502 r42baca4  
    4343            'nickname': CatalogFieldIndex('nickname'),
    4444            'sport': CatalogFieldIndex('sport'),
     45            'hashed': CatalogFieldIndex('hashed'),
    4546        }
    4647        return indexes
     
    140141    def sports_json(self):
    141142        return json.dumps(self.sports)
     143
     144    def get_workout_by_hash(self, hashed):
     145        if hashed is not None:
     146            # for some reason, when searching for None
     147            # the catalog will return all workouts
     148            res = self.query(Eq('hashed', hashed))
     149            if res:
     150                return next(res)
     151        return None
Note: See TracChangeset for help on using the changeset viewer.