From cfa00757d8304212e1caaebb7e8d8fc55146d9b1 Mon Sep 17 00:00:00 2001 From: Elias Gutierrez Date: Wed, 29 Jun 2022 12:10:59 -0700 Subject: [PATCH 1/6] fix(article-models): add extra conditional This was done so that the slug would not autogenerate a new one if the slug already exists in the current updated data, or if the user wants to provide their own slug --- api/article/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/article/models.py b/api/article/models.py index a0a91ff8..bdf781ba 100644 --- a/api/article/models.py +++ b/api/article/models.py @@ -200,7 +200,7 @@ def clean(self): title = cleaned_data.get("title", None) slug = cleaned_data.get("slug", None) - if title: + if title and not slug: cleaned_data["slug"] = unique_slug_generator( instance=self.instance, new_slug=slug ) From 6f860b27a333838b309452a2fcf4260a98656082 Mon Sep 17 00:00:00 2001 From: Elias Gutierrez Date: Wed, 29 Jun 2022 12:20:23 -0700 Subject: [PATCH 2/6] fix(work-models): add extra conditional This was done so that the slug would not autogenerate a new one if the slug already exists in the current updated data, or if the user wants to provide their own slug --- api/work/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/work/models.py b/api/work/models.py index 25cf2240..c8c7ace1 100644 --- a/api/work/models.py +++ b/api/work/models.py @@ -184,7 +184,7 @@ def clean(self): title = cleaned_data.get("title", None) slug = cleaned_data.get("slug", None) - if title: + if title and not slug: cleaned_data["slug"] = unique_slug_generator( instance=self.instance, new_slug=slug ) From bdea75dc35d81c11a93c937fa070948635467f22 Mon Sep 17 00:00:00 2001 From: Elias Gutierrez Date: Wed, 29 Jun 2022 12:25:37 -0700 Subject: [PATCH 3/6] docs(work-models): add extra docs --- api/work/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/work/models.py b/api/work/models.py index c8c7ace1..353d04a7 100644 --- a/api/work/models.py +++ b/api/work/models.py @@ -176,6 +176,9 @@ def clean(self): A custom function to override the ``WagtailAdminModelForm`` ``clean`` function so that the ``slug`` field could be created uniquely if it exists in the DB. + + If the user provides a slug whether it is updated or newly created, then + the slug would not autogenerate. """ cleaned_data = super(WagtailAdminModelForm, self).clean() From 85ddfdcffe02f1eba93cc559d4983377beb92459 Mon Sep 17 00:00:00 2001 From: Elias Gutierrez Date: Wed, 29 Jun 2022 12:26:15 -0700 Subject: [PATCH 4/6] docs(article-models): add extra docs --- api/article/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/article/models.py b/api/article/models.py index bdf781ba..82a02f40 100644 --- a/api/article/models.py +++ b/api/article/models.py @@ -192,6 +192,9 @@ def clean(self): """ A custom function to override the ``WagtailAdminModelForm`` ``clean`` function so that the ``slug`` field could be created uniquely if it exists in the DB. + + If the user provides a slug whether it is updated or newly created, then + the slug would not autogenerate. """ cleaned_data = super(WagtailAdminModelForm, self).clean() From b5effe89c7c83271da23e96a9176f79277f4a6ac Mon Sep 17 00:00:00 2001 From: Elias Gutierrez Date: Wed, 29 Jun 2022 13:07:25 -0700 Subject: [PATCH 5/6] fix(article-models): extend 'max_length' for 'description' --- api/article/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/article/models.py b/api/article/models.py index 82a02f40..62d8e3e3 100644 --- a/api/article/models.py +++ b/api/article/models.py @@ -108,7 +108,7 @@ class ArticlePage(Page): """ uuid = models.UUIDField(unique=True, default=uuid4, editable=False) - description = models.CharField(max_length=100) + description = models.CharField(max_length=250) header_image = models.ForeignKey( "wagtailimages.Image", blank=True, null=True, on_delete=models.SET_NULL ) From 3ff513c8e72eaf2343f9e21a4e196830e3b0de61 Mon Sep 17 00:00:00 2001 From: Elias Gutierrez Date: Wed, 29 Jun 2022 13:09:59 -0700 Subject: [PATCH 6/6] feat(article-migrations): make migrations --- .../0013_alter_articlepage_description.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 api/article/migrations/0013_alter_articlepage_description.py diff --git a/api/article/migrations/0013_alter_articlepage_description.py b/api/article/migrations/0013_alter_articlepage_description.py new file mode 100644 index 00000000..957324ff --- /dev/null +++ b/api/article/migrations/0013_alter_articlepage_description.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.2 on 2022-06-29 20:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('article', '0012_remove_articlepage_search_image'), + ] + + operations = [ + migrations.AlterField( + model_name='articlepage', + name='description', + field=models.CharField(max_length=250), + ), + ]