diff --git a/Makefile b/Makefile index 0ee54936..37e0806f 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,9 @@ docker-build-client: docker-check-all: docker-bandit docker-lint-all docker-type-check docker-test-client docker-test-python +docker-downgrade-db: + docker-compose -f docker-compose-dev.yml exec fittrackee $(DOCKER_FLASK) db downgrade --directory $(DOCKER_MIGRATIONS) + docker-init: docker-run docker-init-db docker-restart docker-run-workers docker-init-db: diff --git a/fittrackee/migrations/versions/31_db58d195c5bf_add_start_elevation_at_zero.py b/fittrackee/migrations/versions/31_db58d195c5bf_add_start_elevation_at_zero.py new file mode 100644 index 00000000..1743228d --- /dev/null +++ b/fittrackee/migrations/versions/31_db58d195c5bf_add_start_elevation_at_zero.py @@ -0,0 +1,35 @@ +"""add user preference to start elevation plots at zero + +Revision ID: db58d195c5bf +Revises: 374a670efe23 +Create Date: 2023-03-14 04:14:23.781672 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = 'db58d195c5bf' +down_revision = '374a670efe23' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('users', schema=None) as batch_op: + batch_op.add_column(sa.Column('start_elevation_at_zero', sa.Boolean(), nullable=True)) + op.execute("UPDATE users SET start_elevation_at_zero = true") + op.alter_column('users', 'start_elevation_at_zero', nullable=False) + + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('users', schema=None) as batch_op: + batch_op.drop_column('start_elevation_at_zero') + + # ### end Alembic commands ### diff --git a/fittrackee/users/auth.py b/fittrackee/users/auth.py index 7330c850..9d6405b1 100644 --- a/fittrackee/users/auth.py +++ b/fittrackee/users/auth.py @@ -869,6 +869,7 @@ def edit_user_preferences(auth_user: User) -> Union[Dict, HttpResponse]: 4, 6 ], + "start_elevation_at_zero": true, "timezone": "Europe/Paris", "total_distance": 67.895, "total_duration": "6:50:27", @@ -883,9 +884,9 @@ def edit_user_preferences(auth_user: User) -> Union[Dict, HttpResponse]: : Union[Dict, HttpResponse]: 'display_ascent', 'imperial_units', 'language', + 'start_elevation_at_zero', 'timezone', 'weekm', } @@ -916,6 +918,7 @@ def edit_user_preferences(auth_user: User) -> Union[Dict, HttpResponse]: display_ascent = post_data.get('display_ascent') imperial_units = post_data.get('imperial_units') language = get_language(post_data.get('language')) + start_elevation_at_zero = post_data.get('start_elevation_at_zero') timezone = post_data.get('timezone') weekm = post_data.get('weekm') @@ -924,6 +927,7 @@ def edit_user_preferences(auth_user: User) -> Union[Dict, HttpResponse]: auth_user.display_ascent = display_ascent auth_user.imperial_units = imperial_units auth_user.language = language + auth_user.start_elevation_at_zero = start_elevation_at_zero auth_user.timezone = timezone auth_user.weekm = weekm db.session.commit() diff --git a/fittrackee/users/models.py b/fittrackee/users/models.py index 4d4b46f9..9c74f757 100644 --- a/fittrackee/users/models.py +++ b/fittrackee/users/models.py @@ -59,6 +59,7 @@ class User(BaseModel): confirmation_token = db.Column(db.String(255), nullable=True) display_ascent = db.Column(db.Boolean, default=True, nullable=False) accepted_policy_date = db.Column(db.DateTime, nullable=True) + start_elevation_at_zero = db.Column(db.Boolean, default=True, nullable=False) def __repr__(self) -> str: return f'' @@ -211,6 +212,7 @@ class User(BaseModel): 'display_ascent': self.display_ascent, 'imperial_units': self.imperial_units, 'language': self.language, + 'start_elevation_at_zero': self.start_elevation_at_zero, 'timezone': self.timezone, 'weekm': self.weekm, }, diff --git a/fittrackee_client/src/components/User/ProfileDisplay/UserPreferences.vue b/fittrackee_client/src/components/User/ProfileDisplay/UserPreferences.vue index bf2a418b..43fa0abd 100644 --- a/fittrackee_client/src/components/User/ProfileDisplay/UserPreferences.vue +++ b/fittrackee_client/src/components/User/ProfileDisplay/UserPreferences.vue @@ -19,6 +19,8 @@
{{ $t('user.PROFILE.ASCENT_DATA') }}:
{{ $t(`common.${display_ascent}`) }}
+
{{ $t('user.PROFILE.START_ELEVATION_AT_ZERO') }}:
+
{{ $t(`common.${startElevationAtZero}`) }}
+
+ + {{ $t('user.PROFILE.START_ELEVATION_AT_ZERO') }} + +
+ +
+