shuup.notify.script_template package

Submodules

shuup.notify.script_template.factory module

shuup.notify.script_template.factory.generic_send_email_script_template_factory(identifier, event, name, description, help_text, initial=None)[source]

A factory to create a generic script template based on GenericSendEmailScriptTemplate class.

Parameters:
  • 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
  • initial (dict|None) – the initial data to use in forms or None

shuup.notify.script_template.generic module

class shuup.notify.script_template.generic.GenericScriptTemplateEmailContentForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.forms.Form

Generic form which contains the content of a email: subject and body.

base_fields = OrderedDict([('subject', <django.forms.fields.CharField object>), ('body', <django.forms.fields.CharField object>)])
declared_fields = OrderedDict([('subject', <django.forms.fields.CharField object>), ('body', <django.forms.fields.CharField object>)])
media
class shuup.notify.script_template.generic.GenericScriptTemplateEmailForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)[source]

Bases: django.forms.forms.Form

Generic form which contains a destination of the email.

SEND_TO_CHOICES = [('customer', 'Customer'), ('other', 'Other destination')]
clean()[source]
base_fields = OrderedDict([('send_to', <django.forms.fields.ChoiceField object>), ('recipient', <django.forms.fields.EmailField object>)])
declared_fields = OrderedDict([('send_to', <django.forms.fields.ChoiceField object>), ('recipient', <django.forms.fields.EmailField object>)])
media
class shuup.notify.script_template.generic.GenericSendEmailScriptTemplate(script_instance=None)[source]

Bases: shuup.notify.script_template.BaseScriptTemplate

A generic ScriptTemplate which needs email configurations such as recipient, subject and body.

This class also deals with a multi-language form to receive translated email’s subject and body.

The form of this ScriptTemplate is a FormGroup which will contain a base form which has no translation and also intances of multilingual_form_class, one for each available LANGUAGE. Only the form for the default language (provided by PARLER_DEFAULT_LANGUAGE_CODE setting) is required.

Ivar:django.form.Form base_form_class: the main form, not included in the group of translation fields.
Ivar:django.form.Form multilingual_form_class: the form which will be created for each available language.
Parameters:script_instance (shuup.notify.models.script.Script|None) – script instance to change or None
template_name = 'notify/admin/generic_script_template.jinja'
extra_js_template_name = 'notify/admin/generic_script_template_extra_js.jinja'
base_form_class

alias of GenericScriptTemplateEmailForm

multilingual_form_class

alias of GenericScriptTemplateEmailContentForm

get_script_steps(form)[source]
get_context_data()[source]
get_form(**kwargs)[source]

Create a FormGroup and put the necessary forms inside.

get_initial()[source]
can_edit_script()[source]
We can only edit the script when:
  • the event is what we expect
  • has a single SendMail action in steps (oterwise we don’t know which to edit)

Module contents

class shuup.notify.script_template.BaseScriptTemplate(script_instance=None)[source]

Bases: shuup.notify.base.ScriptTemplate

A base ScriptTemplate class which provides implementation for create and update the script.

Parameters:script_instance (shuup.notify.models.script.Script|None) – script instance to change or None
get_script_steps(form=None)[source]

Returns a list of Steps to use in the script.

Parameters:form (django.forms.Form|None) – validated form to use or None
Returns:list of steps
Return type:list[shuup.notify.Step]
create_script(shop, form=None)[source]

Creates the script based on the event and the steps

update_script(form)[source]

Change the steps and save the script