Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update fatsecret tools and fooddiary view #72

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading