Skip to content

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

Add collection description to random data

fowczarekf99ef05580f5
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py
index 5b2ed0bf96..af3dbce0c0 100644
--- a/saleor/core/utils/random_data.py
+++ b/saleor/core/utils/random_data.py
@@ -49,10 +49,12 @@ GROCERIES_CATEGORY = {'name': 'Groceries', 'image_name': 'groceries.jpg'}
COLLECTIONS_SCHEMA = [
{
'name': 'Summer collection',
- 'image_name': 'summer.jpg'},
+ 'image_name': 'summer.jpg',
+ 'description': 'Description of a summer collection.'},
{
'name': 'Winter sale',
- 'image_name': 'clothing.jpg'}]
+ 'image_name': 'clothing.jpg',
+ 'description': 'Description of a winter sale.'}]
IMAGES_MAPPING = {
61: ['saleordemoproduct_paints_01.png'],
@@ -239,11 +241,12 @@ def get_email(first_name, last_name):
_first.lower().decode('utf-8'), _last.lower().decode('utf-8'))
-def get_or_create_collection(name, placeholder_dir, image_name):
+def get_or_create_collection(name, placeholder_dir, image_name, description):
background_image = get_image(placeholder_dir, image_name)
defaults = {
'slug': fake.slug(name),
- 'background_image': background_image}
+ 'background_image': background_image,
+ 'description': description}
return Collection.objects.get_or_create(name=name, defaults=defaults)[0]
@@ -528,7 +531,8 @@ def create_fake_collection(placeholder_dir, collection_data):
image_dir = get_product_list_images_dir(placeholder_dir)
collection = get_or_create_collection(
name=collection_data['name'], placeholder_dir=image_dir,
- image_name=collection_data['image_name'])
+ image_name=collection_data['image_name'],
+ description=collection_data['description'])
products = Product.objects.order_by('?')[:4]
collection.products.add(*products)
create_collection_background_image_thumbnails.delay(collection.pk)
diff --git a/saleor/dashboard/collection/forms.py b/saleor/dashboard/collection/forms.py
index 149e2cfde1..67dd0893bd 100644
--- a/saleor/dashboard/collection/forms.py
+++ b/saleor/dashboard/collection/forms.py
@@ -23,13 +23,13 @@ class CollectionForm(forms.ModelForm):
labels = {
'name': pgettext_lazy('Item name', 'Name'),
'background_image': pgettext_lazy(
- 'Background Image of collection',
- 'Background Image'),
+ 'Background image of a collection',
+ 'Background image'),
'is_published': pgettext_lazy(
'Collection published toggle',
'Published'),
'description': pgettext_lazy(
- 'Description of collection',
+ 'Description field of a collection',
'Description')}
def __init__(self, *args, **kwargs):
diff --git a/saleor/product/models.py b/saleor/product/models.py
index c92aee6ba0..6084f9b7e7 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -3,8 +3,7 @@ from decimal import Decimal
from django.conf import settings
from django.contrib.postgres.fields import HStoreField
-from django.core.exceptions import ValidationError
-from django.core.validators import MaxLengthValidator, MinValueValidator
+from django.core.validators import MinValueValidator
from django.db import models
from django.db.models import Q
from django.urls import reverse