From 488853f045b9699077a14a3994ff1e8844c0e1b4 Mon Sep 17 00:00:00 2001 From: Ewen Date: Fri, 22 Sep 2023 08:19:18 +0200 Subject: [PATCH] wip --- .../src/routes/ma_chaeliou/[id]/+page.svelte | 2 +- grids/models.py | 5 +++++ grids/utils.py | 20 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 grids/utils.py diff --git a/frontend/src/routes/ma_chaeliou/[id]/+page.svelte b/frontend/src/routes/ma_chaeliou/[id]/+page.svelte index ae0a204..3f8ed94 100644 --- a/frontend/src/routes/ma_chaeliou/[id]/+page.svelte +++ b/frontend/src/routes/ma_chaeliou/[id]/+page.svelte @@ -19,7 +19,7 @@ }, validationSchema: yup.object().shape({ width: yup.number().positive().moreThan(3), - heigt: yup.number().positive().moreThan(3), + height: yup.number().positive().moreThan(3), }), onSubmit: (values) => { submitPopulate(values); diff --git a/grids/models.py b/grids/models.py index a4ebe1a..3a813f1 100644 --- a/grids/models.py +++ b/grids/models.py @@ -1,4 +1,5 @@ from django.db import models +from .utils import split_word class Level(models.Model): @@ -70,3 +71,7 @@ class Placement(models.Model): default=Direction.RIGHT, choices=[(Direction.RIGHT, "Right"), (Direction.BOTTOM, "Bottom")], ) + + @property + def length(self): + return len(split_word(self)) diff --git a/grids/utils.py b/grids/utils.py new file mode 100644 index 0000000..745cd0c --- /dev/null +++ b/grids/utils.py @@ -0,0 +1,20 @@ +import re + + +def split_word(word): + if word == "": + return [] + else: + index_cscrabh = [match.start() for match in re.finditer("c'h", word.lower())] + print(index_cscrabh) + list_chars = [] + i = 0 + while i < len(word): + if i in index_cscrabh: + list_chars.append(word[i : i + 3]) + i += 3 + else: + list_chars.append(word[i]) + i += 1 + + return list_chars