Skip to content

Commit

Permalink
fix 100 trening update close #175
Browse files Browse the repository at this point in the history
  • Loading branch information
NECROshizo committed Apr 6, 2024
1 parent 3eced25 commit 8fd9dcb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions backend/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,15 @@ def _update_user_timezone_data(self, user: ClassUser, user_timezone: str) -> Non

def post(self, request: Request, *args, **kwargs) -> Response:
user_timezone = request.data.get("timezone")
user = request.user

if not user_timezone:
return Response({"timezone": "Часовой пояс пользователя обязателен."}, status=status.HTTP_400_BAD_REQUEST)

response = Response({"updated": True}, status=status.HTTP_200_OK)
if not user.last_completed_training:

user = request.user
last_traning = user.last_completed_training

if not last_traning:
self._update_user_timezone_data(user, user_timezone)
return response

Expand All @@ -272,8 +275,9 @@ def post(self, request: Request, *args, **kwargs) -> Response:
return response

user.timezone = user_timezone
if amount_of_skips >= days_missed:
self._updates_skip_data(user, amount_of_skips, days_missed, date_day_ago)
else:
self._clearing_user_training_data(user)
if last_traning.training_day.day_number < 100:
if amount_of_skips >= days_missed:
self._updates_skip_data(user, amount_of_skips, days_missed, date_day_ago)
else:
self._clearing_user_training_data(user)
return response

0 comments on commit 8fd9dcb

Please sign in to comment.