shoop.core.utils package¶
Submodules¶
shoop.core.utils.form_mixins module¶
-
class
shoop.core.utils.form_mixins.
ProtectedFieldsMixin
(**kwargs)[source]¶ Bases:
object
-
change_protect_field_text
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
clean_protected_fields
(cleaned_data)[source]¶ Ignore protected fields (they are set to
disabled
, so they will not be in the form data).As a side effect, this removes the fields from
changed_data
too.Parameters: cleaned_data (dict) – Cleaned data Returns: Cleaned data without protected field data Return type: dict
-
shoop.core.utils.maintenance module¶
shoop.core.utils.model_caching_descriptor module¶
shoop.core.utils.name_mixin module¶
shoop.core.utils.price_display module¶
Utilities for displaying prices correctly.
Contents:
- Class
PriceDisplayOptions
for storing the display options.- Helper function
render_price_property
for rendering prices correctly from Python code.- Various filter classes for implementing Jinja2 filters.
-
shoop.core.utils.price_display.
render_price_property
(request, item, priceful, property_name='price')[source]¶ Render price property of a Priceful object.
Return type: str
-
class
shoop.core.utils.price_display.
PriceDisplayFilter
(name, property_name=None)[source]¶ Bases:
shoop.core.utils.price_display._ContextFilter
-
class
shoop.core.utils.price_display.
PricePropertyFilter
(name, property_name=None)[source]¶ Bases:
shoop.core.utils.price_display._ContextFilter
-
class
shoop.core.utils.price_display.
PricePercentPropertyFilter
(name, property_name=None)[source]¶ Bases:
shoop.core.utils.price_display._ContextFilter
shoop.core.utils.prices module¶
-
shoop.core.utils.prices.
convert_taxness
(request, item, priceful, with_taxes)[source]¶ Convert taxness of a priceful object.
Return a
Priceful
objectresult
satisfyingresult.price.includes_tax == with_taxes
if possible.When given
priceful
does not have tax amount and taxes cannot be calculated automatically (should_calculate_taxes_automatically
returns false), return the givenpriceful
as is.Given
request
is used for constructing aTaxingContext
.Return type: shoop.core.pricing.Priceful
-
class
shoop.core.utils.prices.
TaxedPriceInfo
(price, base_price, quantity, tax_amount, **kwargs)[source]¶ Bases:
shoop.core.pricing.PriceInfo
shoop.core.utils.product_bought_with_relations module¶
shoop.core.utils.product_caching_object module¶
shoop.core.utils.query module¶
shoop.core.utils.slugs module¶
shoop.core.utils.tax_numbers module¶
-
shoop.core.utils.tax_numbers.
validate
(tax_number)[source]¶ Validate a tax number.
Parameters: tax_number (str) – Tax number to validate Returns: Type identifier of the tax number, if detected. Possible values for now are either “vat” or “unknown”. Return type: str Raise: ValidationError
if tax number type was detected, but it is somehow malformed.
shoop.core.utils.users module¶
shoop.core.utils.vat module¶
-
exception
shoop.core.utils.vat.
VatValidationError
(*args, **kwargs)[source]¶ Bases:
django.core.exceptions.ValidationError
-
code
= None¶
-
-
exception
shoop.core.utils.vat.
VatCannotIdentifyValidationError
(*args, **kwargs)[source]¶ Bases:
shoop.core.utils.vat.VatValidationError
-
code
= 'vat_cannot_identify'¶
-
-
exception
shoop.core.utils.vat.
VatInvalidValidationError
(*args, **kwargs)[source]¶ Bases:
shoop.core.utils.vat.VatValidationError
-
code
= 'vat_invalid'¶
-
-
shoop.core.utils.vat.
verify_vat
(vat_id, default_prefix='')[source]¶ Verify an EU VAT ID.
Returns a tuple (prefix, code_parts) – if both are truthy, the validation succeeded. If the prefix part is falsy, then the prefix was unknown and no validation was even attempted. If the prefix part is truthy, then it will contain the country prefix used for validation. The code_parts part can still be falsy, if the validation for the country’s VAT number pattern failed.
Parameters: Returns: Tuple of (prefix, code_parts)