Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Remove is featured field
oldPadavan58a7c7d44f81
diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.pyindex 519ec15a00..8186ce18ba 100644--- a/saleor/core/management/commands/populatedb.py+++ b/saleor/core/management/commands/populatedb.py@@ -8,7 +8,7 @@ from ...utils.random_data import (add_address_to_admin, create_collections_by_schema, create_menus,create_orders, create_page, create_product_sales,create_products_by_schema, create_shipping_methods, create_users,- create_vouchers, set_featured_products)+ create_vouchers, set_homepage_collection)class Command(BaseCommand):@@ -65,10 +65,10 @@ class Command(BaseCommand):self.stdout.write(msg)for msg in create_orders(20):self.stdout.write(msg)- for msg in set_featured_products(16):- self.stdout.write(msg)for msg in create_collections_by_schema(self.placeholders_dir):self.stdout.write(msg)+ for msg in set_homepage_collection():+ self.stdout.write(msg)for msg in create_page():self.stdout.write(msg)for msg in create_menus():diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex e68e911de0..10644e49ec 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -540,10 +540,13 @@ def create_vouchers():yield 'Value voucher already exists'-def set_featured_products(how_many=8):- pks = Product.objects.order_by('?')[:how_many].values_list('pk', flat=True)- Product.objects.filter(pk__in=pks).update(is_featured=True)- yield 'Featured products created'+def set_homepage_collection():+ homepage_collection = Collection.objects.order_by('?').first()+ site = Site.objects.get_current()+ site_settings = site.settings+ site_settings.homepage_collection = homepage_collection+ site_settings.save()+ yield 'Homepage collection assigned'def add_address_to_admin(email):diff --git a/saleor/dashboard/product/filters.py b/saleor/dashboard/product/filters.pyindex b80f3c70b3..dc8e8cf84e 100644--- a/saleor/dashboard/product/filters.py+++ b/saleor/dashboard/product/filters.py@@ -22,10 +22,6 @@ PUBLISHED_CHOICES = (('1', pgettext_lazy('Is publish filter choice', 'Published')),('0', pgettext_lazy('Is publish filter choice', 'Not published')))-FEATURED_CHOICES = (- ('1', pgettext_lazy('Is featured filter choice', 'Featured')),- ('0', pgettext_lazy('Is featured filter choice', 'Not featured')))-class ProductFilter(SortedFilterSet):name = CharFilter(@@ -48,12 +44,6 @@ class ProductFilter(SortedFilterSet):choices=PUBLISHED_CHOICES,empty_label=pgettext_lazy('Filter empty choice label', 'All'),widget=forms.Select)- is_featured = ChoiceFilter(- label=pgettext_lazy(- 'Product list is featured filter label', 'Is featured'),- choices=FEATURED_CHOICES,- empty_label=pgettext_lazy('Filter empty choice label', 'All'),- widget=forms.Select)sort_by = OrderingFilter(label=pgettext_lazy('Product list filter label', 'Sort by'),fields=PRODUCT_SORT_BY_FIELDS.keys(),diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 2e0be3d6f3..d406c0296e 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -220,9 +220,6 @@ class ProductForm(forms.ModelForm, AttributesMixin):'Availability date', 'Publish product on'),'is_published': pgettext_lazy('Product published toggle', 'Published'),- 'is_featured': pgettext_lazy(- 'Featured product toggle',- 'Feature this product on homepage'),'charge_taxes': pgettext_lazy('Charge taxes on product', 'Charge taxes on this product')}diff --git a/saleor/graphql/product/filters.py b/saleor/graphql/product/filters.pyindex de3917258c..94c1b777bc 100644--- a/saleor/graphql/product/filters.py+++ b/saleor/graphql/product/filters.py@@ -63,8 +63,7 @@ class ProductFilterSet(DistinctFilterSet):'attributes': ['exact'],'name': ['exact', 'icontains'],'product_type__name': ['exact'],- 'is_published': ['exact'],- 'is_featured': ['exact']}+ 'is_published': ['exact']}@classmethoddef filter_for_field(cls, f, field_name, lookup_expr='exact'):diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex ad5b080181..9ba7307de3 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -199,8 +199,6 @@ class ProductInput(graphene.InputObjectType):description = graphene.String(description='Product description.')is_published = graphene.Boolean(description='Determines if product is visible to customers.')- is_featured = graphene.Boolean(- description='Determines if product is featured in the storefront.')name = graphene.String(description='Product name.')product_type = graphene.ID(description='ID of the type that product belongs to.')diff --git a/saleor/product/migrations/0067_remove_product_is_featured.py b/saleor/product/migrations/0067_remove_product_is_featured.pynew file mode 100644index 0000000000..b0088ad109--- /dev/null+++ b/saleor/product/migrations/0067_remove_product_is_featured.py@@ -0,0 +1,18 @@+# Generated by Django 2.0.3 on 2018-08-08 09:51++from django.db import migrations+++class Migration(migrations.Migration):++ dependencies = [+ ('product', '0066_auto_20180803_0528'),+ ('site', '0018_sitesettings_homepage_collection'),+ ]++ operations = [+ migrations.RemoveField(+ model_name='product',+ name='is_featured',+ ),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex 54487258d3..c5ee1e63f0 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -113,7 +113,6 @@ class Product(SeoModel):is_published = models.BooleanField(default=True)attributes = HStoreField(default={}, blank=True)updated_at = models.DateTimeField(auto_now=True, null=True)- is_featured = models.BooleanField(default=False)charge_taxes = models.BooleanField(default=True)tax_rate = models.CharField(max_length=128, default=DEFAULT_TAX_RATE_NAME, blank=True)diff --git a/saleor/site/migrations/0018_sitesettings_homepage_collection.py b/saleor/site/migrations/0018_sitesettings_homepage_collection.pyindex 29d00baeb1..64280f6926 100644--- a/saleor/site/migrations/0018_sitesettings_homepage_collection.py+++ b/saleor/site/migrations/0018_sitesettings_homepage_collection.py@@ -13,19 +13,21 @@ def copy_featured_products_to_homepade_collection(apps, schema_editor):Collection = apps.get_model('product', 'Collection')Product = apps.get_model('product', 'Product')- homepage_collection = Collection(name='Homepage collection for migration')- homepage_collection.slug = slugify(homepage_collection.name)- homepage_collection.save()today = datetime.date.today()- homepage_collection.products.add(- *list(- Product.objects.filter(- Q(available_on__lte=today) | Q(available_on__isnull=True),- Q(is_published=True, is_featured=True))))-- for site_setting in SiteSettings.objects.all():- site_setting.homepage_collection = homepage_collection- site_setting.save()+ homepage_products = list(+ Product.objects.filter(+ Q(available_on__lte=today) | Q(available_on__isnull=True),+ is_published=True, is_featured=True))+ if homepage_products:+ homepage_collection = Collection(+ name='Homepage collection for migration')+ homepage_collection.slug = slugify(homepage_collection.name)+ homepage_collection.save()+ homepage_collection.products.add(*homepage_products)++ for site_setting in SiteSettings.objects.all():+ site_setting.homepage_collection = homepage_collection+ site_setting.save()class Migration(migrations.Migration):diff --git a/templates/dashboard/product/form.html b/templates/dashboard/product/form.htmlindex bb47b70a9d..f652c21c91 100644--- a/templates/dashboard/product/form.html+++ b/templates/dashboard/product/form.html@@ -107,9 +107,6 @@<div class="row">{{ product_form.collections|materializecss }}</div>- <div class="row is_featured_checkbox">- {{ product_form.is_featured|materializecss }}- </div><span class="card-title">{% trans "Attributes" %}</span><br><h6>