Skip to content

Commit

Permalink
Merge branch 'develop' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Dec 22, 2023
2 parents bd0e1bc + 4de9be5 commit 54119ed
Show file tree
Hide file tree
Showing 35 changed files with 1,328 additions and 4,567 deletions.
6 changes: 5 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,8 @@ REMOTE_USER_AUTH=0
# EXPORT_FILE_CACHE_DURATION=600

# if you want to do many requests to the FDC API you need to get a (free) API key. Demo key is limited to 30 requests / hour or 50 requests / day
#FDC_API_KEY=DEMO_KEY
#FDC_API_KEY=DEMO_KEY

# API throttle limits
# you may use X per second, minute, hour or day
# DRF_THROTTLE_RECIPE_URL_IMPORT=60/hour
1 change: 1 addition & 0 deletions .idea/dictionaries/vaben.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cookbook/helper/HelperFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Round(Func):


def str2bool(v):
if type(v) == bool or v is None:
if isinstance(v, bool) or v is None:
return v
else:
return v.lower() in ("yes", "true", "1")
3 changes: 3 additions & 0 deletions cookbook/helper/ingredient_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def parse(self, ingredient):
if len(ingredient) == 0:
raise ValueError('string to parse cannot be empty')

if len(ingredient) > 512:
raise ValueError('cannot parse ingredients with more than 512 characters')

# some people/languages put amount and unit at the end of the ingredient string
# if something like this is detected move it to the beginning so the parser can handle it
if len(ingredient) < 1000 and re.search(r'^([^\W\d_])+(.)*[1-9](\d)*\s*([^\W\d_])+', ingredient):
Expand Down
2 changes: 1 addition & 1 deletion cookbook/helper/recipe_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _recently_viewed(self, num_recent=None):

def _favorite_recipes(self, times_cooked=None):
if self._sort_includes('favorite') or times_cooked:
less_than = '-' in (times_cooked or []) and not self._sort_includes('-favorite')
less_than = '-' in (str(times_cooked) or []) and not self._sort_includes('-favorite')
if less_than:
default = 1000
else:
Expand Down
4 changes: 2 additions & 2 deletions cookbook/helper/recipe_url_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ def parse_keywords(keyword_json, request):
# if alias exists use that instead

if len(kw) != 0:
automation_engine.apply_keyword_automation(kw)
if k := Keyword.objects.filter(name=kw, space=request.space).first():
kw = automation_engine.apply_keyword_automation(kw)
if k := Keyword.objects.filter(name__iexact=kw, space=request.space).first():
keywords.append({'label': str(k), 'name': k.name, 'id': k.id})
else:
keywords.append({'label': kw, 'name': kw})
Expand Down
6 changes: 3 additions & 3 deletions cookbook/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-18 14:28+0200\n"
"PO-Revision-Date: 2023-10-12 20:19+0000\n"
"Last-Translator: pharok <[email protected]>\n"
"PO-Revision-Date: 2023-12-10 14:19+0000\n"
"Last-Translator: Robin Wilmet <[email protected]>\n"
"Language-Team: French <http://translate.tandoor.dev/projects/tandoor/"
"recipes-backend/fr/>\n"
"Language: fr\n"
Expand Down Expand Up @@ -551,7 +551,7 @@ msgstr "sens inverse"

#: .\cookbook\helper\recipe_url_import.py:267
msgid "careful rotation"
msgstr ""
msgstr "sens horloger"

#: .\cookbook\helper\recipe_url_import.py:268
msgid "knead"
Expand Down
22 changes: 8 additions & 14 deletions cookbook/locale/hu_HU/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-05-18 14:28+0200\n"
"PO-Revision-Date: 2023-10-20 14:05+0000\n"
"PO-Revision-Date: 2023-12-05 09:15+0000\n"
"Last-Translator: Ferenc <[email protected]>\n"
"Language-Team: Hungarian <http://translate.tandoor.dev/projects/tandoor/"
"recipes-backend/hu/>\n"
Expand Down Expand Up @@ -282,16 +282,12 @@ msgstr ""
"hibát figyelmen kívül hagynak)."

#: .\cookbook\forms.py:461
#, fuzzy
#| msgid ""
#| "Select type method of search. Click <a href=\"/docs/search/\">here</a> "
#| "for full desciption of choices."
msgid ""
"Select type method of search. Click <a href=\"/docs/search/\">here</a> for "
"full description of choices."
msgstr ""
"Válassza ki a keresés típusát. Kattintson <a href=\"/docs/search/\">ide</a> "
"a lehetőségek teljes leírásáért."
"Válassza ki a keresés típusát. Kattintson <a href=\"/docs/search/\">ide</"
"a> a lehetőségek teljes leírásáért."

#: .\cookbook\forms.py:462
msgid ""
Expand Down Expand Up @@ -536,10 +532,8 @@ msgid "One of queryset or hash_key must be provided"
msgstr "A queryset vagy a hash_key valamelyikét meg kell adni"

#: .\cookbook\helper\recipe_url_import.py:266
#, fuzzy
#| msgid "Use fractions"
msgid "reverse rotation"
msgstr "Törtek használata"
msgstr "Ellentétes irány"

#: .\cookbook\helper\recipe_url_import.py:267
msgid "careful rotation"
Expand Down Expand Up @@ -770,7 +764,7 @@ msgstr "Elérte a fájlfeltöltési limitet."

#: .\cookbook\serializer.py:291
msgid "Cannot modify Space owner permission."
msgstr ""
msgstr "A Hely tulajdonosi engedélye nem módosítható."

#: .\cookbook\serializer.py:1093
msgid "Hello"
Expand Down Expand Up @@ -1226,10 +1220,8 @@ msgstr "Admin"

#: .\cookbook\templates\base.html:312
#: .\cookbook\templates\space_overview.html:25
#, fuzzy
#| msgid "No Space"
msgid "Your Spaces"
msgstr "Nincs hely"
msgstr "Ön Helye"

#: .\cookbook\templates\base.html:323
#: .\cookbook\templates\space_overview.html:6
Expand Down Expand Up @@ -2132,6 +2124,8 @@ msgstr "Csatlakozás %(provider)s"
#, python-format
msgid "You are about to connect a new third party account from %(provider)s."
msgstr ""
"Ön egy új, harmadik féltől származó fiókot készül csatlakoztatni "
"a%(provider)-tól/től."

#: .\cookbook\templates\socialaccount\login.html:13
#, python-format
Expand Down
122 changes: 110 additions & 12 deletions cookbook/templates/system.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,94 @@ <h4 class="mt-3">{% trans 'Debug Mode' %} <span
{% trans 'Everything is fine!' %}
{% endif %}

<h4 class="mt-3">{% trans 'Database' %} <span
class="badge badge-{% if postgres %}warning{% else %}success{% endif %}">{% if postgres %}
{% trans 'Info' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>
{% if postgres %}
<h4 class="mt-3">{% trans 'Database' %}
<span class="badge badge-{{ postgres_status }}">
{% if postgres_status == 'warning' %}
{% trans 'Info' %}
{% elif postgres_status == 'danger' %}
{% trans 'Warning' %}
{% else %}
{% trans 'Ok' %}
{% endif %}
</span>
</h4>
{{ postgres_message }}

<h4 class="mt-3">{% trans 'Migrations' %}
<span
class="badge badge-{% if missing_migration %}danger{% else %}success{% endif %}">{% if missing_migration %}
{% trans 'Warning' %}{% else %}{% trans 'Ok' %}{% endif %}</span></h4>

<p>
{% blocktrans %}
This application is not running with a Postgres database backend. This is ok but not recommended as some
features only work with postgres databases.
Migrations should never fail!
Failed migrations will likely cause major parts of the app to not function correctly.
If a migration fails make sure you are on the latest version and if so please post the migration log and the overview below in a GitHub issue.
{% endblocktrans %}
{% else %}
{% trans 'Everything is fine!' %}
{% endif %}
</p>

<table class="table mt-3">
<thead>
<tr>
<th>App</th>
<th class="text-right">{% trans 'Migrations' %}</th>
</tr>
</thead>
{% for key,value in migration_info.items %}
<tr>

<td>{{ value.app }}</td>
<td class="text-right">
<span class="badge badge-{% if value.unapplied_migrations|length > 0 %}danger{% else %}success{% endif %}">
{{ value.applied_migrations|length }} / {{ value.total }}
</span>
</td>
</tr>
{% for u in value.unapplied_migrations %}
<tr>
<td>
{{ u }}
</td>
<td></td>
</tr>
{% endfor %}

{% endfor %}
</table>


{# <h4 class="mt-3">#}
{# {% trans 'Orphaned Files' %}#}
{##}
{# <span class="badge badge-{% if orphans|length == 0 %}success{% elif orphans|length <= 25 %}warning{% else %}danger{% endif %}">#}
{# {% if orphans|length == 0 %}{% trans 'Success' %}#}
{# {% elif orphans|length <= 25 %}{% trans 'Warning' %}#}
{# {% else %}{% trans 'Danger' %}#}
{# {% endif %}#}
{# </span>#}
{# </h4>#}

{# {% if orphans|length == 0 %}#}
{# {% trans 'Everything is fine!' %}#}
{# {% else %}#}
{# {% blocktrans with orphan_count=orphans|length %}#}
{# There are currently {{ orphan_count }} orphaned files.#}
{# {% endblocktrans %}#}
{# <br>#}
{# <button id="toggle-button" class="btn btn-info btn-sm" onclick="toggleOrphans()">{% trans 'Show' %}</button>#}
{# <button class="btn btn-info btn-sm" onclick="deleteOrphans()">{% trans 'Delete' %}</button>#}
{# {% endif %}#}
{# <textarea id="orphans-list" style="display:none;" class="form-control" rows="20">#}
{#{% for orphan in orphans %}{{ orphan }}#}
{#{% endfor %}#}
{# </textarea>#}

<h4 class="mt-3">Debug</h4>
<textarea class="form-control" rows="20">
Gunicorn Media: {{ gunicorn_media }}
Sqlite: {{ postgres }}
Debug: {{ debug }}
Sqlite: {% if postgres %} {% trans 'False' %} {% else %} {% trans 'True' %} {% endif %}
{% if postgres %}PostgreSQL: {{ postgres_version }} {% endif %}
Debug: {{ debug }}

{% for key,value in request.META.items %}{% if key in 'SERVER_PORT,REMOTE_HOST,REMOTE_ADDR,SERVER_PROTOCOL' %}{{ key }}:{{ value }}
{% endif %}{% endfor %}
Expand All @@ -110,4 +181,31 @@ <h4 class="mt-3">Debug</h4>
</textarea>
<br/>
<br/>
{% endblock %}
<form method="POST" id="delete-form">
{% csrf_token %}
<input type="hidden" name="delete_orphans" value="false">
</form>
{% block script %}
<script>
function toggleOrphans() {
var orphansList = document.getElementById('orphans-list');
var button = document.getElementById('toggle-button');

if (orphansList.style.display === 'none') {
orphansList.style.display = 'block';
button.innerText = "{% trans 'Hide' %}";
} else {
orphansList.style.display = 'none';
button.innerText = "{% trans 'Show' %}";
}
}

function deleteOrphans() {
document.getElementById('delete-form').delete_orphans.value = 'true';
document.getElementById('delete-form').submit();
}
</script>
{% endblock script %}
{% endblock %}


6 changes: 6 additions & 0 deletions cookbook/tests/api/test_api_meal_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ def test_list_filter(obj_1, u1_s1):
response = json.loads(r.content)
assert len(response) == 1

response = json.loads(u1_s1.get(f'{reverse(LIST_URL)}?meal_type={response[0]["meal_type"]["id"]}').content)
assert len(response) == 1

response = json.loads(u1_s1.get(f'{reverse(LIST_URL)}?meal_type=0').content)
assert len(response) == 0

response = json.loads(
u1_s1.get(f'{reverse(LIST_URL)}?from_date={(datetime.now() + timedelta(days=2)).strftime("%Y-%m-%d")}').content)
assert len(response) == 0
Expand Down
2 changes: 1 addition & 1 deletion cookbook/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def extend(self, r):
path('api/sync_all/', api.sync_all, name='api_sync'),
path('api/log_cooking/<int:recipe_id>/', api.log_cooking, name='api_log_cooking'),
path('api/plan-ical/<slug:from_date>/<slug:to_date>/', api.get_plan_ical, name='api_get_plan_ical'),
path('api/recipe-from-source/', api.recipe_from_source, name='api_recipe_from_source'),
path('api/recipe-from-source/', api.RecipeUrlImportView.as_view(), name='api_recipe_from_source'),
path('api/backup/', api.get_backup, name='api_backup'),
path('api/ingredient-from-string/', api.ingredient_from_string, name='api_ingredient_from_string'),
path('api/share-link/<int:pk>', api.share_link, name='api_share_link'),
Expand Down
Loading

0 comments on commit 54119ed

Please sign in to comment.