Merge branch 'develop' into feature/vue3

# Conflicts:
#	.github/workflows/ci.yml
#	.gitignore
#	requirements.txt
This commit is contained in:
vabene1111
2024-03-02 07:41:07 +01:00
112 changed files with 33936 additions and 186 deletions

View File

@@ -11,8 +11,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: 2022-11-06 22:09+0000\n"
"Last-Translator: Gorkem <g.kalipcilar@gmail.com>\n"
"PO-Revision-Date: 2024-02-29 02:19+0000\n"
"Last-Translator: M Ugur <mugurd@gmail.com>\n"
"Language-Team: Turkish <http://translate.tandoor.dev/projects/tandoor/"
"recipes-backend/tr/>\n"
"Language: tr\n"
@@ -20,7 +20,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Weblate 4.14.1\n"
"X-Generator: Weblate 4.15\n"
#: .\cookbook\forms.py:52
msgid "Default unit"
@@ -28,15 +28,15 @@ msgstr "Varsayılan birim"
#: .\cookbook\forms.py:53
msgid "Use fractions"
msgstr ""
msgstr "Kesirleri kullan"
#: .\cookbook\forms.py:54
msgid "Use KJ"
msgstr ""
msgstr "KiloJoule kullan"
#: .\cookbook\forms.py:55
msgid "Theme"
msgstr ""
msgstr "Tema"
#: .\cookbook\forms.py:56
msgid "Navbar color"
@@ -55,14 +55,12 @@ msgid "Plan sharing"
msgstr ""
#: .\cookbook\forms.py:60
#, fuzzy
#| msgid "Ingredients"
msgid "Ingredient decimal places"
msgstr "Malzemeler"
msgstr "Malzeme ondalık virgül yeri"
#: .\cookbook\forms.py:61
msgid "Shopping list auto sync period"
msgstr ""
msgstr "Alışveriş listesinin otomatik eşleşme sıklığı"
#: .\cookbook\forms.py:62 .\cookbook\templates\recipe_view.html:36
msgid "Comments"
@@ -70,7 +68,7 @@ msgstr "Yorumlar"
#: .\cookbook\forms.py:63
msgid "Left-handed mode"
msgstr ""
msgstr "Solaklar için"
#: .\cookbook\forms.py:67
msgid ""
@@ -100,7 +98,7 @@ msgstr ""
#: .\cookbook\forms.py:75
msgid "Users with whom to share shopping lists."
msgstr ""
msgstr "Alışveriş listesinin paylaşılacağı kullanıcılar."
#: .\cookbook\forms.py:76
msgid "Number of decimals to round ingredients."
@@ -424,10 +422,8 @@ msgid "Fields on food that should be inherited by default."
msgstr ""
#: .\cookbook\forms.py:558
#, fuzzy
#| msgid "Show recently viewed recipes on search page."
msgid "Show recipe counts on search filters"
msgstr "Son görüntülenen tarifleri arama sayfasında göster."
msgstr "süzülen tarifleri arama sayfasında göster."
#: .\cookbook\forms.py:559
msgid "Use the plural form for units and food inside this space."

View File

@@ -0,0 +1,88 @@
from datetime import datetime, timedelta
import pytest
from django.contrib import auth
from django.urls import reverse
from icalendar import Calendar
from cookbook.models import MealPlan, MealType
BOUND_URL = 'api_get_plan_ical'
FROM_URL = 'api_get_plan_ical_from'
FUTURE_URL = 'api_get_plan_ical_future'
@pytest.fixture()
def meal_type(space_1, u1_s1):
return MealType.objects.get_or_create(name='test', space=space_1, created_by=auth.get_user(u1_s1))[0]
@pytest.fixture()
def obj_1(space_1, recipe_1_s1, meal_type, u1_s1):
return MealPlan.objects.create(recipe=recipe_1_s1, space=space_1, meal_type=meal_type, from_date=datetime.now(), to_date=datetime.now(),
created_by=auth.get_user(u1_s1))
@pytest.fixture
def obj_2(space_1, recipe_1_s1, meal_type, u1_s1):
return MealPlan.objects.create(recipe=recipe_1_s1, space=space_1, meal_type=meal_type, from_date=datetime.now()+timedelta(days=30), to_date=datetime.now()+timedelta(days=30),
created_by=auth.get_user(u1_s1))
@pytest.fixture
def obj_3(space_1, recipe_1_s1, meal_type, u1_s1):
return MealPlan.objects.create(recipe=recipe_1_s1, space=space_1, meal_type=meal_type, from_date=datetime.now()+timedelta(days=-30), to_date=datetime.now()+timedelta(days=-1),
created_by=auth.get_user(u1_s1))
@pytest.mark.parametrize("arg", [
['a_u', 403],
['g1_s1', 403],
['u1_s1', 200],
['a1_s1', 200],
])
def test_permissions(arg, request):
c = request.getfixturevalue(arg[0])
assert c.get(reverse(FUTURE_URL)).status_code == arg[1]
def test_future(obj_1, obj_2, obj_3, u1_s1):
r = u1_s1.get(reverse(FUTURE_URL))
assert r.status_code == 200
cal = Calendar.from_ical(r.getvalue().decode('UTF-8'))
events = cal.walk('VEVENT')
assert len(events) == 2
def test_from(obj_1, obj_2, obj_3, u1_s1):
from_date_slug = (datetime.now()+timedelta(days=1)).strftime("%Y-%m-%d")
r = u1_s1.get(reverse(FROM_URL, kwargs={'from_date': from_date_slug}))
assert r.status_code == 200
cal = Calendar.from_ical(r.getvalue().decode('UTF-8'))
events = cal.walk('VEVENT')
assert len(events) == 1
def test_bound(obj_1, obj_2, obj_3, u1_s1):
from_date_slug = (datetime.now()+timedelta(days=-1)).strftime("%Y-%m-%d")
to_date_slug = (datetime.now()+timedelta(days=1)).strftime("%Y-%m-%d")
r = u1_s1.get(reverse(BOUND_URL, kwargs={'from_date': from_date_slug, 'to_date': to_date_slug}))
assert r.status_code == 200
cal = Calendar.from_ical(r.getvalue().decode('UTF-8'))
events = cal.walk('VEVENT')
assert len(events) == 1
def test_event(obj_1, u1_s1):
from_date_slug = (datetime.now()+timedelta(days=-1)).strftime("%Y-%m-%d")
to_date_slug = (datetime.now()+timedelta(days=1)).strftime("%Y-%m-%d")
r = u1_s1.get(reverse(BOUND_URL, kwargs={'from_date': from_date_slug, 'to_date': to_date_slug}))
cal = Calendar.from_ical(r.getvalue().decode('UTF-8'))
events = cal.walk('VEVENT')
assert len(events) == 1
event = events[0]
assert int(event['uid']) == obj_1.id
assert event['summary'] == f'{obj_1.meal_type.name}: {obj_1.get_label()}'
assert event['description'] == obj_1.note
assert event.decoded('dtstart') == datetime.now().date()
assert event.decoded('dtend') == datetime.now().date()

View File

@@ -122,6 +122,8 @@ urlpatterns = [
path('api/get_recipe_file/<int:recipe_id>/', api.get_recipe_file, name='api_get_recipe_file'),
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/', api.get_plan_ical, name='api_get_plan_ical_future'),
path('api/plan-ical/<slug:from_date>/', api.get_plan_ical, name='api_get_plan_ical_from'),
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.RecipeUrlImportView.as_view(), name='api_recipe_from_source'),
path('api/backup/', api.get_backup, name='api_backup'),

View File

@@ -1740,8 +1740,9 @@ def log_cooking(request, recipe_id):
return {'error': 'recipe does not exist'}
@group_required('user')
def get_plan_ical(request, from_date, to_date):
@api_view(['GET'])
@permission_classes([CustomIsUser & CustomTokenHasReadWriteScope])
def get_plan_ical(request, from_date=datetime.date.today(), to_date=None):
queryset = MealPlan.objects.filter(Q(created_by=request.user)
| Q(shared=request.user)).filter(space=request.user.userspace_set.filter(active=1).first().space).distinct().all()