shuup.notify package¶
Subpackages¶
- shuup.notify.actions package
- shuup.notify.admin_module package
- Subpackages
- shuup.notify.admin_module.views package
- Submodules
- shuup.notify.admin_module.views.delete module
- shuup.notify.admin_module.views.edit module
- shuup.notify.admin_module.views.editor module
- shuup.notify.admin_module.views.email_template module
- shuup.notify.admin_module.views.list module
- shuup.notify.admin_module.views.template module
- Module contents
- shuup.notify.admin_module.views package
- Submodules
- shuup.notify.admin_module.forms module
- shuup.notify.admin_module.utils module
- Module contents
- Subpackages
- shuup.notify.conditions package
- shuup.notify.models package
- shuup.notify.script_template package
Submodules¶
shuup.notify.base module¶
-
class
shuup.notify.base.
Variable
(name, type=<class 'shuup.notify.typology.Type'>, required=True, help_text='', attributes=())[source]¶ Bases:
object
Parameters: - name (str) – A human readable name for the variable.
- type (shuup.notify.typology.Type) – The datatype of the variable.
- required (bool) – Whether the variable is required or not.
- help_text (str) – A free-form plaintext help text for the variable.
- attributes (typing.Sequence[tuple[str, str]]) – A sequence of (label, accessor) pairs that will be shown
under the variable as guides of attributes that can be accessed from it.
If one would pass
[_("ID", "id")]
to this when thename
param is “Order” if would get rendered asOrder ID: {{ order.id }}
in the script editor.
-
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
= 0¶
-
template_fields
= OrderedDict()¶
-
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:
-
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 form will be presented to the user and validated, so you can extract more information to build the Script.Variables: - identifier (str) – unique identifier for this ScriptTemplate with a max of 64 characters.
- event (shuup.notify.Event) – event class which will be used to trigger the notification.
- name (str) – name of the ScriptTemplate.
- description (str) – description of the ScriptTemplate presented to the user.
- help_text (str) – text to help users understand how this script will work.
- form_class (django.forms.Form|None) – form class if your ScriptTemplate needs extra configuration.
- initial (dict) – initial data to use in forms.
- template_name (str) – template to use to render the form, if needed.
- extra_js_template_name (str) – template with extra JavaScript code to use when rendering the form, if needed.
:ivar django.http.request.HttpRequest : 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
(shop, 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
= 0¶
-
UNILINGUAL
= 1¶
-
MULTILINGUAL
= 2¶
-
-
class
shuup.notify.enums.
ConstantUse
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
VARIABLE_ONLY
= 1¶
-
CONSTANT_ONLY
= 2¶
-
VARIABLE_OR_CONSTANT
= 3¶
-
-
class
shuup.notify.enums.
StepNext
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
CONTINUE
= 'continue'¶
-
STOP
= 'stop'¶
-
-
class
shuup.notify.enums.
StepConditionOperator
[source]¶ Bases:
enumfields.enums.Enum
An enumeration.
-
ALL
= 'all'¶
-
ANY
= 'any'¶
-
NONE
= 'none'¶
-
shuup.notify.notify_events module¶
-
class
shuup.notify.notify_events.
PasswordReset
(**variable_values)[source]¶ Bases:
shuup.notify.base.Event
-
identifier
= 'shuup_notify_password_reset'¶
-
name
= 'Password Reset'¶
-
description
= 'This event is triggered when password reset is requested.'¶
-
bindings
= {}¶
-
variables
= {'site_name': <shuup.notify.base.Variable object>, 'uid': <shuup.notify.base.Variable object>, 'user_to_recover': <shuup.notify.base.Variable object>, 'token': <shuup.notify.base.Variable object>, 'recovery_url': <shuup.notify.base.Variable object>, 'customer_email': <shuup.notify.base.Variable object>}¶
-
shuup.notify.runner module¶
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, shop=None, event_identifier=None)[source]¶ Bases:
object
-
classmethod
from_variables
(shop=None, event_identifier=None, **variables)[source]¶ Create Context from variables.
Parameters: event_identifier – identifier for shuup.notify event type Return type: shuup.notify.script.Context
-
classmethod
from_event
(event, shop=None)[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.script_templates module¶
shuup.notify.settings module¶
-
shuup.notify.settings.
SHUUP_NOTIFY_SCRIPT_RUNNER
= 'shuup.notify.runner.run_event'¶ The method used to run scripts.
-
shuup.notify.settings.
SHUUP_NOTIFY_TEMPLATE_ENVIRONMENT_PROVIDER
= 'shuup.notify.template.get_sandboxed_template_environment'¶ The method used to return the render environment for templates.
shuup.notify.signal_handlers module¶
shuup.notify.signals module¶
shuup.notify.tasks module¶
shuup.notify.template module¶
-
shuup.notify.template.
get_sandboxed_template_environment
(context, **kwargs)[source]¶ Returns a Jinja2 enviroment for rendering templates in notifications
Parameters: - context (shuup.notify.script.Context) – Script context.
- kwargs (dict) – extra args.
Returns: The environment used to render.
Return type: jinja2.environment.Environment
-
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.
MultiEmailField
(*, required=True, widget=None, label=None, initial=None, help_text='', error_messages=None, show_hidden_initial=False, validators=(), localize=False, disabled=False, label_suffix=None)[source]¶ Bases:
django.forms.fields.Field
From https://docs.djangoproject.com/en/1.11/ref/forms/validation/#form-field-default-cleaning
-
class
shuup.notify.typology.
Type
[source]¶ Bases:
object
-
name
= None¶
-
identifier
= None¶
-
-
class
shuup.notify.typology.
Boolean
[source]¶ Bases:
shuup.notify.typology.Type
-
name
= 'Boolean'¶
-
identifier
= 'boolean'¶
-
-
class
shuup.notify.typology.
Integer
[source]¶ Bases:
shuup.notify.typology._Number
-
name
= 'Integer Number'¶
-
identifier
= 'integer'¶
-
-
class
shuup.notify.typology.
Decimal
[source]¶ Bases:
shuup.notify.typology._Number
-
name
= 'Decimal Number'¶
-
identifier
= 'decimal'¶
-
-
class
shuup.notify.typology.
Text
[source]¶ Bases:
shuup.notify.typology._String
-
name
= 'Text'¶
-
identifier
= 'text'¶
-
-
class
shuup.notify.typology.
Language
[source]¶ Bases:
shuup.notify.typology._String
-
name
= 'Language'¶
-
identifier
= 'language'¶
-
-
class
shuup.notify.typology.
Email
[source]¶ Bases:
shuup.notify.typology._String
-
name
= 'Email Address'¶
-
identifier
= 'email'¶
-
-
class
shuup.notify.typology.
URL
[source]¶ Bases:
shuup.notify.typology._String
-
name
= 'URL Address'¶
-
identifier
= 'url'¶
-
-
class
shuup.notify.typology.
Phone
[source]¶ Bases:
shuup.notify.typology._String
-
name
= 'Phone Number'¶
-
identifier
= 'phone'¶
-
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': ['shuup.notify.notify_events:PasswordReset'], 'notify_script_template': ['shuup.notify.script_templates:PasswordResetTemplate'], 'admin_module': ['shuup.notify.admin_module:NotifyAdminModule', 'shuup.notify.admin_module:EmailTemplateAdminModule']}¶
-