From 120a741a7d00328cdeabd946591117cb76d24007 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Fri, 26 Jul 2024 16:51:18 +0200 Subject: [PATCH] Fix: Consistent labels and help texts for page content model and page content forms --- cms/admin/forms.py | 26 +++++------ cms/migrations/0002_auto_20140816_1918.py | 6 +-- cms/migrations/0008_auto_20150208_2149.py | 2 +- cms/migrations/0021_auto_20180507_1432.py | 2 +- cms/models/contentmodels.py | 57 ++++++++++++++--------- 5 files changed, 53 insertions(+), 40 deletions(-) diff --git a/cms/admin/forms.py b/cms/admin/forms.py index 7db9c286fb0..a8e42e5bac1 100644 --- a/cms/admin/forms.py +++ b/cms/admin/forms.py @@ -187,10 +187,10 @@ 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"), @@ -198,25 +198,23 @@ class BasePageContentForm(forms.ModelForm): 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: @@ -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", ) diff --git a/cms/migrations/0002_auto_20140816_1918.py b/cms/migrations/0002_auto_20140816_1918.py index 81b74ac8a45..6508328d203 100644 --- a/cms/migrations/0002_auto_20140816_1918.py +++ b/cms/migrations/0002_auto_20140816_1918.py @@ -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')), diff --git a/cms/migrations/0008_auto_20150208_2149.py b/cms/migrations/0008_auto_20150208_2149.py index b5a7c595f2c..1aaeabb9f89 100644 --- a/cms/migrations/0008_auto_20150208_2149.py +++ b/cms/migrations/0008_auto_20150208_2149.py @@ -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, ), ] diff --git a/cms/migrations/0021_auto_20180507_1432.py b/cms/migrations/0021_auto_20180507_1432.py index d99636f8f6c..5dae355e8e2 100644 --- a/cms/migrations/0021_auto_20180507_1432.py +++ b/cms/migrations/0021_auto_20180507_1432.py @@ -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'), ), ] diff --git a/cms/models/contentmodels.py b/cms/models/contentmodels.py index 4f0d3b5f1e3..b8d6dff8961 100644 --- a/cms/models/contentmodels.py +++ b/cms/models/contentmodels.py @@ -38,32 +38,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, @@ -72,7 +79,7 @@ class PageContent(models.Model): related_name="pagecontent_set" ) creation_date = models.DateTimeField( - _("creation date"), + verbose_name=_("creation date"), editable=False, default=timezone.now ) @@ -80,35 +87,43 @@ class PageContent(models.Model): 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