API & Client: fix
- user edition - title for activity with gpx and no name in gpx - style
This commit is contained in:
parent
019ed42bae
commit
3acdabb4da
@ -25,14 +25,21 @@ class ActivityException(Exception):
|
||||
|
||||
|
||||
def get_datetime_with_tz(timezone, activity_date, gpx_data=None):
|
||||
# activity date in gpx are directly in UTC
|
||||
activity_date_tz = None
|
||||
if timezone and not gpx_data:
|
||||
if timezone:
|
||||
user_tz = pytz.timezone(timezone)
|
||||
utc_tz = pytz.utc
|
||||
if gpx_data:
|
||||
# activity date in gpx is in UTC, but in naive datetime
|
||||
fmt = '%Y-%m-%d %H:%M:%S'
|
||||
activity_date_string = activity_date.strftime(fmt)
|
||||
activity_date_tmp = utc_tz.localize(
|
||||
datetime.strptime(activity_date_string, fmt))
|
||||
activity_date_tz = activity_date_tmp.astimezone(user_tz)
|
||||
else:
|
||||
activity_date_tz = user_tz.localize(activity_date)
|
||||
if not gpx_data:
|
||||
activity_date = activity_date_tz.astimezone(utc_tz)
|
||||
# make datetime 'naive' like in gpx file
|
||||
activity_date = activity_date_tz.astimezone(pytz.utc)
|
||||
activity_date = activity_date.replace(tzinfo=None)
|
||||
|
||||
return activity_date_tz, activity_date
|
||||
|
@ -311,6 +311,41 @@ def test_add_an_activity_with_gpx_without_name(
|
||||
assert_activity_data_with_gpx(data)
|
||||
|
||||
|
||||
def test_add_an_activity_with_gpx_without_name_timezone(
|
||||
app, user_1, sport_1_cycling, gpx_file_wo_name
|
||||
):
|
||||
user_1.timezone = 'Europe/Paris'
|
||||
client = app.test_client()
|
||||
resp_login = client.post(
|
||||
'/api/auth/login',
|
||||
data=json.dumps(dict(
|
||||
email='test@test.com',
|
||||
password='12345678'
|
||||
)),
|
||||
content_type='application/json'
|
||||
)
|
||||
response = client.post(
|
||||
'/api/activities',
|
||||
data=dict(
|
||||
file=(BytesIO(str.encode(gpx_file_wo_name)), 'example.gpx'),
|
||||
data='{"sport_id": 1}'
|
||||
),
|
||||
headers=dict(
|
||||
content_type='multipart/form-data',
|
||||
Authorization='Bearer ' + json.loads(
|
||||
resp_login.data.decode()
|
||||
)['auth_token']
|
||||
)
|
||||
)
|
||||
data = json.loads(response.data.decode())
|
||||
|
||||
assert response.status_code == 201
|
||||
assert 'created' in data['status']
|
||||
assert len(data['data']['activities']) == 1
|
||||
assert 'Cycling - 2018-03-13 13:44:45' == data['data']['activities'][0]['title'] # noqa
|
||||
assert_activity_data_with_gpx(data)
|
||||
|
||||
|
||||
def test_get_an_activity_with_gpx_notes(
|
||||
app, user_1, sport_1_cycling, gpx_file
|
||||
):
|
||||
|
@ -85,6 +85,7 @@ export const handleProfileFormSubmit = formData => dispatch => {
|
||||
'Password and password confirmation don\'t match.'
|
||||
))
|
||||
}
|
||||
delete formData.id
|
||||
return FitTrackeeGenericApi
|
||||
.postData('auth/profile/edit', formData)
|
||||
.then(ret => {
|
||||
|
@ -46,7 +46,7 @@ a {
|
||||
color: #40578a;
|
||||
}
|
||||
|
||||
input, textarea {
|
||||
input[type="text"], textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ export default function RecordsCard (props) {
|
||||
? 'No records'
|
||||
: (Object.keys(recordsBySport).map(sportLabel => (
|
||||
<table
|
||||
className="table table-borderless record-table"
|
||||
className="table table-borderless table-sm record-table"
|
||||
key={sportLabel}
|
||||
>
|
||||
<thead>
|
||||
|
@ -40,7 +40,7 @@ export default class FitTrackeeApi {
|
||||
|
||||
static postData(target, data) {
|
||||
const params = {
|
||||
url: `${apiUrl}${target}/${data.id}`,
|
||||
url: `${apiUrl}${target}${data.id ? `/${data.id}` : '' }`,
|
||||
method: 'POST',
|
||||
body: data,
|
||||
type: 'application/json',
|
||||
|
Loading…
Reference in New Issue
Block a user