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
ScriptListViewScriptListView.template_nameScriptListView.modelScriptListView.default_columnsScriptListView.toolbar_buttons_provider_keyScriptListView.mass_actions_provider_keyScriptListView.get_object_urlScriptListView.get_event_identifier_textScriptListView.get_toolbarScriptListView.get_object_abstractScriptListView.get_queryset
- shuup.notify.admin_module.views.template module
- Module contents
script_item_editorScriptEditViewEditScriptContentViewScriptListViewScriptListView.default_columnsScriptListView.get_event_identifier_textScriptListView.get_object_abstractScriptListView.get_object_urlScriptListView.get_querysetScriptListView.get_toolbarScriptListView.mass_actions_provider_keyScriptListView.modelScriptListView.template_nameScriptListView.toolbar_buttons_provider_key
ScriptTemplateViewScriptTemplateConfigViewScriptTemplateEditView
- 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
- Submodules
- shuup.notify.models.email_template module
- shuup.notify.models.notification module
NotificationManagerNotificationNotification.shopNotification.recipient_typeNotification.recipientNotification.created_onNotification.messageNotification.identifierNotification.priorityNotification.marked_readNotification.marked_read_byNotification.marked_read_onNotification.objectsNotification.__init__Notification.saveNotification.mark_readNotification.is_readNotification.dataNotification.DoesNotExistNotification.MultipleObjectsReturnedNotification.get_next_by_created_onNotification.get_previous_by_created_onNotification.get_priority_displayNotification.get_recipient_type_displayNotification.idNotification.marked_read_by_idNotification.recipient_idNotification.shop_idNotification.urlNotification.set_reverse_url
- shuup.notify.models.script module
ScriptScript.shopScript.event_identifierScript.identifierScript.created_onScript.nameScript.enabledScript.templateScript.get_stepsScript.set_stepsScript.get_serialized_stepsScript.set_serialized_stepsScript.event_classScript.executeScript.DoesNotExistScript.MultipleObjectsReturnedScript.add_log_entryScript.get_next_by_created_onScript.get_previous_by_created_onScript.idScript.log_entriesScript.objectsScript.shop_id
ScriptLogEntryScriptLogEntry.DoesNotExistScriptLogEntry.MultipleObjectsReturnedScriptLogEntry.get_kind_displayScriptLogEntry.get_next_by_created_onScriptLogEntry.get_previous_by_created_onScriptLogEntry.idScriptLogEntry.kindScriptLogEntry.logged_modelScriptLogEntry.objectsScriptLogEntry.targetScriptLogEntry.target_idScriptLogEntry.user
- Module contents
EmailTemplateNotificationNotification.DoesNotExistNotification.MultipleObjectsReturnedNotification.__init__Notification.created_onNotification.dataNotification.get_next_by_created_onNotification.get_previous_by_created_onNotification.get_priority_displayNotification.get_recipient_type_displayNotification.idNotification.identifierNotification.is_readNotification.mark_readNotification.marked_readNotification.marked_read_byNotification.marked_read_by_idNotification.marked_read_onNotification.messageNotification.objectsNotification.priorityNotification.recipientNotification.recipient_idNotification.recipient_typeNotification.saveNotification.set_reverse_urlNotification.shopNotification.shop_idNotification.url
ScriptScript.DoesNotExistScript.MultipleObjectsReturnedScript.add_log_entryScript.created_onScript.enabledScript.event_classScript.event_identifierScript.executeScript.get_next_by_created_onScript.get_previous_by_created_onScript.get_serialized_stepsScript.get_stepsScript.idScript.identifierScript.log_entriesScript.nameScript.objectsScript.set_serialized_stepsScript.set_stepsScript.shopScript.shop_idScript.template
- shuup.notify.script_template package
- Submodules
- shuup.notify.script_template.factory module
- shuup.notify.script_template.generic module
GenericScriptTemplateEmailContentFormGenericScriptTemplateEmailFormGenericSendEmailScriptTemplateGenericSendEmailScriptTemplate.template_nameGenericSendEmailScriptTemplate.extra_js_template_nameGenericSendEmailScriptTemplate.base_form_classGenericSendEmailScriptTemplate.multilingual_form_classGenericSendEmailScriptTemplate.get_script_stepsGenericSendEmailScriptTemplate.get_context_dataGenericSendEmailScriptTemplate.get_formGenericSendEmailScriptTemplate.get_initialGenericSendEmailScriptTemplate.can_edit_script
- Module contents
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 (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 thenameparam is “Order” if would get rendered asOrder ID: {{ order.id }}in the script editor.
- __init__(name, type=<class 'shuup.notify.typology.Type'>, required=True, help_text='', attributes=())[source]
- 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 (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 thenameparam 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, default=None)[source]
Bases:
Variable- 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 (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 thenameparam is “Order” if would get rendered asOrder ID: {{ order.id }}in the script editor.
- __init__(name, type=<class 'shuup.notify.typology.Type'>, required=False, help_text='', constant_use=ConstantUse.VARIABLE_ONLY, default=None)[source]
- 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 (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 thenameparam is “Order” if would get rendered asOrder ID: {{ order.id }}in the script editor.
- property accepts_any_type
- property allow_constant
- property allow_variable
- class shuup.notify.base.TemplatedBinding(*args, **kwargs)[source]
Bases:
Binding- 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 (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 thenameparam is “Order” if would get rendered asOrder ID: {{ order.id }}in the script editor.
- __init__(*args, **kwargs)[source]
- 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 (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 thenameparam is “Order” if would get rendered asOrder ID: {{ order.id }}in the script editor.
- 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:
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_entrymethod.
- property log_target
- bindings = {}
- variables = {}
- class shuup.notify.base.ScriptItem(data, validate=True)[source]
Bases:
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:
ScriptItem- provide_category = 'notify_condition'
- bindings = {}
- identifier = 'condition'
- name = 'Condition'
- variables = {}
- class shuup.notify.base.Action(data, validate=True)[source]
Bases:
ScriptItem- provide_category = 'notify_action'
- template_use = 0
- template_fields = {}
- abstractmethod 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:
- 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:
objectRepresents a script template to use in provides.
Subclass this, implement the methods and add a reference to the class in the
notify_script_templateprovide category.When
form_classis 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 = ''
- __init__(script_instance=None)[source]
- Parameters:
script_instance (shuup.notify.models.script.Script|None) – script instance to change or None
- abstractmethod create_script(shop, form=None)[source]
Create and returns the Script.
If
form_classis set, the will be validated and you can use it to do extra configuration on the Script.- Returns:
the created script
- Return type:
- abstractmethod can_edit_script()[source]
Check whether the bound
script_instanceattribute 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:
- Returns:
whether the bound
script_instancecan be edited by this script template
- abstractmethod update_script(form)[source]
Updates the current bound
script_instancewith 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:
- get_initial()[source]
Returns the initial data to use for configuration form.
Note: You must also check for the bound
script_instanceattribute. 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:
shuup.notify.enums module
- class shuup.notify.enums.TemplateUse(value)[source]
Bases:
Enum- NONE = 0
- UNILINGUAL = 1
- MULTILINGUAL = 2
- class shuup.notify.enums.ConstantUse(value)[source]
Bases:
Enum- VARIABLE_ONLY = 1
- CONSTANT_ONLY = 2
- VARIABLE_OR_CONSTANT = 3
shuup.notify.notify_events module
- class shuup.notify.notify_events.PasswordReset(**variable_values)[source]
Bases:
Event- identifier = 'shuup_notify_password_reset'
- name = 'Password Reset'
- description = 'This event is triggered when password reset is requested.'
- bindings = {}
- variables = {'customer_email': <shuup.notify.base.Variable object>, 'recovery_url': <shuup.notify.base.Variable object>, 'site_name': <shuup.notify.base.Variable object>, 'token': <shuup.notify.base.Variable object>, 'uid': <shuup.notify.base.Variable object>, 'user_to_recover': <shuup.notify.base.Variable object>}
shuup.notify.runner module
shuup.notify.script module
- class shuup.notify.script.Step(conditions=(), actions=(), next=StepNext.CONTINUE, cond_op=StepConditionOperator.ALL, enabled=True)[source]
Bases:
object- __init__(conditions=(), actions=(), next=StepNext.CONTINUE, cond_op=StepConditionOperator.ALL, enabled=True)[source]
- property 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:
- 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_entrymethod.If no log target exists or if it has no
add_log_entrymethod, this method does nothing.
- property log_entry_queryset
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.
- __init__(context, data)[source]
- 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:
FieldFrom 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:
Type- name = 'Boolean'
- identifier = 'boolean'
- class shuup.notify.typology.Integer[source]
Bases:
_Number- name = 'Integer Number'
- identifier = 'integer'
- class shuup.notify.typology.Decimal[source]
Bases:
_Number- name = 'Decimal Number'
- identifier = 'decimal'
- class shuup.notify.typology.Language[source]
Bases:
_String- name = 'Language'
- identifier = 'language'
- class shuup.notify.typology.Email[source]
Bases:
_String- name = 'Email Address'
- identifier = 'email'
- class shuup.notify.typology.URL[source]
Bases:
_String- name = 'URL Address'
- identifier = 'url'
- class shuup.notify.typology.Phone[source]
Bases:
_String- name = 'Phone Number'
- identifier = 'phone'
- class shuup.notify.typology.Model(model_label)[source]
Bases:
Type- Parameters:
model_label (str) – Model label in Django
app.Modelformat (e.g.shuup.Order).
- identifier = 'model'
- property name
- __init__(model_label)[source]
- Parameters:
model_label (str) – Model label in Django
app.Modelformat (e.g.shuup.Order).
- model_label = None
- class shuup.notify.typology.Enum(enum_class)[source]
Bases:
Type- identifier = 'enum'
- property name
- enum_class = None
Module contents
- class shuup.notify.ShuupNotifyAppConfig(*args, **kwargs)[source]
Bases:
AppConfig- name = 'shuup.notify'
- verbose_name = 'Shuup Notification Framework'
- label = 'shuup_notify'
- default_auto_field = 'django.db.models.BigAutoField'
- provides = {'admin_module': ['shuup.notify.admin_module:NotifyAdminModule', 'shuup.notify.admin_module:EmailTemplateAdminModule'], 'notify_action': ['shuup.notify.actions:SetDebugFlag', 'shuup.notify.actions:AddOrderLogEntry', 'shuup.notify.actions:SendEmail', 'shuup.notify.actions:AddNotification'], '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_event': ['shuup.notify.notify_events:PasswordReset'], 'notify_script_template': ['shuup.notify.script_templates:PasswordResetTemplate']}
See /provides for details about the
providesvariable.