diff --git a/blackfox/api/views.py b/blackfox/api/views.py index f69e0af..176fe0c 100644 --- a/blackfox/api/views.py +++ b/blackfox/api/views.py @@ -71,7 +71,8 @@ def create(self, request): status=status.HTTP_400_BAD_REQUEST ) try: - objs = get_fooddiary_objects(user) + reload = True if request.query_params.get('reload') else False + objs = get_fooddiary_objects(user, reload=reload) except KeyError as error: return Response( {'message': fatsecret_error_message.format(error=error)}, diff --git a/blackfox/blackfox/settings.py b/blackfox/blackfox/settings.py index 63a1a48..38f49a4 100644 --- a/blackfox/blackfox/settings.py +++ b/blackfox/blackfox/settings.py @@ -106,13 +106,6 @@ } } -'''DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': '/Users/evgeniygolodnykh/Desktop/blackfox_backend/db.sqlite3', - } -}''' - # Password validation # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators diff --git a/blackfox/fatsecret/tools.py b/blackfox/fatsecret/tools.py index 513582c..adcfcab 100644 --- a/blackfox/fatsecret/tools.py +++ b/blackfox/fatsecret/tools.py @@ -105,12 +105,15 @@ def get_fatsecret_data(session, params, date): } -def get_fooddiary_objects(user): +def get_fooddiary_objects(user, reload=False): """A function to create FoodDiary instance from fatscrit data.""" fooddiary = FoodDiary.objects.filter(user=user).first() project = Project.objects.filter(user=user).first() - if fooddiary: + if reload: + last_diary_date = project.start_date + FoodDiary.objects.filter(user=user).delete() + elif fooddiary: last_diary_date = fooddiary.date FoodDiary.objects.filter(id=fooddiary.id).delete() else: diff --git a/blackfox/templates/email/password_reset.html b/blackfox/templates/email/password_reset.html index 2235b16..e502d05 100644 --- a/blackfox/templates/email/password_reset.html +++ b/blackfox/templates/email/password_reset.html @@ -9,7 +9,7 @@ {% trans "Please go to the following page and choose a new password:" %} https://www.blackfoxnutrition.ru/{{ url|safe }} -{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }} +{% trans "Your email, in case you've forgotten:" %} {{ user.get_username }} {% trans "Thanks for using our site!" %} @@ -21,7 +21,7 @@
{% trans "Please go to the following page and choose a new password:" %}
https://www.blackfoxnutrition.ru/{{ url|safe }} -{% trans "Your username, in case you've forgotten:" %} {{ user.get_username }}
+{% trans "Your email, in case you've forgotten:" %} {{ user.get_username }}
{% trans "Thanks for using our site!" %}