def ready(self): from shuup.core.order_creator.signals import order_creator_finished from shuup.admin.modules.orders.receivers import handle_custom_payment_return_requests order_creator_finished.connect(handle_custom_payment_return_requests, dispatch_uid='shuup.admin.handle_cash_payments') validate_templates_configuration()
def ready(self): from shuup.core.order_creator.signals import order_creator_finished from shuup.admin.modules.orders.receivers import handle_custom_payment_return_requests order_creator_finished.connect(handle_custom_payment_return_requests, dispatch_uid='shuup.admin.handle_cash_payments') validate_templates_configuration()
def ready(self): from django.db.models.signals import post_save from shuup.core.models import CompanyContact, PersonContact from shuup.core.order_creator.signals import order_creator_finished from shuup_mailchimp.configuration_keys import ( MC_CONTACT_SIGNAL_DISPATCH_UID, MC_ORDER_SIGNAL_DISPATCH_UID ) from shuup_mailchimp.interface import ( update_or_create_contact, update_or_create_contact_from_order ) post_save.connect(update_or_create_contact, sender=CompanyContact, dispatch_uid=MC_CONTACT_SIGNAL_DISPATCH_UID) post_save.connect(update_or_create_contact, sender=PersonContact, dispatch_uid=MC_CONTACT_SIGNAL_DISPATCH_UID) order_creator_finished.connect(update_or_create_contact_from_order, dispatch_uid=MC_ORDER_SIGNAL_DISPATCH_UID)
@receiver(m2m_changed, sender=get_user_model().groups.through) def on_user_groups_change(instance, action, model, **kwargs): from shuup.admin.utils.permissions import USER_PERMISSIONS_CACHE_NAMESPACE # a group has changed it's users relation through group.users.set() # then we need to bump the entire cache if isinstance(instance, Group): cache.bump_version(USER_PERMISSIONS_CACHE_NAMESPACE) # bump only the user's permission cache elif isinstance(instance, get_user_model()): cache.bump_version("{}:{}".format(USER_PERMISSIONS_CACHE_NAMESPACE, instance.pk)) @receiver(object_saved) def on_object_saved(sender, object, **kwargs): # make sure to index the prices of the product when a product is saved if isinstance(object, ShopProduct): transaction.on_commit( lambda: run_task("shuup.core.catalog.tasks.index_shop_product", shop_product_id=object.pk)) if isinstance(object, Product): transaction.on_commit(lambda: run_task( "shuup.core.catalog.tasks.index_product", product_id=object.pk)) order_creator_finished.connect(handle_custom_payment_return_requests, dispatch_uid="shuup.admin.handle_cash_payments")
from shuup_admin_channel.utils import get_room_name_for_shop def send_order_received_message(order, **kwargs): """ Send message to users that a new order is received TODO: Put these on a queue and group messages so when a lot of orders is place inside a minute this won't flood users. """ payload = dict( type= "handle_order_received", # this will be called in the consumer handlers order_id=order.pk, customer_name=order.customer.name, customer_email=order.email, customer_phone=order.phone, order_total=order.taxful_total_price.as_rounded().value) from channels.layers import get_channel_layer channel_layer = get_channel_layer(settings.SHUUP_ADMIN_CHANNEL_LAYER or DEFAULT_CHANNEL_LAYER) from asgiref.sync import async_to_sync async_to_sync(channel_layer.group_send)(get_room_name_for_shop( order.shop.pk), payload) if settings.SHUUP_ADMIN_CHANNEL_ORDER_RECEIVED_ENABLED: order_creator_finished.connect( send_order_received_message, dispatch_uid="channel_send_order_received_message")