mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
Merge branch 'develop' into feature/vue3
# Conflicts: # docs/features/authentication.md
This commit is contained in:
@@ -6,7 +6,7 @@ from django.utils.dateparse import parse_duration
|
||||
from django.utils.translation import gettext as _
|
||||
from isodate import parse_duration as iso_parse_duration
|
||||
from isodate.isoerror import ISO8601Error
|
||||
from pytube import YouTube
|
||||
from pytubefix import YouTube
|
||||
from recipe_scrapers._utils import get_host_name, get_minutes
|
||||
|
||||
from cookbook.helper.automation_helper import AutomationEngine
|
||||
@@ -274,9 +274,8 @@ def get_from_youtube_scraper(url, request):
|
||||
default_recipe_json['image'] = video.thumbnail_url
|
||||
if video.description:
|
||||
default_recipe_json['steps'][0]['instruction'] = automation_engine.apply_regex_replace_automation(video.description, Automation.INSTRUCTION_REPLACE)
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
traceback.print_exc()
|
||||
|
||||
return default_recipe_json
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ from gettext import gettext as _
|
||||
import bleach
|
||||
import markdown as md
|
||||
from jinja2 import Template, TemplateSyntaxError, UndefinedError
|
||||
from jinja2.exceptions import SecurityError
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from markdown.extensions.tables import TableExtension
|
||||
|
||||
from cookbook.helper.mdx_attributes import MarkdownFormatExtension
|
||||
@@ -89,11 +91,13 @@ def render_instructions(step): # TODO deduplicate markdown cleanup code
|
||||
return f"<scalable-number v-bind:number='{bleach.clean(str(number))}' v-bind:factor='ingredient_factor'></scalable-number>"
|
||||
|
||||
try:
|
||||
template = Template(instructions)
|
||||
instructions = template.render(ingredients=ingredients, scale=scale)
|
||||
env = SandboxedEnvironment()
|
||||
instructions = env.from_string(instructions).render(ingredients=ingredients, scale=scale)
|
||||
except TemplateSyntaxError:
|
||||
return _('Could not parse template code.') + ' Error: Template Syntax broken'
|
||||
except UndefinedError:
|
||||
return _('Could not parse template code.') + ' Error: Undefined Error'
|
||||
except SecurityError:
|
||||
return _('Could not parse template code.') + ' Error: Security Error'
|
||||
|
||||
return instructions
|
||||
|
||||
2503
cookbook/locale/hr/LC_MESSAGES/django.po
Normal file
2503
cookbook/locale/hr/LC_MESSAGES/django.po
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,17 +8,17 @@ msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-08-01 15:04+0200\n"
|
||||
"PO-Revision-Date: 2023-05-01 07:55+0000\n"
|
||||
"Last-Translator: axeron2036 <admin@axeron2036.ru>\n"
|
||||
"PO-Revision-Date: 2024-11-12 17:58+0000\n"
|
||||
"Last-Translator: Владислав <vlad@kelonmyosa.ru>\n"
|
||||
"Language-Team: Russian <http://translate.tandoor.dev/projects/tandoor/"
|
||||
"recipes-backend/ru/>\n"
|
||||
"Language: ru\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
|
||||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 4.15\n"
|
||||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
|
||||
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 5.6.2\n"
|
||||
|
||||
#: .\cookbook\forms.py:45
|
||||
msgid ""
|
||||
@@ -454,17 +454,17 @@ msgstr ""
|
||||
#: .\cookbook\models.py:455 .\cookbook\templates\base.html:114
|
||||
#: .\cookbook\templates\meal_plan.html:7
|
||||
msgid "Meal-Plan"
|
||||
msgstr ""
|
||||
msgstr "План питания"
|
||||
|
||||
#: .\cookbook\models.py:456 .\cookbook\templates\base.html:122
|
||||
#: .\cookbook\views\views.py:459
|
||||
msgid "Books"
|
||||
msgstr "Книги"
|
||||
msgstr "Книги рецептов"
|
||||
|
||||
#: .\cookbook\models.py:457 .\cookbook\templates\base.html:118
|
||||
#: .\cookbook\views\views.py:460
|
||||
msgid "Shopping"
|
||||
msgstr ""
|
||||
msgstr "Покупки"
|
||||
|
||||
#: .\cookbook\models.py:752
|
||||
msgid " is part of a recipe step and cannot be deleted"
|
||||
@@ -929,7 +929,7 @@ msgstr ""
|
||||
|
||||
#: .\cookbook\templates\base.html:110 .\cookbook\templates\index.html:87
|
||||
msgid "Recipes"
|
||||
msgstr ""
|
||||
msgstr "Рецепты"
|
||||
|
||||
#: .\cookbook\templates\base.html:161 .\cookbook\views\lists.py:120
|
||||
msgid "Foods"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,17 +8,17 @@ msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2024-08-01 15:04+0200\n"
|
||||
"PO-Revision-Date: 2023-04-12 11:55+0000\n"
|
||||
"Last-Translator: noxonad <noxonad@proton.me>\n"
|
||||
"PO-Revision-Date: 2024-11-22 07:58+0000\n"
|
||||
"Last-Translator: Oleh Hudyma <oleg.hudymaa@gmail.com>\n"
|
||||
"Language-Team: Ukrainian <http://translate.tandoor.dev/projects/tandoor/"
|
||||
"recipes-backend/uk/>\n"
|
||||
"Language: uk\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
|
||||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 4.15\n"
|
||||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
|
||||
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 5.6.2\n"
|
||||
|
||||
#: .\cookbook\forms.py:45
|
||||
msgid ""
|
||||
@@ -36,47 +36,51 @@ msgstr ""
|
||||
|
||||
#: .\cookbook\forms.py:62
|
||||
msgid "Preparation time in minutes"
|
||||
msgstr ""
|
||||
msgstr "Час приготування у хвилинах"
|
||||
|
||||
#: .\cookbook\forms.py:62
|
||||
msgid "Waiting time (cooking/baking) in minutes"
|
||||
msgstr ""
|
||||
msgstr "Час очікування (варіння/випічка) у хвилинах"
|
||||
|
||||
#: .\cookbook\forms.py:63 .\cookbook\forms.py:222 .\cookbook\forms.py:246
|
||||
msgid "Path"
|
||||
msgstr ""
|
||||
msgstr "Шлях"
|
||||
|
||||
#: .\cookbook\forms.py:63
|
||||
msgid "Storage UID"
|
||||
msgstr ""
|
||||
msgstr "UID сховища"
|
||||
|
||||
#: .\cookbook\forms.py:93
|
||||
msgid "Default"
|
||||
msgstr ""
|
||||
msgstr "За замовчуванням"
|
||||
|
||||
#: .\cookbook\forms.py:121
|
||||
msgid ""
|
||||
"To prevent duplicates recipes with the same name as existing ones are "
|
||||
"ignored. Check this box to import everything."
|
||||
msgstr ""
|
||||
"Щоб запобігти дублюванням, рецепти з назвами, що вже існують, "
|
||||
"ігноруватимуться. Установіть цей прапорець, щоб імпортувати все."
|
||||
|
||||
#: .\cookbook\forms.py:143
|
||||
msgid "Add your comment: "
|
||||
msgstr ""
|
||||
msgstr "Додайте ваш коментар: "
|
||||
|
||||
#: .\cookbook\forms.py:151
|
||||
msgid "Leave empty for dropbox and enter app password for nextcloud."
|
||||
msgstr ""
|
||||
msgstr "Залиште порожнім для dropbox і введіть api ключі для nextcloud."
|
||||
|
||||
#: .\cookbook\forms.py:154
|
||||
msgid "Leave empty for nextcloud and enter api token for dropbox."
|
||||
msgstr ""
|
||||
msgstr "Залиште порожнім для nextcloud і введіть api ключі для dropbox."
|
||||
|
||||
#: .\cookbook\forms.py:160
|
||||
msgid ""
|
||||
"Leave empty for dropbox and enter only base url for nextcloud (<code>/remote."
|
||||
"php/webdav/</code> is added automatically)"
|
||||
msgstr ""
|
||||
"Залиште порожнім для dropbox і введіть лише базовий url для nextcloud "
|
||||
"(<code>/remote.php/webdav/</code> буде додано автоматично)"
|
||||
|
||||
#: .\cookbook\forms.py:188
|
||||
msgid ""
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
{#{% for orphan in orphans %}{{ orphan }}#}
|
||||
{#{% endfor %}#}
|
||||
{# </textarea>#}
|
||||
|
||||
{% if api_space_stats %}
|
||||
<h4 class="mt-3">API Stats</h4>
|
||||
<h6 >Space Stats</h6>
|
||||
<table class="table table-bordered table-striped">
|
||||
@@ -202,7 +202,7 @@
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endif %}
|
||||
<h4 class="mt-3">Debug</h4>
|
||||
<textarea class="form-control" rows="20">
|
||||
Gunicorn Media: {{ gunicorn_media }}
|
||||
|
||||
@@ -123,35 +123,38 @@ class LoggingMixin(object):
|
||||
super(LoggingMixin, self).initial(request, *args, **kwargs)
|
||||
|
||||
if settings.REDIS_HOST:
|
||||
d = date.today().isoformat()
|
||||
space = request.space
|
||||
endpoint = request.resolver_match.url_name
|
||||
try:
|
||||
d = date.today().isoformat()
|
||||
space = request.space
|
||||
endpoint = request.resolver_match.url_name
|
||||
|
||||
r = redis.StrictRedis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
username=settings.REDIS_USERNAME,
|
||||
password=settings.REDIS_PASSWORD,
|
||||
db=settings.REDIS_DATABASES['STATS'],
|
||||
)
|
||||
r = redis.StrictRedis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
username=settings.REDIS_USERNAME,
|
||||
password=settings.REDIS_PASSWORD,
|
||||
db=settings.REDIS_DATABASES['STATS'],
|
||||
)
|
||||
|
||||
pipe = r.pipeline()
|
||||
pipe = r.pipeline()
|
||||
|
||||
# Global and daily tallies for all URLs.
|
||||
pipe.incr('api:request-count')
|
||||
pipe.incr(f'api:request-count:{d}')
|
||||
# Global and daily tallies for all URLs.
|
||||
pipe.incr('api:request-count')
|
||||
pipe.incr(f'api:request-count:{d}')
|
||||
|
||||
# Use a sorted set to store the user stats, with the score representing
|
||||
# the number of queries the user made total or on a given day.
|
||||
pipe.zincrby(f'api:space-request-count', 1, space.pk)
|
||||
pipe.zincrby(f'api:space-request-count:{d}', 1, space.pk)
|
||||
# Use a sorted set to store the user stats, with the score representing
|
||||
# the number of queries the user made total or on a given day.
|
||||
pipe.zincrby(f'api:space-request-count', 1, space.pk)
|
||||
pipe.zincrby(f'api:space-request-count:{d}', 1, space.pk)
|
||||
|
||||
# Use a sorted set to store all the endpoints with score representing
|
||||
# the number of queries the endpoint received total or on a given day.
|
||||
pipe.zincrby(f'api:endpoint-request-count', 1, endpoint)
|
||||
pipe.zincrby(f'api:endpoint-request-count:{d}', 1, endpoint)
|
||||
# Use a sorted set to store all the endpoints with score representing
|
||||
# the number of queries the endpoint received total or on a given day.
|
||||
pipe.zincrby(f'api:endpoint-request-count', 1, endpoint)
|
||||
pipe.zincrby(f'api:endpoint-request-count:{d}', 1, endpoint)
|
||||
|
||||
pipe.execute()
|
||||
pipe.execute()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
@extend_schema_view(list=extend_schema(parameters=[
|
||||
|
||||
@@ -356,42 +356,45 @@ def system(request):
|
||||
for key in migration_info.keys():
|
||||
migration_info[key]['total'] = len(migration_info[key]['unapplied_migrations']) + len(migration_info[key]['applied_migrations'])
|
||||
|
||||
api_stats = None
|
||||
api_space_stats = None
|
||||
# API endpoint logging
|
||||
r = redis.StrictRedis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
password='',
|
||||
username='',
|
||||
db=settings.REDIS_DATABASES['STATS'],
|
||||
)
|
||||
if settings.REDIS_HOST:
|
||||
r = redis.StrictRedis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
password='',
|
||||
username='',
|
||||
db=settings.REDIS_DATABASES['STATS'],
|
||||
)
|
||||
|
||||
api_stats = [['Endpoint', 'Total']]
|
||||
api_space_stats = [['User', 'Total']]
|
||||
total_stats = ['All', int(r.get('api:request-count'))]
|
||||
api_stats = [['Endpoint', 'Total']]
|
||||
api_space_stats = [['User', 'Total']]
|
||||
total_stats = ['All', int(r.get('api:request-count'))]
|
||||
|
||||
for i in range(0, 6):
|
||||
d = (date.today() - timedelta(days=i)).isoformat()
|
||||
api_stats[0].append(d)
|
||||
api_space_stats[0].append(d)
|
||||
total_stats.append(int(r.get(f'api:request-count:{d}')) if r.get(f'api:request-count:{d}') else 0)
|
||||
|
||||
api_stats.append(total_stats)
|
||||
|
||||
for x in r.zrange('api:endpoint-request-count', 0, -1, withscores=True, desc=True):
|
||||
endpoint = x[0].decode('utf-8')
|
||||
endpoint_stats = [endpoint, x[1]]
|
||||
for i in range(0, 6):
|
||||
d = (date.today() - timedelta(days=i)).isoformat()
|
||||
endpoint_stats.append(r.zscore(f'api:endpoint-request-count:{d}', endpoint))
|
||||
api_stats.append(endpoint_stats)
|
||||
api_stats[0].append(d)
|
||||
api_space_stats[0].append(d)
|
||||
total_stats.append(int(r.get(f'api:request-count:{d}')) if r.get(f'api:request-count:{d}') else 0)
|
||||
|
||||
for x in r.zrange('api:space-request-count', 0, 20, withscores=True, desc=True):
|
||||
s = x[0].decode('utf-8')
|
||||
space_stats = [Space.objects.get(pk=s).name, x[1]]
|
||||
for i in range(0, 6):
|
||||
d = (date.today() - timedelta(days=i)).isoformat()
|
||||
space_stats.append(r.zscore(f'api:space-request-count:{d}', s))
|
||||
api_space_stats.append(space_stats)
|
||||
api_stats.append(total_stats)
|
||||
|
||||
for x in r.zrange('api:endpoint-request-count', 0, -1, withscores=True, desc=True):
|
||||
endpoint = x[0].decode('utf-8')
|
||||
endpoint_stats = [endpoint, x[1]]
|
||||
for i in range(0, 6):
|
||||
d = (date.today() - timedelta(days=i)).isoformat()
|
||||
endpoint_stats.append(r.zscore(f'api:endpoint-request-count:{d}', endpoint))
|
||||
api_stats.append(endpoint_stats)
|
||||
|
||||
for x in r.zrange('api:space-request-count', 0, 20, withscores=True, desc=True):
|
||||
s = x[0].decode('utf-8')
|
||||
space_stats = [Space.objects.get(pk=s).name, x[1]]
|
||||
for i in range(0, 6):
|
||||
d = (date.today() - timedelta(days=i)).isoformat()
|
||||
space_stats.append(r.zscore(f'api:space-request-count:{d}', s))
|
||||
api_space_stats.append(space_stats)
|
||||
|
||||
return render(
|
||||
request, 'system.html', {
|
||||
|
||||
Reference in New Issue
Block a user