<s> from django . db . models . signals import post_save , pre_delete <EOL> from sellmo . core import indexing <EOL> from sellmo . apps . customer . models import CustomerGroup <EOL> from . models import Product <EOL> from . indexes import ProductIndex <EOL> indexing . indexer . register_index ( '<STR_LIT>' , ProductIndex ) <EOL> def on_product_post_save ( sender , instance , raw = False , ** kwargs ) : <EOL> if not raw : <EOL> index = indexing . indexer . get_index ( '<STR_LIT>' ) <EOL> index . sync ( [ instance . pk ] ) <EOL> def on_product_pre_delete ( sender , instance , ** kwargs ) : <EOL> index = indexing . indexer . get_index ( '<STR_LIT>' ) <EOL> index . sync ( [ instance . pk ] ) <EOL> def on_customer_group_post_save ( sender , instance , raw = False , ** kwargs ) : <EOL> if not raw : <EOL> index = indexing . indexer . get_index ( '<STR_LIT>' ) <EOL> index . sync ( ) <EOL> def on_customer_group_pre_delete ( sender , instance , ** kwargs ) : <EOL> index = indexing . indexer . get_index ( '<STR_LIT>' ) <EOL> index . sync ( ) <EOL> def connect_signals ( ) : <EOL> for subtype in Product . SUBTYPES + [ Product ] : <EOL> post_save . connect ( on_product_post_save , sender = subtype ) <EOL> pre_delete . connect ( on_product_pre_delete , sender = subtype ) <EOL> post_save . connect ( on_customer_group_post_save , sender = CustomerGroup ) <EOL> pre_delete . connect ( on_customer_group_pre_delete , sender = CustomerGroup ) </s>
