Skip to content

Commit

Permalink
Merge pull request #72 from Evgeniy-Golodnykh/develop
Browse files Browse the repository at this point in the history
update fatsecret tools and fooddiary view
  • Loading branch information
Evgeniy-Golodnykh authored Jan 18, 2025
2 parents 22fd62f + b41787a commit 586048e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion blackfox/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
7 changes: 0 additions & 7 deletions blackfox/blackfox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions blackfox/fatsecret/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions blackfox/templates/email/password_reset.html
Original file line number Diff line number Diff line change
Expand Up @@ -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!" %}

Expand All @@ -21,7 +21,7 @@

<p>{% trans "Please go to the following page and choose a new password:" %}</p>
<a href="https://www.blackfoxnutrition.ru/{{ url|safe }}">https://www.blackfoxnutrition.ru/{{ url|safe }}</a>
<p>{% trans "Your username, in case you've forgotten:" %} <b>{{ user.get_username }}</b></p>
<p>{% trans "Your email, in case you've forgotten:" %} <b>{{ user.get_username }}</b></p>

<p>{% trans "Thanks for using our site!" %}</p>

Expand Down

0 comments on commit 586048e

Please sign in to comment.