shuup.notify package¶
Subpackages¶
Submodules¶
shuup.notify.base module¶
-
class
shuup.notify.base.
Variable
(name, type=<class 'shuup.notify.typology.Type'>, required=True, help_text='')[source]¶ Bases:
object
-
class
shuup.notify.base.
Binding
(name, type=<class 'shuup.notify.typology.Type'>, required=False, help_text='', constant_use=<ConstantUse.VARIABLE_ONLY: 1>, default=None)[source]¶ Bases:
shuup.notify.base.Variable
-
accepts_any_type
¶
-
allow_constant
¶
-
allow_variable
¶
-
-
class
shuup.notify.base.
TemplatedBinding
(*args, **kwargs)[source]¶ Bases:
shuup.notify.base.Binding
-
class
shuup.notify.base.
Base
[source]¶ Bases:
object
-
identifier
= None¶
-
name
= None¶
-
description
= None¶
-
variables
= {}¶
-
bindings
= {}¶
-
provide_category
= None¶
-
-
class
shuup.notify.base.
Event
(**variable_values)[source]¶ Bases:
shuup.notify.base.Base
-
provide_category
= 'notify_event'¶
-
identifier
= None¶
-
log_target_variable
= None¶ The name of the variable to be used as the log target for this event.
The target variable must have an
add_log_entry
method.
-
log_target
¶
-
bindings
= {}¶
-
variables
= {}¶
-
-
class
shuup.notify.base.
ScriptItem
(data, validate=True)[source]¶ Bases:
shuup.notify.base.Base
-
provide_category
= None¶
-
get_value
(context, binding_name)[source]¶ Get the actual value of a binding from the given script context.
Parameters: - context (shuup.notify.script.Context) – Script Context
- binding_name (str) – Binding name.
Returns: The variable value
-
get_values
(context)[source]¶ Get all binding values in a dict.
Parameters: context (shuup.notify.script.Context) – Script Context Returns: Dict of binding name -> value Return type: dict[name, value]
-
bindings
= {}¶
-
identifier
= 'script_item'¶
-
name
= 'Script Item'¶
-
variables
= {}¶
-
-
class
shuup.notify.base.
Condition
(data, validate=True)[source]¶ Bases:
shuup.notify.base.ScriptItem
-
provide_category
= 'notify_condition'¶
-
bindings
= {}¶
-
identifier
= 'condition'¶
-
name
= 'Condition'¶
-
variables
= {}¶
-
-
class
shuup.notify.base.
Action
(data, validate=True)[source]¶ Bases:
shuup.notify.base.ScriptItem
-
provide_category
= 'notify_action'¶
-
template_use
= <TemplateUse.NONE: 0>¶
-
template_fields
= {}¶
-
execute
(context)[source]¶ Parameters: context (shuup.notify.script.Context) – Script Context
-
get_template
(context)[source]¶ Get this action’s template instance, bound in the context.
Return type: shuup.notify.template.Template
-
get_template_values
(context, language_preferences=())[source]¶ Render this Action’s template with data from the given context.
Parameters: - context (shuup.notify.script.Context) – Script Context
- language_preferences (list[str]) – Language preference list. The first language in the template to have values for all fields will be used. Has no effect for UNILINGUAL template_use.
Returns: Dict of field name -> rendered template text.
Return type: dict[str, str]|None
-
bindings
= {}¶
-
identifier
= 'action'¶
-
name
= 'Action'¶
-
variables
= {}¶
-
-
class
shuup.notify.base.
ScriptTemplate
(script_instance=None)[source]¶ Bases:
object
Represents a script template to use in provides.
Subclass this, implement the methods and add a reference to the class in the
notify_script_template
provide category.When
form_class
is set, a the form will be presented to the user and validated, so you can extract more information to build the Script.Variables: - identifier (str) – a unique identifier for this ScriptTemplate with a max of 64 characters
- event (shuup.notify.Event) – the event class which will be used to trigger the notification
- name (str) – the name of the ScriptTemplate
- description (str) – the description of the ScriptTemplate to present to the user
- help_text (str) – a text to help users understand how this script will work
- form_class (django.forms.Form|None) – a form class if your ScriptTemplate needs extra configuration
- initial (dict) – the initial data to use in forms
- template_name (str) – a template to use to render the form, if needed
- extra_js_template_name (str) – a template with extra JavaScript code to use when rendering the form, if needed
:ivar django.http.request.HttpRequest : the http request
Parameters: script_instance (shuup.notify.models.script.Script|None) – script instance to change or None -
identifier
= ''¶
-
event
= None¶
-
name
= ''¶
-
description
= ''¶
-
help_text
= ''¶
-
form_class
= None¶
-
initial
= {}¶
-
template_name
= ''¶
-
extra_js_template_name
= ''¶
-
create_script
(form=None)[source]¶ Create and returns the Script.
If
form_class
is set, the will be validated and you can use it to do extra configuration on the Script.Returns: the created script Return type: shuup.notify.models.script.Script
-
can_edit_script
()[source]¶ Check whether the bound
script_instance
attribute can be edited by this TemplateScript.This means if you can still understand the current script state and structure and parse it, so you can edit the script through the
form_class
.This is a necessary check since the user can change the script through the Editor and those changes can disfigure the expected script structure.
Return type: bool Returns: whether the bound script_instance
can be edited by this script template
-
update_script
(form)[source]¶ Updates the current bound
script_instance
with the validated form data.This method is invoked when editing a Script created through this ScriptTemplate.
Note that only script templates which provides a form will have this method invoked.
Returns: the updated script Return type: shuup.notify.models.script.Script
-
get_initial
()[source]¶ Returns the initial data to use for configuration form.
Note: You must also check for the bound
script_instance
attribute. One can edit the Script created by the template editor through the form this instance provides. This way, when a script instance is bound, you must return the the representantion of the Script as the initial form data.Returns: initial data to to use in configuration form Return type: dict
shuup.notify.enums module¶
-
class
shuup.notify.enums.
TemplateUse
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
NONE
= <TemplateUse.NONE: 0>¶
-
UNILINGUAL
= <TemplateUse.UNILINGUAL: 1>¶
-
MULTILINGUAL
= <TemplateUse.MULTILINGUAL: 2>¶
-
-
class
shuup.notify.enums.
ConstantUse
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
VARIABLE_ONLY
= <ConstantUse.VARIABLE_ONLY: 1>¶
-
CONSTANT_ONLY
= <ConstantUse.CONSTANT_ONLY: 2>¶
-
VARIABLE_OR_CONSTANT
= <ConstantUse.VARIABLE_OR_CONSTANT: 3>¶
-
-
class
shuup.notify.enums.
StepNext
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
CONTINUE
= <StepNext.CONTINUE: 'continue'>¶
-
STOP
= <StepNext.STOP: 'stop'>¶
-
-
class
shuup.notify.enums.
StepConditionOperator
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
ALL
= <StepConditionOperator.ALL: 'all'>¶
-
ANY
= <StepConditionOperator.ANY: 'any'>¶
-
NONE
= <StepConditionOperator.NONE: 'none'>¶
-
shuup.notify.script module¶
-
class
shuup.notify.script.
Step
(conditions=(), actions=(), next=<StepNext.CONTINUE: 'continue'>, cond_op=<StepConditionOperator.ALL: 'all'>, enabled=True)[source]¶ Bases:
object
-
enabled
¶
-
-
class
shuup.notify.script.
Context
(variables=None)[source]¶ Bases:
object
-
classmethod
from_variables
(**variables)[source]¶ Create Context from variables.
Return type: shuup.notify.script.Context
-
classmethod
from_event
(event)[source]¶ Create Context from event.
Return type: shuup.notify.script.Context
-
log
(level, msg, *args, **kwargs)[source]¶ Log a message with the context’s logger (not the log target). This may be an useful debugging tool.
The parameters are the same as for
logging.Logger.log()
.
-
add_log_entry_on_log_target
(message, identifier, **kwargs)[source]¶ Add a log entry on the context’s log target.
The kwargs are passed to the target’s
add_log_entry
method.If no log target exists or if it has no
add_log_entry
method, this method does nothing.Parameters:
-
log_entry_queryset
¶
-
classmethod
shuup.notify.settings module¶
shuup.notify.template module¶
-
shuup.notify.template.
render_in_context
(context, template_text, html_intent=False)[source]¶ Render the given Jinja2 template text in the script context.
Parameters: - context (shuup.notify.script.Context) – Script context.
- template_text (str) – Jinja2 template text.
- html_intent (bool) – Is the template text intended for HTML output? This currently turns on autoescaping.
Returns: Rendered template text
Return type: Raises: Whatever Jinja2 might happen to raise
-
class
shuup.notify.template.
Template
(context, data)[source]¶ Bases:
object
Parameters: - context (shuup.notify.script.Context) – Script context
- data (dict) – Template data dictionary
shuup.notify.typology module¶
-
class
shuup.notify.typology.
Type
[source]¶ Bases:
object
-
name
= None¶
-
identifier
= None¶
-
get_field
(**kwargs)[source]¶ Get a Django form field for this type.
The kwargs are passed directly to the field constructor.
Parameters: kwargs (dict) – Kwargs for field constructor Returns: Form field Return type: django.forms.Field
-
-
class
shuup.notify.typology.
Boolean
[source]¶ Bases:
shuup.notify.typology.Type
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'boolean'¶
-
-
class
shuup.notify.typology.
Integer
[source]¶ Bases:
shuup.notify.typology._Number
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'integer'¶
-
-
class
shuup.notify.typology.
Decimal
[source]¶ Bases:
shuup.notify.typology._Number
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'decimal'¶
-
-
class
shuup.notify.typology.
Text
[source]¶ Bases:
shuup.notify.typology._String
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'text'¶
-
-
class
shuup.notify.typology.
Language
[source]¶ Bases:
shuup.notify.typology._String
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'language'¶
-
-
class
shuup.notify.typology.
Email
[source]¶ Bases:
shuup.notify.typology._String
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'email'¶
-
-
class
shuup.notify.typology.
URL
[source]¶ Bases:
shuup.notify.typology._String
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'url'¶
-
-
class
shuup.notify.typology.
Phone
[source]¶ Bases:
shuup.notify.typology._String
-
name
= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
identifier
= 'phone'¶
-
-
class
shuup.notify.typology.
Model
(model_label)[source]¶ Bases:
shuup.notify.typology.Type
Parameters: model_label (str) – Model label in Django app.Model
format (e.g.shuup.Order
)-
identifier
= 'model'¶
-
name
¶
-
model_label
= None¶
-
get_model
()[source]¶ Return type: django.db.models.Model
-
Module contents¶
-
class
shuup.notify.
ShuupNotifyAppConfig
(*args, **kwargs)[source]¶ Bases:
shuup.apps.AppConfig
-
name
= 'shuup.notify'¶
-
verbose_name
= 'Shuup Notification Framework'¶
-
label
= 'shuup_notify'¶
-
provides
= {'notify_condition': ['shuup.notify.conditions:LanguageEqual', 'shuup.notify.conditions:BooleanEqual', 'shuup.notify.conditions:IntegerEqual', 'shuup.notify.conditions:TextEqual', 'shuup.notify.conditions:Empty', 'shuup.notify.conditions:NonEmpty'], 'notify_action': ['shuup.notify.actions:SetDebugFlag', 'shuup.notify.actions:AddOrderLogEntry', 'shuup.notify.actions:SendEmail', 'shuup.notify.actions:AddNotification'], 'notify_event': [], 'admin_module': ['shuup.notify.admin_module:NotifyAdminModule']}¶
-