Skip to content

Commit

Permalink
Merge pull request #1522 from tulimaki/various-fixes
Browse files Browse the repository at this point in the history
 Hotfix: fix cache signal handler when called through m2m
  • Loading branch information
chessbr committed Sep 19, 2018
2 parents e61d36b + 06a0cf9 commit f31ea2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions shuup/core/signal_handers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from django.db.backends.signals import connection_created
from django.db.models.signals import m2m_changed, post_save

from shuup.core.models import Product, ShopProduct, Tax, TaxClass
from shuup.core.models import (
Category, Product, ShopProduct, Tax, TaxClass
)
from shuup.core.utils.context_cache import (
bump_product_signal_handler, bump_shop_product_signal_handler
)
Expand All @@ -33,8 +35,13 @@ def handle_product_post_save(sender, instance, **kwargs):


def handle_shop_product_post_save(sender, instance, **kwargs):
bump_shop_product_signal_handler(sender, instance, **kwargs)
bump_prices_for_shop_product(instance)
if isinstance(instance, Category):
for shop_product in instance.shop_products.all():
bump_shop_product_signal_handler(sender, shop_product, **kwargs)
bump_prices_for_shop_product(shop_product)
else:
bump_shop_product_signal_handler(sender, instance, **kwargs)
bump_prices_for_shop_product(instance)


# connect signals to bump caches on Product and ShopProduct change
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "shuup/front/checkout/_base.jinja" %}
{% from "shuup/front/macros/general.jinja" import render_field with context %}

{% block checkout_phase_content %}
<div class="row">
Expand All @@ -11,8 +12,7 @@
{{ macros.alert(error, mode="danger") }}
{% endfor %}
{% for f in login_form.hidden_fields() %}{{ f }}{% endfor %}
{{ macros.render_field(login_form.username) }}
{{ macros.render_field(login_form.password) }}
{% for f in login_form.visible_fields() %}{{ render_field(f) }}{% endfor %}
<button type="submit" class="btn btn-primary btn-block" name="login">
<i class="fa fa-sign-in"></i> {% trans %}Log in{% endtrans %}
</button>
Expand Down

0 comments on commit f31ea2a

Please sign in to comment.