Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Help texts, labels

Pacu2488998063e27
diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.py
index a36d786ff8..01683fe9ca 100644
--- a/saleor/dashboard/category/forms.py
+++ b/saleor/dashboard/category/forms.py
@@ -5,6 +5,7 @@ from django.utils.translation import pgettext_lazy
from text_unidecode import unidecode
from ...product.models import Category
+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELS
class CategoryForm(forms.ModelForm):
@@ -32,7 +33,9 @@ class CategoryForm(forms.ModelForm):
'Name'),
'description': pgettext_lazy(
'Description',
- 'Description')}
+ 'Description'),
+ **SEO_LABELS}
+ help_texts = SEO_HELP_TEXTS
def save(self, commit=True):
self.instance.slug = slugify(unidecode(self.instance.name))
diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.py
index c7f0fba890..d577c55332 100644
--- a/saleor/dashboard/collection/forms.py
+++ b/saleor/dashboard/collection/forms.py
@@ -7,6 +7,7 @@ from text_unidecode import unidecode
from ...product.models import Collection, Product
from ..forms import AjaxSelect2MultipleChoiceField
from ..widgets import CharsLeftWidget
+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELS
class CollectionForm(forms.ModelForm):
@@ -26,15 +27,12 @@ class CollectionForm(forms.ModelForm):
'Products'),
'background_image': pgettext_lazy(
'Products selection',
- 'Background Image')}
+ 'Background Image'),
+ **SEO_LABELS}
widgets = {
'seo_description': CharsLeftWidget,
'seo_title': CharsLeftWidget}
- help_texts = {
- 'seo_description': pgettext_lazy(
- 'Form field help text',
- 'Slug is being used to create page URL'),
- 'seo_title': 'Example help text'}
+ help_texts = SEO_HELP_TEXTS
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -48,8 +46,8 @@ class CollectionForm(forms.ModelForm):
self.fields['seo_title'].widget.attrs.update({
'id': 'seo_title',
'data-bind': self['name'].auto_id,
- 'placeholder': self.instance.name,
- 'min-recommended-length': 40})
+ 'placeholder': self.instance.name[:70],
+ 'min-recommended-length': 25})
def save(self, commit=True):
self.instance.slug = slugify(unidecode(self.instance.name))
diff --git a/saleor/dashboard/page/forms.py b/saleor/dashboard/page/forms.py
index 09a8fd25c9..e52a9b5006 100644
--- a/saleor/dashboard/page/forms.py
+++ b/saleor/dashboard/page/forms.py
@@ -4,6 +4,7 @@ from django.utils.translation import pgettext_lazy
from ...core.utils.text import generate_seo_description
from ...page.models import Page
from ..product.forms import RichTextField
+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELS
class PageForm(forms.ModelForm):
@@ -32,11 +33,13 @@ class PageForm(forms.ModelForm):
'slug': forms.TextInput(attrs={'placeholder': 'example-slug'})}
labels = {
'is_visible': pgettext_lazy(
- 'Visibility status indicator', 'Publish')}
+ 'Visibility status indicator', 'Publish'),
+ **SEO_LABELS}
help_texts = {
'slug': pgettext_lazy(
'Form field help text',
- 'Slug is being used to create page URL')}
+ 'Slug is being used to create page URL'),
+ **SEO_HELP_TEXTS}
content = RichTextField()
diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.py
index f35a20d9cf..04e2bbe4f8 100644
--- a/saleor/dashboard/product/forms.py
+++ b/saleor/dashboard/product/forms.py
@@ -18,6 +18,7 @@ from ..forms import OrderedModelMultipleChoiceField, ModelChoiceOrCreationField
from ..widgets import RichTextEditorWidget
from .widgets import ImagePreviewWidget
from . import ProductBulkAction
+from ..seo.utils import SEO_HELP_TEXTS, SEO_LABELS
class RichTextField(forms.CharField):
@@ -201,7 +202,9 @@ class ProductForm(forms.ModelForm, AttributesMixin):
'is_featured': pgettext_lazy(
'Featured product toggle', 'Feature this product on homepage'),
'collections': pgettext_lazy(
- 'Add to collection select', 'Collections')}
+ 'Add to collection select', 'Collections'),
+ **SEO_LABELS}
+ help_texts = SEO_HELP_TEXTS
category = TreeNodeChoiceField(queryset=Category.objects.all())
collections = forms.ModelMultipleChoiceField(
diff --git a/saleor/static/dashboard/js/components/google-preview.js b/saleor/static/dashboard/js/components/google-preview.js
index de246b5217..3fc786bb79 100644
--- a/saleor/static/dashboard/js/components/google-preview.js
+++ b/saleor/static/dashboard/js/components/google-preview.js
@@ -31,7 +31,7 @@ function updateCharsCount(field) {
if ($fieldLength < $minRecommendedLength) {
$charCountWrapper.addClass('red-text');
$charCountWrapper.removeClass('green-text');
- } else if ($charCountWrapper.hasClass('red-text')) {
+ } else {
$charCountWrapper.removeClass('red-text');
$charCountWrapper.addClass('green-text');
}
diff --git a/templates/materializecssform/field.html b/templates/materializecssform/field.html
index b6b5a5354b..bac8d7b657 100644
--- a/templates/materializecssform/field.html
+++ b/templates/materializecssform/field.html
@@ -345,7 +345,7 @@
</label>
<span class="chars-left__count">
<span class="chars-left__count__current" data-bind="{{ field.field.widget.attrs.id }}">
- {% blocktrans with current_chars_count=field.value|length max_chars_count=field.field.max_length %}
+ {% blocktrans with current_chars_count=field.value|length max_chars_count=field.field.max_length context "Message showing how many chars were used out of maximum field's length" %}
{{ current_chars_count }}</span> of {{ max_chars_count }} characters used
{% endblocktrans %}
</span>