From 9961746f1fdc27287b79dd4989af7b41ccc457a9 Mon Sep 17 00:00:00 2001 From: nough Date: Thu, 7 Jul 2022 15:46:31 +0100 Subject: [PATCH 01/17] update, adding docker backup script outline --- docs/system/updating.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/system/updating.md b/docs/system/updating.md index b38f3fd3..b1da0aa7 100644 --- a/docs/system/updating.md +++ b/docs/system/updating.md @@ -11,6 +11,33 @@ For all setups using Docker the updating process look something like this 2. Pull the latest image using `docker-compose pull` 3. Start the container again using `docker-compose up -d` +## Docker Script +``` +#get vars +input name of docker_db_container +input working directory + +#backup docker +sudo docker exec -t docker_db_recipes_1 pg_dumpall -U djangouser > pgdump.sql + +docker-compose down +mv postgresql date_postgresqlbackup +check that docker-compose.yml files are up to date with latest recommended from install instructions +check that .env is up to date with latest recommended from install instructions + +#start update +docker-compose pull +docker-compose up -d +wait 5 minutes +docker-compose down +docker-compose up -d +wait 5 minutes + +#import database to new setup +cat pgdump.sql | sudo docker exec -i docker_db_recipes_1 psql postgres -U djangouser +docker-compose down +docker-compose up -d +``` ## Manual @@ -20,4 +47,4 @@ After that make sure to run: 1. `manage.py collectstatic` 2. `manage.py migrate` -To apply all new migrations and collect new static files. \ No newline at end of file +To apply all new migrations and collect new static files. From c86ff27bef8c5c0c4c8966b999586452f6f286b6 Mon Sep 17 00:00:00 2001 From: nough Date: Fri, 8 Jul 2022 09:19:48 +0100 Subject: [PATCH 02/17] Update backup.md Further information, backup using import/export. --- docs/system/backup.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/system/backup.md b/docs/system/backup.md index 20e865f9..cf5a2854 100644 --- a/docs/system/backup.md +++ b/docs/system/backup.md @@ -31,7 +31,7 @@ The filenames consist of `_`. In case you screw up real The standard docker build of tandoor uses postgresql as the back end database. This can be backed up using a function called "dumpall". This generates a .SQL file containing a list of commands for a postgresql server to use to rebuild your database. You will also need to back up the media files separately. Making a full copy of the docker directory can work as a back up, but only if you know you will be using the same hardware, os, and postgresql version upon restore. If not, then the different version of postgresql won't be compatible with the existing tables. -You can back up from docker even when the tandoor container is failing, so long as the postgresql database has started successfully. +You can back up from docker even when the tandoor container is failing, so long as the postgresql database has started successfully. When using this backup method, ensure that your recipes have imported successfully. One user reported only the titles and images importing on first try, requiring a second run of the import command. the following commands assume that your docker-compose files are in a folder called "docker". replace "docker_db_recipes_1" with the name of your db container. The commands also assume you use a backup name of pgdump.sql. It's a good idea to include a date in this filename, so that successive backups do not get deleted. To back up: @@ -47,3 +47,12 @@ cat pgdump.sql | sudo docker exec -i docker_db_recipes_1 psql postgres -U django ``` This connects to the postgres table instead of the actual dgangodb table, as the import function needs to delete the table, which can't be dropped off you're connected to it. +## Backup using export and import +You can now export recipes from Tandoor using the export function. This method requires a working web interface. +1. Click on a recipe +2. Click on the three meatballs then export +3. Select the all recipes toggle and then export. This should download a zip file. + +Import: +Go to Import > from app > tandoor and select the zip file you want to import from. + From cffa731106dafc84b273c5e75435b90db146a9a7 Mon Sep 17 00:00:00 2001 From: Andrew Jayne Date: Sun, 7 Aug 2022 20:51:45 +0100 Subject: [PATCH 03/17] fix: ingredient parsing for non-latin languages Before this change the ingredient string for non-latin languages was not being parsed into the correct amount or units when the food is found at the start of the ingredient string. This was because the regex being used was restricted to latin characters. With this change the amount and units are correctly parsed from such a string. Fixes https://github.com/TandoorRecipes/recipes/issues/1983 --- cookbook/helper/ingredient_parser.py | 4 ++-- cookbook/tests/other/test_ingredient_parser.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cookbook/helper/ingredient_parser.py b/cookbook/helper/ingredient_parser.py index 8a4fc30a..468f1128 100644 --- a/cookbook/helper/ingredient_parser.py +++ b/cookbook/helper/ingredient_parser.py @@ -221,8 +221,8 @@ class IngredientParser: # 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'^([A-z])+(.)*[1-9](\d)*\s([A-z])+', ingredient): - match = re.search(r'[1-9](\d)*\s([A-z])+', ingredient) + if len(ingredient) < 1000 and re.search(r'^([^\W\d_])+(.)*[1-9](\d)*\s*([^\W\d_])+', ingredient): + match = re.search(r'[1-9](\d)*\s*([^\W\d_])+', ingredient) print(f'reording from {ingredient} to {ingredient[match.start():match.end()] + " " + ingredient.replace(ingredient[match.start():match.end()], "")}') ingredient = ingredient[match.start():match.end()] + ' ' + ingredient.replace(ingredient[match.start():match.end()], '') diff --git a/cookbook/tests/other/test_ingredient_parser.py b/cookbook/tests/other/test_ingredient_parser.py index 90d5f0b7..d61cbc69 100644 --- a/cookbook/tests/other/test_ingredient_parser.py +++ b/cookbook/tests/other/test_ingredient_parser.py @@ -66,7 +66,9 @@ def test_ingredient_parser(): 1.0, 'Lorem', 'ipsum', 'dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut l Lorem ipsum dolor sit amet consetetur sadipscing elitr sed diam nonumy eirmod tempor invidunt ut l'), "1 LoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutlLoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutl": ( 1.0, None, 'LoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutlLoremipsumdolorsitametconsetetursadipscingeli', - 'LoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutlLoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutl') + 'LoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutlLoremipsumdolorsitametconsetetursadipscingelitrseddiamnonumyeirmodtemporinviduntutl'), + "砂糖 50g": (50, "g", "砂糖", ""), + "卵 4個": (4, "個", "卵", "") } # for German you could say that if an ingredient does not have From 38921f125424faff01078e6b62fca866a3311197 Mon Sep 17 00:00:00 2001 From: Cameron Grant Date: Thu, 11 Aug 2022 14:23:31 -0700 Subject: [PATCH 04/17] Updated time to use hours and minutes split --- vue/src/apps/RecipeView/RecipeView.vue | 10 +++++++--- vue/src/components/RecipeCard.vue | 10 +++++++--- vue/src/utils/utils.js | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue index 4968f0b4..16b22e5d 100644 --- a/vue/src/apps/RecipeView/RecipeView.vue +++ b/vue/src/apps/RecipeView/RecipeView.vue @@ -38,7 +38,7 @@
{{ $t("Preparation") }}
- {{ recipe.working_time }} {{ $t("min") }} + {{ working_time }}
@@ -50,7 +50,7 @@
{{ $t("Waiting") }}
- {{ recipe.waiting_time }} {{ $t("min") }} + {{ waiting_time }}
@@ -160,7 +160,7 @@ import "bootstrap-vue/dist/bootstrap-vue.css" import {apiLoadRecipe} from "@/utils/api" import RecipeContextMenu from "@/components/RecipeContextMenu" -import {ResolveUrlMixin, ToastMixin} from "@/utils/utils" +import {ResolveUrlMixin, ToastMixin, calculateHourMinuteSplit} from "@/utils/utils" import PdfViewer from "@/components/PdfViewer" import ImageViewer from "@/components/ImageViewer" @@ -206,6 +206,10 @@ export default { ingredient_count() { return this.recipe?.steps.map((x) => x.ingredients).flat().length }, + working_time: function() { + return calculateHourMinuteSplit(this.recipe.working_time)}, + waiting_time: function() { + return calculateHourMinuteSplit(this.recipe.waiting_time)}, }, data() { return { diff --git a/vue/src/components/RecipeCard.vue b/vue/src/components/RecipeCard.vue index 80cbcdb2..13a68a36 100755 --- a/vue/src/components/RecipeCard.vue +++ b/vue/src/components/RecipeCard.vue @@ -8,8 +8,8 @@
- {{ recipe.working_time }} {{ $t("min") }} - {{ recipe.waiting_time }} {{ $t("min") }} + {{ working_time }} + {{ waiting_time }}
@@ -59,7 +59,7 @@