diff --git a/mpwo_api/mpwo_api/activities/activities.py b/mpwo_api/mpwo_api/activities/activities.py index d91fc7d3..ff31b7c5 100644 --- a/mpwo_api/mpwo_api/activities/activities.py +++ b/mpwo_api/mpwo_api/activities/activities.py @@ -77,9 +77,7 @@ def get_activity_gpx(auth_user_id, activity_id): if not activity.gpx or activity.gpx == '': response_object = { 'status': 'fail', - 'message': 'No gpx file for this activity (id: {})'.format( - activity_id - ) + 'message': f'No gpx file for this activity (id: {activity_id})' } return jsonify(response_object), 400 @@ -103,7 +101,7 @@ def get_activity_gpx(auth_user_id, activity_id): else: gpx_content = '' status = 'not found' - message = 'Activity not found (id: {})'.format(activity_id) + message = f'Activity not found (id: {activity_id})' code = 404 response_object = { diff --git a/mpwo_api/mpwo_api/activities/models.py b/mpwo_api/mpwo_api/activities/models.py index 49257e11..a037981b 100644 --- a/mpwo_api/mpwo_api/activities/models.py +++ b/mpwo_api/mpwo_api/activities/models.py @@ -86,7 +86,7 @@ class Sport(db.Model): backref=db.backref('sports', lazy='joined')) def __repr__(self): - return ''.format(self.label) + return f'' def __init__(self, label): self.label = label @@ -149,8 +149,7 @@ class Activity(db.Model): single_parent=True)) def __str__(self): - return ''.format( - self.sports.label, self.activity_date, ) + return f'' def __init__(self, user_id, sport_id, activity_date, distance, duration): self.user_id = user_id @@ -270,8 +269,8 @@ class ActivitySegment(db.Model): ave_speed = db.Column(db.Numeric(6, 2), nullable=True) # km/h def __str__(self): - return ''.format( - self.segment_id, self.activity_id, ) + return (f'') def __init__(self, segment_id, activity_id): self.segment_id = segment_id @@ -319,11 +318,9 @@ class Record(db.Model): _value = db.Column("value", db.Integer, nullable=True) def __str__(self): - return ''.format( - self.sports.label, - self.record_type, - self.activity_date.strftime('%Y-%m-%d') - ) + return (f'") def __init__(self, activity, record_type): self.user_id = activity.user_id diff --git a/mpwo_api/mpwo_api/activities/utils.py b/mpwo_api/mpwo_api/activities/utils.py index e79363c5..84b91799 100644 --- a/mpwo_api/mpwo_api/activities/utils.py +++ b/mpwo_api/mpwo_api/activities/utils.py @@ -47,8 +47,7 @@ def create_activity( new_activity.title = title else: sport = Sport.query.filter_by(id=new_activity.sport_id).first() - new_activity.title = '{} - {}'.format(sport.label, - new_activity.activity_date) + new_activity.title = f'{sport.label} - {new_activity.activity_date}' if gpx_data: new_activity.gpx = gpx_data['filename'] @@ -189,9 +188,9 @@ def get_file_path(auth_user_id, activity_file): def get_new_file_path(auth_user_id, activity_date, activity_file, sport): old_filename = secure_filename(activity_file.filename) - extension = '.{}'.format(old_filename.rsplit('.', 1)[1].lower()) + extension = f".{old_filename.rsplit('.', 1)[1].lower()}" _, new_filename = tempfile.mkstemp( - prefix='{}_{}_'.format(activity_date, sport), + prefix=f'{activity_date}_sport_', suffix=extension ) dir_path = os.path.join( diff --git a/mpwo_api/mpwo_api/users/models.py b/mpwo_api/mpwo_api/users/models.py index 31beecd6..aca9899c 100644 --- a/mpwo_api/mpwo_api/users/models.py +++ b/mpwo_api/mpwo_api/users/models.py @@ -27,7 +27,7 @@ class User(db.Model): backref=db.backref('users', lazy='joined')) def __repr__(self): - return '' % self.username + return f'' def __init__( self, username, email, password,