diff --git a/fittrackee_api/fittrackee_api/tests/test_auth_api.py b/fittrackee_api/fittrackee_api/tests/test_auth_api.py index cbd9e0b5..95d51863 100644 --- a/fittrackee_api/fittrackee_api/tests/test_auth_api.py +++ b/fittrackee_api/fittrackee_api/tests/test_auth_api.py @@ -62,9 +62,7 @@ def test_user_registration_invalid_short_username(app): ) data = json.loads(response.data.decode()) assert data['status'] == 'error' - assert ( - data['message'] == "Username: 3 to 12 characters required.\n" - ) + assert data['message'] == "Username: 3 to 12 characters required.\n" assert response.content_type == 'application/json' assert response.status_code == 400 @@ -85,9 +83,7 @@ def test_user_registration_invalid_long_username(app): ) data = json.loads(response.data.decode()) assert data['status'] == 'error' - assert ( - data['message'] == "Username: 3 to 12 characters required.\n" - ) + assert data['message'] == "Username: 3 to 12 characters required.\n" assert response.content_type == 'application/json' assert response.status_code == 400 @@ -129,9 +125,7 @@ def test_user_registration_invalid_short_password(app): ) data = json.loads(response.data.decode()) assert data['status'] == 'error' - assert ( - data['message'] == "Password: 8 characters required.\n" - ) + assert data['message'] == "Password: 8 characters required.\n" assert response.content_type == 'application/json' assert response.status_code == 400 @@ -153,8 +147,7 @@ def test_user_registration_mismatched_password(app): data = json.loads(response.data.decode()) assert data['status'] == 'error' assert ( - data['message'] - == "Password and password confirmation don\'t match.\n" + data['message'] == "Password and password confirmation don\'t match.\n" ) assert response.content_type == 'application/json' assert response.status_code == 400 diff --git a/fittrackee_client/src/actions/activities.js b/fittrackee_client/src/actions/activities.js index 8228c26f..997f1084 100644 --- a/fittrackee_client/src/actions/activities.js +++ b/fittrackee_client/src/actions/activities.js @@ -34,7 +34,7 @@ export const addActivity = form => dispatch => .then(ret => { if (ret.status === 'created') { if (ret.data.activities.length === 0) { - dispatch(setError('activities: no correct file')) + dispatch(setError('activities|no correct file.')) } else if (ret.data.activities.length === 1) { dispatch(loadProfile()) history.push(`/activities/${ret.data.activities[0].id}`) @@ -44,11 +44,11 @@ export const addActivity = form => dispatch => history.push('/') } } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } dispatch(setLoading(false)) }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) export const addActivityWithoutGpx = form => dispatch => FitTrackeeGenericApi.addData('activities/no_gpx', form) @@ -57,10 +57,10 @@ export const addActivityWithoutGpx = form => dispatch => dispatch(loadProfile()) history.push(`/activities/${ret.data.activities[0].id}`) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) export const getActivityGpx = activityId => dispatch => { if (activityId) { @@ -69,10 +69,10 @@ export const getActivityGpx = activityId => dispatch => { if (ret.status === 'success') { dispatch(setGpx(ret.data.gpx)) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) } dispatch(setGpx(null)) } @@ -86,10 +86,10 @@ export const getSegmentGpx = (activityId, segmentId) => dispatch => { if (ret.status === 'success') { dispatch(setGpx(ret.data.gpx)) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) } dispatch(setGpx(null)) } @@ -101,10 +101,10 @@ export const getActivityChartData = activityId => dispatch => { if (ret.status === 'success') { dispatch(setChartData(formatChartData(ret.data.chart_data))) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) } dispatch(setChartData(null)) } @@ -118,10 +118,10 @@ export const getSegmentChartData = (activityId, segmentId) => dispatch => { if (ret.status === 'success') { dispatch(setChartData(formatChartData(ret.data.chart_data))) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) } dispatch(setChartData(null)) } @@ -134,10 +134,10 @@ export const deleteActivity = id => dispatch => .then(() => dispatch(loadProfile())) .then(() => history.push('/')) } else { - dispatch(setError(`activities: ${ret.status}`)) + dispatch(setError(`activities|${ret.status}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) export const editActivity = form => dispatch => FitTrackeeGenericApi.updateData('activities', form) @@ -146,11 +146,11 @@ export const editActivity = form => dispatch => dispatch(loadProfile()) history.push(`/activities/${ret.data.activities[0].id}`) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } dispatch(setLoading(false)) }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) export const getMoreActivities = params => dispatch => FitTrackeeGenericApi.getData('activities', params) @@ -160,10 +160,10 @@ export const getMoreActivities = params => dispatch => dispatch(pushActivities(ret.data.activities)) } } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) export const getMonthActivities = (from, to) => dispatch => FitTrackeeGenericApi.getData('activities', { @@ -176,7 +176,7 @@ export const getMonthActivities = (from, to) => dispatch => if (ret.status === 'success') { dispatch(updateCalendar(ret.data.activities)) } else { - dispatch(setError(`activities: ${ret.message}`)) + dispatch(setError(`activities|${ret.message}`)) } }) - .catch(error => dispatch(setError(`activities: ${error}`))) + .catch(error => dispatch(setError(`activities|${error}`))) diff --git a/fittrackee_client/src/actions/index.js b/fittrackee_client/src/actions/index.js index 632257b3..0fd33458 100644 --- a/fittrackee_client/src/actions/index.js +++ b/fittrackee_client/src/actions/index.js @@ -26,17 +26,17 @@ export const setLoading = loading => ({ export const getOrUpdateData = (action, target, data) => dispatch => { if (data && data.id && isNaN(data.id)) { - return dispatch(setError(target, `${target}: Incorrect id`)) + return dispatch(setError(`${target}|Incorrect id`)) } return FitTrackeeApi[action](target, data) .then(ret => { if (ret.status === 'success') { dispatch(setData(target, ret.data)) } else { - dispatch(setError(`${target}: ${ret.message || ret.status}`)) + dispatch(setError(`${target}|${ret.message || ret.status}`)) } }) - .catch(error => dispatch(setError(`${target}: ${error}`))) + .catch(error => dispatch(setError(`${target}|${error}`))) } export const addData = (target, data) => dispatch => @@ -45,24 +45,24 @@ export const addData = (target, data) => dispatch => if (ret.status === 'created') { history.push(`/admin/${target}`) } else { - dispatch(setError(`${target}: ${ret.status}`)) + dispatch(setError(`${target}|${ret.status}`)) } }) - .catch(error => dispatch(setError(`${target}: ${error}`))) + .catch(error => dispatch(setError(`${target}|${error}`))) export const deleteData = (target, id) => dispatch => { if (isNaN(id)) { - return dispatch(setError(target, `${target}: Incorrect id`)) + return dispatch(setError(target, `${target}|Incorrect id`)) } return FitTrackeeApi.deleteData(target, id) .then(ret => { if (ret.status === 204) { history.push(`/admin/${target}`) } else { - dispatch(setError(`${target}: ${ret.message || ret.status}`)) + dispatch(setError(`${target}|${ret.message || ret.status}`)) } }) - .catch(error => dispatch(setError(`${target}: ${error}`))) + .catch(error => dispatch(setError(`${target}|${error}`))) } export const updateLanguage = language => dispatch => { diff --git a/fittrackee_client/src/actions/stats.js b/fittrackee_client/src/actions/stats.js index de23f754..834e65d4 100644 --- a/fittrackee_client/src/actions/stats.js +++ b/fittrackee_client/src/actions/stats.js @@ -7,7 +7,7 @@ export const getStats = (userId, type, data) => dispatch => if (ret.status === 'success') { dispatch(setData('statistics', ret.data)) } else { - dispatch(setError(`statistics: ${ret.message}`)) + dispatch(setError(`statistics|${ret.message}`)) } }) - .catch(error => dispatch(setError(`statistics: ${error}`))) + .catch(error => dispatch(setError(`statistics|${error}`))) diff --git a/fittrackee_client/src/components/Activities/index.jsx b/fittrackee_client/src/components/Activities/index.jsx index 7e2626bd..1eba78a0 100644 --- a/fittrackee_client/src/components/Activities/index.jsx +++ b/fittrackee_client/src/components/Activities/index.jsx @@ -5,6 +5,7 @@ import { connect } from 'react-redux' import ActivitiesFilter from './ActivitiesFilter' import ActivitiesList from './ActivitiesList' +import Message from '../Common/Message' import NoActivities from '../Common/NoActivities' import { getOrUpdateData } from '../../actions' import { getMoreActivities } from '../../actions/activities' @@ -55,7 +56,7 @@ class Activities extends React.Component {
{t(`messages:${message}`)}
+ {t(`messages:${message}`)}
}
+ {t(`messages:${message}`)}
+ {singleMessage}
}
+ {messages && messages.length > 0 && (
+
+
+ {messages.map(msg => (
+ - {t(`messages:${msg.value}`)}
+ ))}
+
+
+ )}
+ >
+ )
+ }
+}
diff --git a/fittrackee_client/src/components/Dashboard/index.jsx b/fittrackee_client/src/components/Dashboard/index.jsx
index fab1c824..4ff840c3 100644
--- a/fittrackee_client/src/components/Dashboard/index.jsx
+++ b/fittrackee_client/src/components/Dashboard/index.jsx
@@ -5,6 +5,7 @@ import { connect } from 'react-redux'
import ActivityCard from './ActivityCard'
import Calendar from './Calendar'
+import Message from '../Common/Message'
import NoActivities from '../Common/NoActivities'
import Records from './Records'
import Statistics from './Statistics'
@@ -45,7 +46,7 @@ class DashBoard extends React.Component {
{t(`messages:${message}`)}
+ {t(`messages:${message}`)}
}
+ {t(`messages:${message}`)}
}
+ {t(`messages:${message}`)}
}
- {messages.length > 0 && (
-
-
- {messages.map(msg => (
- - {t(`messages:${msg.value}`)}
- ))}
-
-
- )}
+