Skip to content

fix: Consistent labels and help texts for page content model and page content forms #7968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions cms/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,36 +187,34 @@ class BasePageContentForm(forms.ModelForm):
_request = None

title = forms.CharField(
label=_("Title"),
label=PageContent._meta.get_field("title").verbose_name,
max_length=255,
widget=forms.TextInput(),
help_text=_("The default title"),
help_text=PageContent._meta.get_field("title").help_text,
)
slug = forms.SlugField(
label=_("Slug"),
max_length=255,
help_text=_("The part of the title that is used in the URL"),
)
menu_title = forms.CharField(
label=_("Menu Title"),
label=PageContent._meta.get_field("menu_title").verbose_name,
widget=forms.TextInput(),
help_text=_("Overwrite what is displayed in the menu"),
help_text=PageContent._meta.get_field("menu_title").help_text,
required=False,
)
page_title = forms.CharField(
label=_("Page Title"),
label=PageContent._meta.get_field("page_title").verbose_name,
widget=forms.TextInput(),
required=False,
help_text=_(
"Overwrites what is displayed at the top of your browser or in bookmarks"
),
help_text=PageContent._meta.get_field("page_title").help_text,
)
meta_description = forms.CharField(
label=_("Description meta tag"),
label=PageContent._meta.get_field("meta_description").verbose_name,
max_length=320,
required=False,
widget=forms.Textarea(attrs={"maxlength": "320", "rows": "4"}),
help_text=_("A description of the page used by search engines."),
help_text=PageContent._meta.get_field("meta_description").help_text,
)

class Meta:
Expand Down Expand Up @@ -522,14 +520,14 @@ class ChangePageForm(BasePageContentForm):
help_text=_("Keep this field empty if standard path should be used."),
)
soft_root = forms.BooleanField(
label=_("Soft root"),
label=PageContent._meta.get_field("soft_root").verbose_name,
required=False,
help_text=_("All ancestors will not be displayed in the navigation"),
help_text=PageContent._meta.get_field("soft_root").help_text,
)
redirect = PageSmartLinkField(
label=_("Redirect"),
label=PageContent._meta.get_field("redirect").verbose_name,
required=False,
help_text=_("Redirects to this URL."),
help_text=PageContent._meta.get_field("redirect").help_text,
placeholder_text=_("Start typing..."),
ajax_view="admin:cms_page_get_list",
)
Expand Down
6 changes: 3 additions & 3 deletions cms/migrations/0002_auto_20140816_1918.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
('language', models.CharField(db_index=True, max_length=15, verbose_name='language')),
('title', models.CharField(max_length=255, verbose_name='title')),
('page_title', models.CharField(max_length=255, null=True, help_text='overwrite the title (html title tag)', blank=True, verbose_name='title')),
('menu_title', models.CharField(max_length=255, null=True, help_text='overwrite the title in the menu', blank=True, verbose_name='title')),
('meta_description', models.TextField(max_length=155, null=True, help_text='The text displayed in search engines.', blank=True, verbose_name='description')),
('title', models.CharField(max_length=255, help_text='The default title', verbose_name='title')),
('page_title', models.CharField(max_length=255, null=True, help_text='Overwrites what is displayed at the top of your browser or in bookmarks', blank=True, verbose_name='Page Title')),
('menu_title', models.CharField(max_length=255, null=True, help_text='Overwrite what is displayed in the menu', blank=True, verbose_name='Menu Title')),
('slug', models.SlugField(max_length=255, verbose_name='slug')),
('path', models.CharField(db_index=True, max_length=255, verbose_name='Path')),
('has_url_overwrite', models.BooleanField(db_index=True, default=False, editable=False, verbose_name='has url overwrite')),
Expand Down
2 changes: 1 addition & 1 deletion cms/migrations/0008_auto_20150208_2149.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='title',
name='redirect',
field=models.CharField(max_length=2048, null=True, verbose_name='redirect', blank=True),
field=models.CharField(max_length=2048, null=True, help_text='Redirects to this URL.', verbose_name='redirect', blank=True),
preserve_default=True,
),
]
2 changes: 1 addition & 1 deletion cms/migrations/0021_auto_20180507_1432.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='title',
name='meta_description',
field=models.TextField(blank=True, help_text='The text displayed in search engines.', null=True, verbose_name='description'),
field=models.TextField(blank=True, help_text='A description of the page used by search engines.', null=True, verbose_name='Description meta tag'),
),
]
57 changes: 36 additions & 21 deletions cms/models/contentmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,39 @@ class PageContent(models.Model):
]

language = models.CharField(_("language"), max_length=15, db_index=True)
title = models.CharField(_("title"), max_length=255)
title = models.CharField(
verbose_name=_("title"),
max_length=255,
help_text=_("The default title"),
)
page_title = models.CharField(
_("title"),
verbose_name=_("Page Title"),
max_length=255,
blank=True,
null=True,
help_text=_("overwrite the title (html title tag)")
help_text=_(
"Overwrites what is displayed at the top of your browser or in bookmarks"
),
)
menu_title = models.CharField(
_("title"),
verbose_name=_("Menu Title"),
max_length=255,
blank=True,
null=True,
help_text=_("overwrite the title in the menu")
help_text=_("Overwrite what is displayed in the menu"),
)
meta_description = models.TextField(
_("description"),
verbose_name=_("Description meta tag"),
blank=True,
null=True,
help_text=_("The text displayed in search engines.")
help_text=_("A description of the page used by search engines."),
)
redirect = models.CharField(
_("redirect"),
verbose_name=_("redirect"),
max_length=2048,
blank=True,
null=True
null=True,
help_text=_("Redirects to this URL."),
)
page = models.ForeignKey(
Page,
Expand All @@ -73,43 +80,51 @@ class PageContent(models.Model):
related_name="pagecontent_set"
)
creation_date = models.DateTimeField(
_("creation date"),
verbose_name=_("creation date"),
editable=False,
default=timezone.now
)
# Placeholders (plugins)
placeholders = PlaceholderRelationField()

created_by = models.CharField(
_("created by"), max_length=constants.PAGE_USERNAME_MAX_LENGTH,
editable=False)
verbose_name=_("created by"),
max_length=constants.PAGE_USERNAME_MAX_LENGTH,
editable=False,
)
changed_by = models.CharField(
_("changed by"), max_length=constants.PAGE_USERNAME_MAX_LENGTH,
editable=False)
verbose_name=_("changed by"),
max_length=constants.PAGE_USERNAME_MAX_LENGTH,
editable=False,
)
changed_date = models.DateTimeField(auto_now=True)

in_navigation = models.BooleanField(_("in navigation"), default=True, db_index=True)
in_navigation = models.BooleanField(
verbose_name=_("in navigation"),
default=True,
db_index=True,
)
soft_root = models.BooleanField(
_("soft root"),
verbose_name=_("soft root"),
db_index=True,
default=False,
help_text=_("All ancestors will not be displayed in the navigation")
help_text=_("All ancestors will not be displayed in the navigation"),
)
template = models.CharField(
_("template"),
verbose_name=_("template"),
max_length=100,
choices=template_choices,
help_text=_('The template used to render the content.'),
default=TEMPLATE_DEFAULT
default=TEMPLATE_DEFAULT,
)
limit_visibility_in_menu = models.SmallIntegerField(
_("menu visibility"),
verbose_name=_("menu visibility"),
default=constants.VISIBILITY_ALL,
choices=LIMIT_VISIBILITY_IN_MENU_CHOICES,
db_index=True,
blank=True,
null=True,
help_text=_("limit when this page is visible in the menu")
help_text=_("limit when this page is visible in the menu"),
)

# X Frame Options for clickjacking protection
Expand Down
Loading