From b7c939339ff0a88a9477f4373423fe2881b3eb3e Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Sat, 11 Apr 2020 22:53:02 +0200 Subject: [PATCH 1/7] update docstrings --- shop/deferred.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shop/deferred.py b/shop/deferred.py index 968be93bd..9bd267128 100644 --- a/shop/deferred.py +++ b/shop/deferred.py @@ -70,12 +70,11 @@ class ForeignKeyBuilder(ModelBase): """ In Django we can not point a ``OneToOneField``, ``ForeignKey`` or ``ManyToManyField`` onto an abstract Model class. In Django-SHOP this limitation is circumvented by creating deferred - foreign keys, which are mapped to their correct model's counterpart during the model materialization - step. + foreign keys, which are mapped to their correct model's counterpart during the model + materialization step. If the main application stores its models in its own directory, add to settings.py: - SHOP_APP_LABEL = 'myshop' - so that the models are created inside your own shop instantiation. + SHOP_APP_LABEL = 'myshop', so that the models are created inside your own shop instantiation. """ _model_allocation = {} _pending_mappings = [] From af54842fbc6501d87db7dafc96bf46e3c348f1da Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Sun, 12 Apr 2020 01:08:49 +0200 Subject: [PATCH 2/7] Fix: Ordered Items not rendered in Django admin This bus has been reported here: https://github.com/awesto/cookiecutter-django-shop/issues/27 --- .../shop/admin/edit_inline/stacked-order.html | 27 ++++++++----------- .../shop/admin/includes/fieldset.html | 12 ++++----- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/shop/templates/shop/admin/edit_inline/stacked-order.html b/shop/templates/shop/admin/edit_inline/stacked-order.html index 8fd51d478..37a8d00b9 100644 --- a/shop/templates/shop/admin/edit_inline/stacked-order.html +++ b/shop/templates/shop/admin/edit_inline/stacked-order.html @@ -1,30 +1,25 @@ -{% load i18n admin_urls admin_static %} -
+{% load i18n admin_urls static %} +
+

{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}

{{ inline_admin_formset.formset.management_form }} {{ inline_admin_formset.formset.non_form_errors }} -{% for inline_admin_form in inline_admin_formset %}
-

{{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% trans "Change" %}{% endif %} +{% for inline_admin_form in inline_admin_formset %}
+

{{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% if inline_admin_formset.has_change_permission %}{% trans "Change" %}{% else %}{% trans "View" %}{% endif %}{% endif %} {% else %}#{{ forloop.counter }}{% endif %} {% if inline_admin_form.show_url %}{% trans "View on site" %}{% endif %} - {% if inline_admin_formset.formset.can_delete and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %} + {% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %}

{% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %} {% for fieldset in inline_admin_form %} {% include "shop/admin/includes/fieldset.html" %} {% endfor %} {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %} - {{ inline_admin_form.fk_field.field }} + {% if inline_admin_form.fk_field %}{{ inline_admin_form.fk_field.field }}{% endif %}
{% endfor %} +

- - diff --git a/shop/templates/shop/admin/includes/fieldset.html b/shop/templates/shop/admin/includes/fieldset.html index 836854cc6..941587200 100644 --- a/shop/templates/shop/admin/includes/fieldset.html +++ b/shop/templates/shop/admin/includes/fieldset.html @@ -7,30 +7,28 @@
{% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %} {% for field in line %} - + {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %} {% if field.is_checkbox %} {{ field.field }}{{ field.label_tag }} {% elif field.field.name|truncatechars:18 == 'render_as_html_...' %} {{ field.label_tag }} - {% with field.contents as contents %} - {% if contents %} + {% with field.contents as contents %}{% if contents %}

 

{{ contents }} {% else %}

- {% endif %} - {% endwith %} + {% endif %}{% endwith %} {% else %} {{ field.label_tag }} {% if field.is_readonly %} -

{{ field.contents }}

+
{{ field.contents }}
{% else %} {{ field.field }} {% endif %} {% endif %} {% if field.field.help_text %} -

{{ field.field.help_text|safe }}

+
{{ field.field.help_text|safe }}
{% endif %}
{% endfor %} From 310b6ccc88111793acf76b837b368b0262038a0b Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Sun, 12 Apr 2020 18:04:29 +0200 Subject: [PATCH 3/7] Bump to version 1.1.2 --- docs/changelog.rst | 7 +++++++ shop/__init__.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 125806f30..31fa5ad93 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,13 @@ Changelog for django-SHOP ========================= +1.1.2 +===== +* Fix #802: ``CartItemSerializer`` raised an exception if field ``CartItem.extra`` was handled by + Django's internal Postgres ``JSONField``. +* Fix: In Django>2, rendering of OrderItem in Inline Admin did not work anymore. + + 1.1.1 ===== * Fix: Rendering text for full text index raised an exception. diff --git a/shop/__init__.py b/shop/__init__.py index 0a6bbcbb4..78ac06dea 100644 --- a/shop/__init__.py +++ b/shop/__init__.py @@ -17,6 +17,6 @@ 11. git commit -m 'Start with ' 12. git push """ -__version__ = '1.1.1' +__version__ = '1.1.2' default_app_config = 'shop.apps.ShopConfig' From 51137e8bb924706a4a5711829c73fcd43e1f5821 Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Mon, 13 Apr 2020 22:46:41 +0200 Subject: [PATCH 4/7] add South African Rand to currencies --- shop/money/iso4217.py | 1 + 1 file changed, 1 insertion(+) diff --git a/shop/money/iso4217.py b/shop/money/iso4217.py index 554a27b3b..ef478f2fd 100644 --- a/shop/money/iso4217.py +++ b/shop/money/iso4217.py @@ -34,5 +34,6 @@ 'UAH': ('980', 2, '₴', _("Ukrainian Hryvnia")), 'USD': ('840', 2, '$', _("US Dollar")), 'SEK': ('752', 2, 'kr', _("Swedish Kronor")), + 'ZAR': ('710', 2, 'R', _("South African Rand")), # feel free to add more currencies, alphabetically ordered } From 95e5b3af08de6ce5539af2afebbe4a9650ad965f Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Mon, 13 Apr 2020 22:48:53 +0200 Subject: [PATCH 5/7] Bump to version 1.1.3 --- docs/changelog.rst | 5 +++++ shop/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 31fa5ad93..e2a9863b2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,11 @@ Changelog for django-SHOP ========================= +1.1.3 +===== +* Add South African Rand to currencies. + + 1.1.2 ===== * Fix #802: ``CartItemSerializer`` raised an exception if field ``CartItem.extra`` was handled by diff --git a/shop/__init__.py b/shop/__init__.py index 78ac06dea..9f9f5b53e 100644 --- a/shop/__init__.py +++ b/shop/__init__.py @@ -17,6 +17,6 @@ 11. git commit -m 'Start with ' 12. git push """ -__version__ = '1.1.2' +__version__ = '1.1.3' default_app_config = 'shop.apps.ShopConfig' From 63f855a832390a4d332d1ee994ab23ed546711fc Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Thu, 30 Apr 2020 01:25:20 +0200 Subject: [PATCH 6/7] fix #808: Product gallery product not JSON serializable --- shop/cascade/catalog.py | 43 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/shop/cascade/catalog.py b/shop/cascade/catalog.py index 4c9eaaaa2..85aa10a47 100644 --- a/shop/cascade/catalog.py +++ b/shop/cascade/catalog.py @@ -1,13 +1,15 @@ from django.contrib.admin import StackedInline from django.forms import fields, widgets -from django.forms.models import ModelForm from django.template.loader import select_template from django.utils.translation import ugettext_lazy as _, ugettext -from entangled.forms import EntangledModelFormMixin + +from entangled.forms import EntangledModelFormMixin, EntangledModelForm + from cms.plugin_pool import plugin_pool from cms.utils.compat.dj import is_installed from cmsplugin_cascade.mixins import WithSortableInlineElementsMixin from cmsplugin_cascade.models import SortableInlineCascadeElement + from shop.cascade.plugin_base import ShopPluginBase, ProductSelectField from shop.conf import app_settings from shop.models.product import ProductModel @@ -109,7 +111,12 @@ def render(self, context, instance, placeholder): plugin_pool.register_plugin(ShopAddToCartPlugin) -class ProductGalleryForm(ModelForm): +class ProductGalleryForm(EntangledModelForm): + order = fields.IntegerField( + widget=widgets.HiddenInput, + initial=0, + ) + product = ProductSelectField( required=False, label=_("Related Product"), @@ -117,38 +124,12 @@ class ProductGalleryForm(ModelForm): ) class Meta: - exclude = ['glossary'] - - def __init__(self, *args, **kwargs): - try: - initial = dict(kwargs['instance'].glossary) - except (KeyError, AttributeError): - initial = {} - initial.update(kwargs.pop('initial', {})) - try: - self.base_fields['product'].initial = initial['product']['pk'] - except KeyError: - self.base_fields['product'].initial = None - if not is_installed('adminsortable2'): - self.base_fields['order'].widget = widgets.HiddenInput() - self.base_fields['order'].initial = 0 - super(ProductGalleryForm, self).__init__(*args, **kwargs) - - def clean(self): - cleaned_data = super(ProductGalleryForm, self).clean() - if self.is_valid(): - product_pk = self.cleaned_data.pop('product', None) - if product_pk: - product_data = {'pk': product_pk} - self.instance.glossary.update(product=product_data) - else: - self.instance.glossary.pop('image', None) - return cleaned_data + entangled_fields = {'glossary': ['product']} + untangled_fields = ['order'] class ProductGalleryInline(SortableInlineAdminMixin, StackedInline): model = SortableInlineCascadeElement - raw_id_fields = ['product'] form = ProductGalleryForm extra = 5 ordering = ['order'] From 98ae22b377e16da6eab694684de37e7df56cdfe3 Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Thu, 30 Apr 2020 10:19:45 +0200 Subject: [PATCH 7/7] Bump to version 1.1.4 --- docs/changelog.rst | 5 +++++ shop/__init__.py | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e2a9863b2..c0cc6e921 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,11 @@ Changelog for django-SHOP ========================= +1.1.4 +===== +* Fix rendering bug in Product Gallery plugin. + + 1.1.3 ===== * Add South African Rand to currencies. diff --git a/shop/__init__.py b/shop/__init__.py index 9f9f5b53e..b6469e67d 100644 --- a/shop/__init__.py +++ b/shop/__init__.py @@ -4,19 +4,17 @@ See PEP 386 (http://www.python.org/dev/peps/pep-0386/) Release logic: - 1. Remove ".dev" from __version__ (below) - 2. git add shop/__init__.py - 3. git commit -m 'Bump to ' - 4. git tag + 1. Increase version number in __version__ (below) + 2. Check that all changes have been documented in docs/changelog.rst + 3. git add shop/__init__.py docs/changelog.rst + 4. git commit -m 'Bump to {new version}' 5. git push 6. assure that all tests pass on https://travis-ci.org/awesto/django-shop - 7. git push --tags - 8. python setup.py sdist upload - 9. bump the version, append ".dev" to __version__ -10. git add shop/__init__.py -11. git commit -m 'Start with ' -12. git push + 7. git tag {new version} + 8. git push --tags + 8. python setup.py sdist +10. twine upload dist/django-shop-{new version}.tar.gz """ -__version__ = '1.1.3' +__version__ = '1.1.4' default_app_config = 'shop.apps.ShopConfig'