Skip to content

Commit

Permalink
Merge branch 'develop' into dont-log-sensitive-headers-in-err
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 authored Sep 23, 2024
2 parents e6eacc4 + 26ab7f5 commit c532b1f
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 55 deletions.
4 changes: 3 additions & 1 deletion cookbook/connectors/homeassistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ async def on_shopping_list_entry_created(self, space: Space, shopping_list_entry
data = {
"entity_id": self._config.todo_entity,
"item": item,
"description": description,
}

if self._config.supports_description_field:
data["description"] = description

try:
await self.homeassistant_api_call("POST", "services/todo/add_item", data)
except ClientResponseError as err:
Expand Down
8 changes: 7 additions & 1 deletion cookbook/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ class ConnectorConfigForm(forms.ModelForm):
required=False,
)

supports_description_field = forms.BooleanField(
help_text="Does the connector todo entity support the description field",
initial=True,
required=False,
)

update_token = forms.CharField(
widget=forms.TextInput(attrs={'autocomplete': 'update-token', 'type': 'password'}),
required=False,
Expand All @@ -198,7 +204,7 @@ class Meta:

fields = (
'name', 'type', 'enabled', 'on_shopping_list_entry_created_enabled', 'on_shopping_list_entry_updated_enabled',
'on_shopping_list_entry_deleted_enabled', 'url', 'todo_entity',
'on_shopping_list_entry_deleted_enabled', 'supports_description_field', 'url', 'todo_entity',
)

help_texts = {
Expand Down
91 changes: 47 additions & 44 deletions cookbook/locale/sv/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ 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: 2024-03-11 13:02+0000\n"
"Last-Translator: Kn <[email protected]>\n"
"PO-Revision-Date: 2024-09-17 11:58+0000\n"
"Last-Translator: Bebbe K <[email protected]>\n"
"Language-Team: Swedish <http://translate.tandoor.dev/projects/tandoor/"
"recipes-backend/sv/>\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.4.2\n"
"X-Generator: Weblate 5.6.2\n"

#: .\cookbook\forms.py:45
msgid ""
Expand Down Expand Up @@ -151,48 +151,61 @@ msgid ""
"Select type method of search. Click <a href=\"/docs/search/\">here</a> for "
"full description of choices."
msgstr ""
"Välj typ av sökmetod. Klicka <a href=\"/docs/search/\">här</a> för "
"fullständig beskrivning av alternativen."

#: .\cookbook\forms.py:341
msgid ""
"Use fuzzy matching on units, keywords and ingredients when editing and "
"importing recipes."
msgstr ""
"Använd \"fuzzy\" matchning på enheter, nyckelord och ingredienser när du "
"redigerar och importerar recept."

#: .\cookbook\forms.py:342
msgid ""
"Fields to search ignoring accents. Selecting this option can improve or "
"degrade search quality depending on language"
msgstr ""
"Fält att söka medan man ignorerar accenter. Val av detta alternativ kan "
"förbättra eller försämra sökkvaliteten beroende på språk"

#: .\cookbook\forms.py:343
msgid ""
"Fields to search for partial matches. (e.g. searching for 'Pie' will return "
"'pie' and 'piece' and 'soapie')"
msgstr ""
"Fält att söka efter delvisa matchningar. (t.ex. att söka efter 'Pie' kommer "
"att returnera 'pie' och 'piece' och 'soapie')"

#: .\cookbook\forms.py:344
msgid ""
"Fields to search for beginning of word matches. (e.g. searching for 'sa' "
"will return 'salad' and 'sandwich')"
msgstr ""
"Fält att söka för matchningar i början av ord. (t.ex. att söka efter 'sa' "
"kommer att returnera 'salad' och 'sandwich')"

#: .\cookbook\forms.py:345
msgid ""
"Fields to 'fuzzy' search. (e.g. searching for 'recpie' will find 'recipe'.) "
"Note: this option will conflict with 'web' and 'raw' methods of search."
msgstr ""
"Fält för 'fuzzy'-sökning. (t.ex. att söka efter 'recpie' kommer att hitta "
"'recipe'.Observera: detta alternativet kommer att komma i konflikt med "
"sökmetoderna 'web' och 'raw'.)"

#: .\cookbook\forms.py:346
msgid ""
"Fields to full text search. Note: 'web', 'phrase', and 'raw' search methods "
"only function with fulltext fields."
msgstr ""
"Fält för fulltextsökning. Observera: Sökmetoderna 'web', 'phrase' och 'raw' "
"fungerar endast med fulltextfält."

#: .\cookbook\forms.py:350
#, fuzzy
#| msgid "Search"
msgid "Search Method"
msgstr "Sök"
msgstr "Sök Metod"

#: .\cookbook\forms.py:350
msgid "Fuzzy Lookups"
Expand All @@ -211,22 +224,20 @@ msgid "Starts With"
msgstr "Börjar med"

#: .\cookbook\forms.py:351
#, fuzzy
#| msgid "Search"
msgid "Fuzzy Search"
msgstr "Sök"
msgstr "Fuzzy Sök"

#: .\cookbook\forms.py:351
#, fuzzy
#| msgid "Text"
msgid "Full Text"
msgstr "Text"
msgstr "Hel Text"

#: .\cookbook\helper\AllAuthCustomAdapter.py:41
msgid ""
"In order to prevent spam, the requested email was not send. Please wait a "
"few minutes and try again."
msgstr ""
"För att förhindra spam, så skickades inte den begärda e-posten. Vänta några "
"minuter och försök igen."

#: .\cookbook\helper\permission_helper.py:164
#: .\cookbook\helper\permission_helper.py:187 .\cookbook\views\views.py:117
Expand Down Expand Up @@ -255,19 +266,19 @@ msgstr "Du kan inte interagera med detta objekt för att det ägs inte av dig!"

#: .\cookbook\helper\permission_helper.py:402
msgid "You have reached the maximum number of recipes for your space."
msgstr ""
msgstr "Du har nått det maximala antalet recept för din utrymme."

#: .\cookbook\helper\permission_helper.py:414
msgid "You have more users than allowed in your space."
msgstr ""
msgstr "Du har mer användare än tillåtet för ditt utrymme."

#: .\cookbook\helper\recipe_url_import.py:310
msgid "reverse rotation"
msgstr ""
msgstr "återvänd rotering"

#: .\cookbook\helper\recipe_url_import.py:311
msgid "careful rotation"
msgstr ""
msgstr "försiktig rotering"

#: .\cookbook\helper\recipe_url_import.py:312
msgid "knead"
Expand All @@ -291,7 +302,7 @@ msgstr "sous-vide"

#: .\cookbook\helper\shopping_helper.py:150
msgid "You must supply a servings size"
msgstr ""
msgstr "Du måste ange en portionstorlek"

#: .\cookbook\helper\template_helper.py:95
#: .\cookbook\helper\template_helper.py:97
Expand All @@ -305,7 +316,7 @@ msgstr "Favorit"

#: .\cookbook\integration\copymethat.py:50
msgid "I made this"
msgstr ""
msgstr "Jag gjorde den här"

#: .\cookbook\integration\integration.py:209
msgid ""
Expand All @@ -319,6 +330,8 @@ msgid ""
"An unexpected error occurred during the import. Please make sure you have "
"uploaded a valid file."
msgstr ""
"Ett oväntat fel uppstod under importeringen. Se till att du har laddat upp "
"en giltig fil."

#: .\cookbook\integration\integration.py:217
msgid "The following recipes were ignored because they already existed:"
Expand All @@ -330,10 +343,8 @@ msgid "Imported %s recipes."
msgstr "Importerade %s recept."

#: .\cookbook\integration\openeats.py:28
#, fuzzy
#| msgid "Recipe Home"
msgid "Recipe source:"
msgstr "Recept Hem"
msgstr "Recept källa:"

#: .\cookbook\integration\paprika.py:49
msgid "Notes"
Expand Down Expand Up @@ -374,23 +385,25 @@ msgstr "Sektion"

#: .\cookbook\management\commands\fix_duplicate_properties.py:15
msgid "Fixes foods with "
msgstr ""
msgstr "Korrigerar livsmedel med "

#: .\cookbook\management\commands\rebuildindex.py:14
msgid "Rebuilds full text search index on Recipe"
msgstr ""
msgstr "Återuppbygger fulltextsökningens index för Recept"

#: .\cookbook\management\commands\rebuildindex.py:18
msgid "Only Postgresql databases use full text search, no index to rebuild"
msgstr ""
"Endast Postgresql-databaser använder fulltextsökning, inget index att "
"återuppbygga med"

#: .\cookbook\management\commands\rebuildindex.py:29
msgid "Recipe index rebuild complete."
msgstr ""
msgstr "Recept index återbyggning färdig."

#: .\cookbook\management\commands\rebuildindex.py:31
msgid "Recipe index rebuild failed."
msgstr ""
msgstr "Recept index återbyggning misslyckades."

#: .\cookbook\migrations\0047_auto_20200602_1133.py:14
msgid "Breakfast"
Expand Down Expand Up @@ -439,6 +452,8 @@ msgid ""
"Maximum file storage for space in MB. 0 for unlimited, -1 to disable file "
"upload."
msgstr ""
"Maximal lagringsutrymme för utrymme i MB. 0 för obegränsad, -1 för att "
"inaktivera filuppladdning."

#: .\cookbook\models.py:454 .\cookbook\templates\search.html:7
#: .\cookbook\templates\settings.html:18
Expand All @@ -462,7 +477,7 @@ msgstr "Handla"

#: .\cookbook\models.py:752
msgid " is part of a recipe step and cannot be deleted"
msgstr ""
msgstr " är en del av ett receptsteg och kan inte tas bort"

#: .\cookbook\models.py:918
msgid "Nutrition"
Expand Down Expand Up @@ -501,34 +516,24 @@ msgid "Food Alias"
msgstr "Alternativt namn för mat"

#: .\cookbook\models.py:1468
#, fuzzy
#| msgid "Units"
msgid "Unit Alias"
msgstr "Enheter"
msgstr "Enhetsalias"

#: .\cookbook\models.py:1469
#, fuzzy
#| msgid "Keywords"
msgid "Keyword Alias"
msgstr "Nyckelord"
msgstr "Nyckelordsalias"

#: .\cookbook\models.py:1470
#, fuzzy
#| msgid "Description"
msgid "Description Replace"
msgstr "Beskrivning"
msgstr "Beskrivning Ersätt"

#: .\cookbook\models.py:1471
#, fuzzy
#| msgid "Instructions"
msgid "Instruction Replace"
msgstr "Instruktioner"
msgstr "Instruktioner Ersätt"

#: .\cookbook\models.py:1472
#, fuzzy
#| msgid "New Unit"
msgid "Never Unit"
msgstr "Ny enhet"
msgstr "Aldrig Enhet"

#: .\cookbook\models.py:1473
msgid "Transpose Words"
Expand All @@ -539,10 +544,8 @@ msgid "Food Replace"
msgstr "Ersätt mat"

#: .\cookbook\models.py:1475
#, fuzzy
#| msgid "Edit Recipe"
msgid "Unit Replace"
msgstr "Redigera recept"
msgstr "Ersätt Enhet"

#: .\cookbook\models.py:1476
msgid "Name Replace"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.15 on 2024-09-15 10:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cookbook', '0218_alter_mealplan_from_date_alter_mealplan_to_date'),
]

operations = [
migrations.AddField(
model_name='connectorconfig',
name='supports_description_field',
field=models.BooleanField(default=True, help_text='Does the todo entity support the description field'),
),
]
1 change: 1 addition & 0 deletions cookbook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ class ConnectorConfig(models.Model, PermissionModelMixin):
on_shopping_list_entry_created_enabled = models.BooleanField(default=False)
on_shopping_list_entry_updated_enabled = models.BooleanField(default=False)
on_shopping_list_entry_deleted_enabled = models.BooleanField(default=False)
supports_description_field = models.BooleanField(default=True, help_text="Does the todo entity support the description field")

url = models.URLField(blank=True, null=True)
token = models.CharField(max_length=512, blank=True, null=True)
Expand Down
2 changes: 1 addition & 1 deletion cookbook/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class Meta:
fields = (
'id', 'name', 'url', 'token', 'todo_entity', 'enabled',
'on_shopping_list_entry_created_enabled', 'on_shopping_list_entry_updated_enabled',
'on_shopping_list_entry_deleted_enabled', 'created_by'
'on_shopping_list_entry_deleted_enabled', 'supports_description_field', 'created_by'
)

read_only_fields = ('created_by',)
Expand Down
12 changes: 12 additions & 0 deletions cookbook/tests/api/test_api_connector_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,23 @@ def test_add(arg, request, a1_s2, obj_1):
assert r.status_code == arg[1]
if r.status_code == 201:
assert response['name'] == 'test'
assert response['supports_description_field'] == True
r = c.get(reverse(DETAIL_URL, args={response['id']}))
assert r.status_code == 200
r = a1_s2.get(reverse(DETAIL_URL, args={response['id']}))
assert r.status_code == 404

def test_add_with_supports_description_field_false(a1_s2):
r = a1_s2.post(
reverse(LIST_URL),
{'name': 'test', 'url': 'http://localhost:8123/api', 'token': '1234', 'enabled': 'true', 'supports_description_field': 'false'},
content_type='application/json'
)
response = json.loads(r.content)
print(r.content)
assert r.status_code == 201
assert response['name'] == 'test'
assert response['supports_description_field'] == False

def test_delete(a1_s1, a1_s2, obj_1):
r = a1_s2.delete(
Expand Down
Loading

0 comments on commit c532b1f

Please sign in to comment.