shuup.campaigns.models package

Submodules

shuup.campaigns.models.basket_conditions module

class shuup.campaigns.models.basket_conditions.BasketCondition(id, polymorphic_ctype, active)[source]

Bases: polymorphic.models.PolymorphicModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
model = None
name = <django.utils.functional.lazy.<locals>.__proxy__ object>
matches(basket, lines)[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketCondition.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketCondition.base_objects = <django.db.models.manager.Manager object>
BasketCondition.campaign
BasketCondition.objects = <polymorphic.managers.PolymorphicManager object>
BasketCondition.polymorphic_ctype
BasketCondition.polymorphic_primary_key_name = 'id'
BasketCondition.polymorphic_super_sub_accessors_replaced = False

shuup.campaigns.models.basket_effects module

class shuup.campaigns.models.basket_effects.BasketDiscountEffect(id, polymorphic_ctype, campaign)[source]

Bases: shuup.core.models.PolymorphicShuupModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
identifier = None
model = None
admin_form_class = None
campaign
apply_for_basket(order_source)[source]

Applies the effect based on given order_source

Returns:amount of discount to accumulate for the product
Return type:Price
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketDiscountEffect.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketDiscountEffect.base_objects = <django.db.models.manager.Manager object>
BasketDiscountEffect.objects = <polymorphic.managers.PolymorphicManager object>
BasketDiscountEffect.polymorphic_ctype
BasketDiscountEffect.polymorphic_primary_key_name = 'id'
BasketDiscountEffect.polymorphic_super_sub_accessors_replaced = False

shuup.campaigns.models.basket_line_effects module

class shuup.campaigns.models.basket_line_effects.BasketLineEffect(id, polymorphic_ctype, campaign)[source]

Bases: shuup.core.models.PolymorphicShuupModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
identifier = None
model = None
admin_form_class = None
campaign
get_discount_lines(order_source, original_lines)[source]

Applies the effect based on given order_source

Returns:amount of discount to accumulate for the product
Return type:Iterable[shuup.core.order_creator.SourceLine]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketLineEffect.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketLineEffect.base_objects = <django.db.models.manager.Manager object>
BasketLineEffect.objects = <polymorphic.managers.PolymorphicManager object>
BasketLineEffect.polymorphic_ctype
BasketLineEffect.polymorphic_primary_key_name = 'id'
BasketLineEffect.polymorphic_super_sub_accessors_replaced = False

shuup.campaigns.models.campaigns module

class shuup.campaigns.models.campaigns.CampaignType[source]

Bases: enumfields.enums.Enum

An enumeration.

CATALOG = <CampaignType.CATALOG: 1>
BASKET = <CampaignType.BASKET: 2>
class shuup.campaigns.models.campaigns.CampaignQueryset(model=None, query=None, using=None, hints=None)[source]

Bases: django.db.models.query.QuerySet

available(shop=None)[source]
class shuup.campaigns.models.campaigns.Campaign(*args, **kwargs)[source]

Bases: shuup.utils.properties.MoneyPropped, parler.models.TranslatableModel

Parameters:
  • shop (ForeignKey to shuup.core.models.Shop) – The shop where the campaign is active.
  • name (CharField) – The name for this campaign.
  • identifier (InternalIdentifierField) – Do not change this value if you are not sure what you are doing.
  • active (BooleanField) – Check this if the campaign is currently active. Please also set a start and end date.
  • start_datetime (DateTimeField) – The date and time the campaign starts. This is only applicable if the campaign is marked as active.
  • end_datetime (DateTimeField) – The date and time the campaign ends. This is only applicable if the campaign is marked as active.
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
admin_url_suffix = None
shop
created_by
modified_by
objects
class Meta[source]

Bases: object

abstract = False
verbose_name = <django.utils.functional.lazy.<locals>.__proxy__ object>
verbose_name_plural = <django.utils.functional.lazy.<locals>.__proxy__ object>
Campaign.save(*args, **kwargs)[source]
Campaign.is_available()[source]
Campaign.type
Campaign.get_next_by_created_on(*moreargs, **morekwargs)
Campaign.get_next_by_modified_on(*moreargs, **morekwargs)
Campaign.get_previous_by_created_on(*moreargs, **morekwargs)
Campaign.get_previous_by_modified_on(*moreargs, **morekwargs)
class shuup.campaigns.models.campaigns.CatalogCampaign(id, shop, name, identifier, active, start_datetime, end_datetime, created_by, modified_by, created_on, modified_on)[source]

Bases: shuup.campaigns.models.campaigns.Campaign

Parameters:
  • id (AutoField) – Id
  • shop (ForeignKey to shuup.core.models.Shop) – The shop where the campaign is active.
  • name (CharField) – The name for this campaign.
  • identifier (InternalIdentifierField) – Do not change this value if you are not sure what you are doing.
  • active (BooleanField) – Check this if the campaign is currently active. Please also set a start and end date.
  • start_datetime (DateTimeField) – The date and time the campaign starts. This is only applicable if the campaign is marked as active.
  • end_datetime (DateTimeField) – The date and time the campaign ends. This is only applicable if the campaign is marked as active.
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
  • conditions (ManyToManyField to shuup.campaigns.models.context_conditions.ContextCondition) – Conditions
  • filters (ManyToManyField to shuup.campaigns.models.catalog_filters.CatalogFilter) – Filters
  • public_name (CharField) – (Translatable) The campaign name to show in the store front.
translations

ManyToOneRel to shuup.campaigns.models.campaigns.CatalogCampaignTranslation

log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.CatalogCampaignLogEntry

effects

ManyToOneRel to shuup.campaigns.models.product_effects.ProductDiscountEffect

admin_url_suffix = 'catalog_campaign'
conditions
filters
translations
save(*args, **kwargs)[source]
rules_match(context, shop_product, matching_catalog_filters, matching_context_conditions)[source]
classmethod get_for_product(shop_product)[source]
classmethod get_matching(context, shop_product)[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CatalogCampaign.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CatalogCampaign.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
CatalogCampaign.created_by
CatalogCampaign.effects
CatalogCampaign.get_next_by_created_on(*moreargs, **morekwargs)
CatalogCampaign.get_next_by_modified_on(*moreargs, **morekwargs)
CatalogCampaign.get_previous_by_created_on(*moreargs, **morekwargs)
CatalogCampaign.get_previous_by_modified_on(*moreargs, **morekwargs)
CatalogCampaign.log_entries
CatalogCampaign.modified_by
CatalogCampaign.objects = <django.db.models.manager.ManagerFromCampaignQueryset object>
CatalogCampaign.public_name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

CatalogCampaign.shop
class shuup.campaigns.models.campaigns.BasketCampaign(id, shop, name, identifier, active, start_datetime, end_datetime, created_by, modified_by, created_on, modified_on, basket_line_text, coupon)[source]

Bases: shuup.campaigns.models.campaigns.Campaign

Parameters:
  • id (AutoField) – Id
  • shop (ForeignKey to shuup.core.models.Shop) – The shop where the campaign is active.
  • name (CharField) – The name for this campaign.
  • identifier (InternalIdentifierField) – Do not change this value if you are not sure what you are doing.
  • active (BooleanField) – Check this if the campaign is currently active. Please also set a start and end date.
  • start_datetime (DateTimeField) – The date and time the campaign starts. This is only applicable if the campaign is marked as active.
  • end_datetime (DateTimeField) – The date and time the campaign ends. This is only applicable if the campaign is marked as active.
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
  • basket_line_text (CharField) – This text will be shown in basket.
  • coupon (OneToOneField to shuup.campaigns.models.campaigns.Coupon) – Coupon
  • conditions (ManyToManyField to shuup.campaigns.models.basket_conditions.BasketCondition) – Conditions
  • public_name (CharField) – (Translatable) The campaign name to show in the store front.
discount_effects

ManyToOneRel to shuup.campaigns.models.basket_effects.BasketDiscountEffect

line_effects

ManyToOneRel to shuup.campaigns.models.basket_line_effects.BasketLineEffect

translations

ManyToOneRel to shuup.campaigns.models.campaigns.BasketCampaignTranslation

log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.BasketCampaignLogEntry

admin_url_suffix = 'basket_campaign'
conditions
coupon
translations
save(*args, **kwargs)[source]
classmethod get_for_product(shop_product)[source]
classmethod get_matching(basket, lines)[source]
rules_match(basket, lines)[source]

Check if basket rules match.

They will not match if 1) The campaign is not active 2) The campaign has attached coupon

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/campaigns/models/campaigns.py:docstring of shuup.campaigns.models.campaigns.BasketCampaign.rules_match, line 6)

Unexpected indentation.
which doesn’t match or is not active

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/campaigns/models/campaigns.py:docstring of shuup.campaigns.models.campaigns.BasketCampaign.rules_match, line 7)

Block quote ends without a blank line; unexpected unindent.
  1. Any of the attached rules doesn’t match
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketCampaign.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketCampaign.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
BasketCampaign.created_by
BasketCampaign.discount_effects
BasketCampaign.get_next_by_created_on(*moreargs, **morekwargs)
BasketCampaign.get_next_by_modified_on(*moreargs, **morekwargs)
BasketCampaign.get_previous_by_created_on(*moreargs, **morekwargs)
BasketCampaign.get_previous_by_modified_on(*moreargs, **morekwargs)
BasketCampaign.line_effects
BasketCampaign.log_entries
BasketCampaign.modified_by
BasketCampaign.objects = <django.db.models.manager.ManagerFromCampaignQueryset object>
BasketCampaign.public_name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

BasketCampaign.shop
class shuup.campaigns.models.campaigns.CouponUsage(id, coupon, order, created_by, modified_by, created_on, modified_on)[source]

Bases: django.db.models.base.Model

Parameters:
log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.CouponUsageLogEntry

coupon
order
created_by
modified_by
classmethod add_usage(order, coupon)[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CouponUsage.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CouponUsage.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
CouponUsage.get_next_by_created_on(*moreargs, **morekwargs)
CouponUsage.get_next_by_modified_on(*moreargs, **morekwargs)
CouponUsage.get_previous_by_created_on(*moreargs, **morekwargs)
CouponUsage.get_previous_by_modified_on(*moreargs, **morekwargs)
CouponUsage.log_entries
CouponUsage.objects = <django.db.models.manager.Manager object>
class shuup.campaigns.models.campaigns.Coupon(id, code, usage_limit_customer, usage_limit, active, created_by, modified_by, created_on, modified_on)[source]

Bases: django.db.models.base.Model

Parameters:
  • id (AutoField) – Id
  • code (CharField) – Code
  • usage_limit_customer (PositiveIntegerField) – Limit the amount of usages per a single customer.
  • usage_limit (PositiveIntegerField) – Set the absolute limit of usages for this coupon. If the limit is zero (0) coupon cannot be used.
  • active (BooleanField) – Is active
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
campaign

OneToOneRel to shuup.campaigns.models.campaigns.BasketCampaign

usages

ManyToOneRel to shuup.campaigns.models.campaigns.CouponUsage

log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.CouponLogEntry

admin_url_suffix = 'coupon'
name_field = 'code'
search_fields = ['code']
created_by
modified_by
save(**kwargs)[source]
classmethod generate_code(length=6)[source]
exhausted
attached
attach_to_campaign(campaign)[source]
classmethod is_usable(code, customer)[source]
can_use_code(customer)[source]

Check if customer can use the code

Parameters:customer (Contact or None) –
Return type:True|False
use(order)[source]
increase_customer_usage_limit_by(amount)[source]
increase_usage_limit_by(amount)[source]
has_been_used(usage_count=1)[source]

See if code is used the times given

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Coupon.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Coupon.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
Coupon.campaign
Coupon.get_next_by_created_on(*moreargs, **morekwargs)
Coupon.get_next_by_modified_on(*moreargs, **morekwargs)
Coupon.get_previous_by_created_on(*moreargs, **morekwargs)
Coupon.get_previous_by_modified_on(*moreargs, **morekwargs)
Coupon.log_entries
Coupon.objects = <django.db.models.manager.Manager object>
Coupon.usages
class shuup.campaigns.models.campaigns.CatalogCampaignLogEntry(id, created_on, user, message, identifier, kind, extra, target)

Bases: shuup.utils.analog.BaseLogEntry

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CatalogCampaignLogEntry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CatalogCampaignLogEntry.extra

A placeholder class that provides a way to set the attribute on the model.

CatalogCampaignLogEntry.get_kind_display(*moreargs, **morekwargs)
CatalogCampaignLogEntry.get_next_by_created_on(*moreargs, **morekwargs)
CatalogCampaignLogEntry.get_previous_by_created_on(*moreargs, **morekwargs)
CatalogCampaignLogEntry.kind

A placeholder class that provides a way to set the attribute on the model.

CatalogCampaignLogEntry.logged_model

alias of CatalogCampaign

CatalogCampaignLogEntry.objects = <django.db.models.manager.Manager object>
CatalogCampaignLogEntry.target
CatalogCampaignLogEntry.user
class shuup.campaigns.models.campaigns.BasketCampaignLogEntry(id, created_on, user, message, identifier, kind, extra, target)

Bases: shuup.utils.analog.BaseLogEntry

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketCampaignLogEntry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketCampaignLogEntry.extra

A placeholder class that provides a way to set the attribute on the model.

BasketCampaignLogEntry.get_kind_display(*moreargs, **morekwargs)
BasketCampaignLogEntry.get_next_by_created_on(*moreargs, **morekwargs)
BasketCampaignLogEntry.get_previous_by_created_on(*moreargs, **morekwargs)
BasketCampaignLogEntry.kind

A placeholder class that provides a way to set the attribute on the model.

BasketCampaignLogEntry.logged_model

alias of BasketCampaign

BasketCampaignLogEntry.objects = <django.db.models.manager.Manager object>
BasketCampaignLogEntry.target
BasketCampaignLogEntry.user
class shuup.campaigns.models.campaigns.CouponLogEntry(id, created_on, user, message, identifier, kind, extra, target)

Bases: shuup.utils.analog.BaseLogEntry

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CouponLogEntry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CouponLogEntry.extra

A placeholder class that provides a way to set the attribute on the model.

CouponLogEntry.get_kind_display(*moreargs, **morekwargs)
CouponLogEntry.get_next_by_created_on(*moreargs, **morekwargs)
CouponLogEntry.get_previous_by_created_on(*moreargs, **morekwargs)
CouponLogEntry.kind

A placeholder class that provides a way to set the attribute on the model.

CouponLogEntry.logged_model

alias of Coupon

CouponLogEntry.objects = <django.db.models.manager.Manager object>
CouponLogEntry.target
CouponLogEntry.user
class shuup.campaigns.models.campaigns.CouponUsageLogEntry(id, created_on, user, message, identifier, kind, extra, target)

Bases: shuup.utils.analog.BaseLogEntry

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CouponUsageLogEntry.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CouponUsageLogEntry.extra

A placeholder class that provides a way to set the attribute on the model.

CouponUsageLogEntry.get_kind_display(*moreargs, **morekwargs)
CouponUsageLogEntry.get_next_by_created_on(*moreargs, **morekwargs)
CouponUsageLogEntry.get_previous_by_created_on(*moreargs, **morekwargs)
CouponUsageLogEntry.kind

A placeholder class that provides a way to set the attribute on the model.

CouponUsageLogEntry.logged_model

alias of CouponUsage

CouponUsageLogEntry.objects = <django.db.models.manager.Manager object>
CouponUsageLogEntry.target
CouponUsageLogEntry.user
class shuup.campaigns.models.campaigns.BasketCampaignTranslation(id, language_code, public_name, master)

Bases: parler.models.TranslatedFieldsModel

Parameters:
exception DoesNotExist

Bases: parler.models.TranslationDoesNotExist, shuup.campaigns.models.campaigns.DoesNotExist, shuup.campaigns.models.campaigns.DoesNotExist

exception BasketCampaignTranslation.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketCampaignTranslation.get_language_code_display(*moreargs, **morekwargs)
BasketCampaignTranslation.master
BasketCampaignTranslation.objects = <django.db.models.manager.Manager object>
class shuup.campaigns.models.campaigns.CatalogCampaignTranslation(id, language_code, public_name, master)

Bases: parler.models.TranslatedFieldsModel

Parameters:
exception DoesNotExist

Bases: parler.models.TranslationDoesNotExist, shuup.campaigns.models.campaigns.DoesNotExist, shuup.campaigns.models.campaigns.DoesNotExist

exception CatalogCampaignTranslation.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CatalogCampaignTranslation.get_language_code_display(*moreargs, **morekwargs)
CatalogCampaignTranslation.master
CatalogCampaignTranslation.objects = <django.db.models.manager.Manager object>

shuup.campaigns.models.catalog_filters module

class shuup.campaigns.models.catalog_filters.CatalogFilter(id, polymorphic_ctype, active)[source]

Bases: polymorphic.models.PolymorphicModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
model = None
identifier = 'base_catalog_filter'
name = <django.utils.functional.lazy.<locals>.__proxy__ object>
filter_queryset(queryset)[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CatalogFilter.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CatalogFilter.base_objects = <django.db.models.manager.Manager object>
CatalogFilter.campaign
CatalogFilter.objects = <polymorphic.managers.PolymorphicManager object>
CatalogFilter.polymorphic_ctype
CatalogFilter.polymorphic_primary_key_name = 'id'
CatalogFilter.polymorphic_super_sub_accessors_replaced = False

shuup.campaigns.models.context_conditions module

class shuup.campaigns.models.context_conditions.ContextCondition(id, polymorphic_ctype, active)[source]

Bases: polymorphic.models.PolymorphicModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
model = None
identifier = 'context_condition'
name = <django.utils.functional.lazy.<locals>.__proxy__ object>
description = <django.utils.functional.lazy.<locals>.__proxy__ object>
matches(context)[source]
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception ContextCondition.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ContextCondition.base_objects = <django.db.models.manager.Manager object>
ContextCondition.campaign
ContextCondition.objects = <polymorphic.managers.PolymorphicManager object>
ContextCondition.polymorphic_ctype
ContextCondition.polymorphic_primary_key_name = 'id'
ContextCondition.polymorphic_super_sub_accessors_replaced = False

shuup.campaigns.models.matching module

shuup.campaigns.models.matching.get_matching_context_conditions(context)[source]
shuup.campaigns.models.matching.get_matching_catalog_filters(shop_product)[source]

shuup.campaigns.models.product_effects module

class shuup.campaigns.models.product_effects.ProductDiscountEffect(id, polymorphic_ctype, campaign)[source]

Bases: shuup.core.models.PolymorphicShuupModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
identifier = None
model = None
admin_form_class = None
campaign
apply_for_product(context, product, price_info)[source]

Applies the effect for product

Returns:amount of discount to accumulate for the product
Return type:Price
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception ProductDiscountEffect.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ProductDiscountEffect.base_objects = <django.db.models.manager.Manager object>
ProductDiscountEffect.objects = <polymorphic.managers.PolymorphicManager object>
ProductDiscountEffect.polymorphic_ctype
ProductDiscountEffect.polymorphic_primary_key_name = 'id'
ProductDiscountEffect.polymorphic_super_sub_accessors_replaced = False

Module contents

class shuup.campaigns.models.BasketLineEffect(id, polymorphic_ctype, campaign)[source]

Bases: shuup.core.models.PolymorphicShuupModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketLineEffect.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketLineEffect.admin_form_class = None
BasketLineEffect.base_objects = <django.db.models.manager.Manager object>
BasketLineEffect.campaign
BasketLineEffect.get_discount_lines(order_source, original_lines)[source]

Applies the effect based on given order_source

Returns:amount of discount to accumulate for the product
Return type:Iterable[shuup.core.order_creator.SourceLine]
BasketLineEffect.identifier = None
BasketLineEffect.model = None
BasketLineEffect.objects = <polymorphic.managers.PolymorphicManager object>
BasketLineEffect.polymorphic_ctype
BasketLineEffect.polymorphic_primary_key_name = 'id'
BasketLineEffect.polymorphic_super_sub_accessors_replaced = False
class shuup.campaigns.models.BasketCampaign(id, shop, name, identifier, active, start_datetime, end_datetime, created_by, modified_by, created_on, modified_on, basket_line_text, coupon)[source]

Bases: shuup.campaigns.models.campaigns.Campaign

Parameters:
  • id (AutoField) – Id
  • shop (ForeignKey to shuup.core.models.Shop) – The shop where the campaign is active.
  • name (CharField) – The name for this campaign.
  • identifier (InternalIdentifierField) – Do not change this value if you are not sure what you are doing.
  • active (BooleanField) – Check this if the campaign is currently active. Please also set a start and end date.
  • start_datetime (DateTimeField) – The date and time the campaign starts. This is only applicable if the campaign is marked as active.
  • end_datetime (DateTimeField) – The date and time the campaign ends. This is only applicable if the campaign is marked as active.
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
  • basket_line_text (CharField) – This text will be shown in basket.
  • coupon (OneToOneField to shuup.campaigns.models.campaigns.Coupon) – Coupon
  • conditions (ManyToManyField to shuup.campaigns.models.basket_conditions.BasketCondition) – Conditions
  • public_name (CharField) – (Translatable) The campaign name to show in the store front.
discount_effects

ManyToOneRel to shuup.campaigns.models.basket_effects.BasketDiscountEffect

line_effects

ManyToOneRel to shuup.campaigns.models.basket_line_effects.BasketLineEffect

translations

ManyToOneRel to shuup.campaigns.models.campaigns.BasketCampaignTranslation

log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.BasketCampaignLogEntry

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketCampaign.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketCampaign.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
BasketCampaign.admin_url_suffix = 'basket_campaign'
BasketCampaign.conditions
BasketCampaign.coupon
BasketCampaign.created_by
BasketCampaign.discount_effects
classmethod BasketCampaign.get_for_product(shop_product)[source]
classmethod BasketCampaign.get_matching(basket, lines)[source]
BasketCampaign.get_next_by_created_on(*moreargs, **morekwargs)
BasketCampaign.get_next_by_modified_on(*moreargs, **morekwargs)
BasketCampaign.get_previous_by_created_on(*moreargs, **morekwargs)
BasketCampaign.get_previous_by_modified_on(*moreargs, **morekwargs)
BasketCampaign.line_effects
BasketCampaign.log_entries
BasketCampaign.modified_by
BasketCampaign.objects = <django.db.models.manager.ManagerFromCampaignQueryset object>
BasketCampaign.public_name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

BasketCampaign.rules_match(basket, lines)[source]

Check if basket rules match.

They will not match if 1) The campaign is not active 2) The campaign has attached coupon

System Message: ERROR/3 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/campaigns/models/__init__.py:docstring of shuup.campaigns.models.BasketCampaign.rules_match, line 6)

Unexpected indentation.
which doesn’t match or is not active

System Message: WARNING/2 (/home/docs/checkouts/readthedocs.org/user_builds/shuup/checkouts/v2.0.0/shuup/campaigns/models/__init__.py:docstring of shuup.campaigns.models.BasketCampaign.rules_match, line 7)

Block quote ends without a blank line; unexpected unindent.
  1. Any of the attached rules doesn’t match
BasketCampaign.save(*args, **kwargs)[source]
BasketCampaign.shop
BasketCampaign.translations
class shuup.campaigns.models.BasketDiscountEffect(id, polymorphic_ctype, campaign)[source]

Bases: shuup.core.models.PolymorphicShuupModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketDiscountEffect.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketDiscountEffect.admin_form_class = None
BasketDiscountEffect.apply_for_basket(order_source)[source]

Applies the effect based on given order_source

Returns:amount of discount to accumulate for the product
Return type:Price
BasketDiscountEffect.base_objects = <django.db.models.manager.Manager object>
BasketDiscountEffect.campaign
BasketDiscountEffect.identifier = None
BasketDiscountEffect.model = None
BasketDiscountEffect.objects = <polymorphic.managers.PolymorphicManager object>
BasketDiscountEffect.polymorphic_ctype
BasketDiscountEffect.polymorphic_primary_key_name = 'id'
BasketDiscountEffect.polymorphic_super_sub_accessors_replaced = False
class shuup.campaigns.models.BasketCondition(id, polymorphic_ctype, active)[source]

Bases: polymorphic.models.PolymorphicModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception BasketCondition.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

BasketCondition.base_objects = <django.db.models.manager.Manager object>
BasketCondition.campaign
BasketCondition.matches(basket, lines)[source]
BasketCondition.model = None
BasketCondition.name = <django.utils.functional.lazy.<locals>.__proxy__ object>
BasketCondition.objects = <polymorphic.managers.PolymorphicManager object>
BasketCondition.polymorphic_ctype
BasketCondition.polymorphic_primary_key_name = 'id'
BasketCondition.polymorphic_super_sub_accessors_replaced = False
class shuup.campaigns.models.Campaign(*args, **kwargs)[source]

Bases: shuup.utils.properties.MoneyPropped, parler.models.TranslatableModel

Parameters:
  • shop (ForeignKey to shuup.core.models.Shop) – The shop where the campaign is active.
  • name (CharField) – The name for this campaign.
  • identifier (InternalIdentifierField) – Do not change this value if you are not sure what you are doing.
  • active (BooleanField) – Check this if the campaign is currently active. Please also set a start and end date.
  • start_datetime (DateTimeField) – The date and time the campaign starts. This is only applicable if the campaign is marked as active.
  • end_datetime (DateTimeField) – The date and time the campaign ends. This is only applicable if the campaign is marked as active.
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
class Meta[source]

Bases: object

abstract = False
verbose_name = <django.utils.functional.lazy.<locals>.__proxy__ object>
verbose_name_plural = <django.utils.functional.lazy.<locals>.__proxy__ object>
Campaign.admin_url_suffix = None
Campaign.created_by
Campaign.get_next_by_created_on(*moreargs, **morekwargs)
Campaign.get_next_by_modified_on(*moreargs, **morekwargs)
Campaign.get_previous_by_created_on(*moreargs, **morekwargs)
Campaign.get_previous_by_modified_on(*moreargs, **morekwargs)
Campaign.is_available()[source]
Campaign.modified_by
Campaign.objects
Campaign.save(*args, **kwargs)[source]
Campaign.shop
Campaign.type
class shuup.campaigns.models.CatalogFilter(id, polymorphic_ctype, active)[source]

Bases: polymorphic.models.PolymorphicModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CatalogFilter.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CatalogFilter.base_objects = <django.db.models.manager.Manager object>
CatalogFilter.campaign
CatalogFilter.filter_queryset(queryset)[source]
CatalogFilter.identifier = 'base_catalog_filter'
CatalogFilter.model = None
CatalogFilter.name = <django.utils.functional.lazy.<locals>.__proxy__ object>
CatalogFilter.objects = <polymorphic.managers.PolymorphicManager object>
CatalogFilter.polymorphic_ctype
CatalogFilter.polymorphic_primary_key_name = 'id'
CatalogFilter.polymorphic_super_sub_accessors_replaced = False
class shuup.campaigns.models.ContextCondition(id, polymorphic_ctype, active)[source]

Bases: polymorphic.models.PolymorphicModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception ContextCondition.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ContextCondition.base_objects = <django.db.models.manager.Manager object>
ContextCondition.campaign
ContextCondition.description = <django.utils.functional.lazy.<locals>.__proxy__ object>
ContextCondition.identifier = 'context_condition'
ContextCondition.matches(context)[source]
ContextCondition.model = None
ContextCondition.name = <django.utils.functional.lazy.<locals>.__proxy__ object>
ContextCondition.objects = <polymorphic.managers.PolymorphicManager object>
ContextCondition.polymorphic_ctype
ContextCondition.polymorphic_primary_key_name = 'id'
ContextCondition.polymorphic_super_sub_accessors_replaced = False
class shuup.campaigns.models.ProductDiscountEffect(id, polymorphic_ctype, campaign)[source]

Bases: shuup.core.models.PolymorphicShuupModel

Parameters:

Replace Django’s inheritance accessor member functions for our model (self.__class__) with our own versions. We monkey patch them until a patch can be added to Django (which would probably be very small and make all of this obsolete).

If we have inheritance of the form ModelA -> ModelB ->ModelC then Django creates accessors like this: - ModelA: modelb - ModelB: modela_ptr, modelb, modelc - ModelC: modela_ptr, modelb, modelb_ptr, modelc

These accessors allow Django (and everyone else) to travel up and down the inheritance tree for the db object at hand.

The original Django accessors use our polymorphic manager. But they should not. So we replace them with our own accessors that use our appropriate base_objects manager.

Parameters:
exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception ProductDiscountEffect.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

ProductDiscountEffect.admin_form_class = None
ProductDiscountEffect.apply_for_product(context, product, price_info)[source]

Applies the effect for product

Returns:amount of discount to accumulate for the product
Return type:Price
ProductDiscountEffect.base_objects = <django.db.models.manager.Manager object>
ProductDiscountEffect.campaign
ProductDiscountEffect.identifier = None
ProductDiscountEffect.model = None
ProductDiscountEffect.objects = <polymorphic.managers.PolymorphicManager object>
ProductDiscountEffect.polymorphic_ctype
ProductDiscountEffect.polymorphic_primary_key_name = 'id'
ProductDiscountEffect.polymorphic_super_sub_accessors_replaced = False
class shuup.campaigns.models.CatalogCampaign(id, shop, name, identifier, active, start_datetime, end_datetime, created_by, modified_by, created_on, modified_on)[source]

Bases: shuup.campaigns.models.campaigns.Campaign

Parameters:
  • id (AutoField) – Id
  • shop (ForeignKey to shuup.core.models.Shop) – The shop where the campaign is active.
  • name (CharField) – The name for this campaign.
  • identifier (InternalIdentifierField) – Do not change this value if you are not sure what you are doing.
  • active (BooleanField) – Check this if the campaign is currently active. Please also set a start and end date.
  • start_datetime (DateTimeField) – The date and time the campaign starts. This is only applicable if the campaign is marked as active.
  • end_datetime (DateTimeField) – The date and time the campaign ends. This is only applicable if the campaign is marked as active.
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
  • conditions (ManyToManyField to shuup.campaigns.models.context_conditions.ContextCondition) – Conditions
  • filters (ManyToManyField to shuup.campaigns.models.catalog_filters.CatalogFilter) – Filters
  • public_name (CharField) – (Translatable) The campaign name to show in the store front.
translations

ManyToOneRel to shuup.campaigns.models.campaigns.CatalogCampaignTranslation

log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.CatalogCampaignLogEntry

effects

ManyToOneRel to shuup.campaigns.models.product_effects.ProductDiscountEffect

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception CatalogCampaign.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

CatalogCampaign.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
CatalogCampaign.admin_url_suffix = 'catalog_campaign'
CatalogCampaign.conditions
CatalogCampaign.created_by
CatalogCampaign.effects
CatalogCampaign.filters
classmethod CatalogCampaign.get_for_product(shop_product)[source]
classmethod CatalogCampaign.get_matching(context, shop_product)[source]
CatalogCampaign.get_next_by_created_on(*moreargs, **morekwargs)
CatalogCampaign.get_next_by_modified_on(*moreargs, **morekwargs)
CatalogCampaign.get_previous_by_created_on(*moreargs, **morekwargs)
CatalogCampaign.get_previous_by_modified_on(*moreargs, **morekwargs)
CatalogCampaign.log_entries
CatalogCampaign.modified_by
CatalogCampaign.objects = <django.db.models.manager.ManagerFromCampaignQueryset object>
CatalogCampaign.public_name

Descriptor for translated attributes.

This attribute proxies all get/set calls to the translated model.

CatalogCampaign.rules_match(context, shop_product, matching_catalog_filters, matching_context_conditions)[source]
CatalogCampaign.save(*args, **kwargs)[source]
CatalogCampaign.shop
CatalogCampaign.translations
class shuup.campaigns.models.Coupon(id, code, usage_limit_customer, usage_limit, active, created_by, modified_by, created_on, modified_on)[source]

Bases: django.db.models.base.Model

Parameters:
  • id (AutoField) – Id
  • code (CharField) – Code
  • usage_limit_customer (PositiveIntegerField) – Limit the amount of usages per a single customer.
  • usage_limit (PositiveIntegerField) – Set the absolute limit of usages for this coupon. If the limit is zero (0) coupon cannot be used.
  • active (BooleanField) – Is active
  • created_by (ForeignKey to django.contrib.auth.models.User) – Created by
  • modified_by (ForeignKey to django.contrib.auth.models.User) – Modified by
  • created_on (DateTimeField) – Created on
  • modified_on (DateTimeField) – Modified on
campaign

OneToOneRel to shuup.campaigns.models.campaigns.BasketCampaign

usages

ManyToOneRel to shuup.campaigns.models.campaigns.CouponUsage

log_entries

ManyToOneRel to shuup.campaigns.models.campaigns.CouponLogEntry

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Coupon.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

Coupon.add_log_entry(message, identifier=None, kind=<LogEntryKind.OTHER: 0>, user=None, extra=None, save=True)
Coupon.admin_url_suffix = 'coupon'
Coupon.attach_to_campaign(campaign)[source]
Coupon.attached
Coupon.campaign
Coupon.can_use_code(customer)[source]

Check if customer can use the code

Parameters:customer (Contact or None) –
Return type:True|False
Coupon.created_by
Coupon.exhausted
classmethod Coupon.generate_code(length=6)[source]
Coupon.get_next_by_created_on(*moreargs, **morekwargs)
Coupon.get_next_by_modified_on(*moreargs, **morekwargs)
Coupon.get_previous_by_created_on(*moreargs, **morekwargs)
Coupon.get_previous_by_modified_on(*moreargs, **morekwargs)
Coupon.has_been_used(usage_count=1)[source]

See if code is used the times given

Coupon.increase_customer_usage_limit_by(amount)[source]
Coupon.increase_usage_limit_by(amount)[source]
classmethod Coupon.is_usable(code, customer)[source]
Coupon.log_entries
Coupon.modified_by
Coupon.name_field = 'code'
Coupon.objects = <django.db.models.manager.Manager object>
Coupon.save(**kwargs)[source]
Coupon.search_fields = ['code']
Coupon.usages
Coupon.use(order)[source]