Skip to content

Commit

Permalink
Merge pull request #290 from BlackCubes/development
Browse files Browse the repository at this point in the history
Development to Main (`v3.0.8`)
  • Loading branch information
BlackCubes authored Jun 29, 2022
2 parents 5fc49d1 + 6ba4ac4 commit 06d73f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
18 changes: 18 additions & 0 deletions api/article/migrations/0013_alter_articlepage_description.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
7 changes: 5 additions & 2 deletions api/article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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()
Expand All @@ -200,7 +203,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
)
Expand Down
5 changes: 4 additions & 1 deletion api/work/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -184,7 +187,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
)
Expand Down

0 comments on commit 06d73f8

Please sign in to comment.