class Meta: exclude = ("shop", ) model = GDPRSettings widgets = { "cookie_banner_content": TextEditorWidget(), "cookie_privacy_excerpt": TextEditorWidget() }
class StripeConfigurationForm(forms.Form): checkout_payment_phase_message = forms.CharField( label=_("Checkout payment phase message"), help_text=_("Set a custom message to use in checkout payment phase."), widget=TextEditorWidget(), required=False) checkout_payment_details_message = forms.CharField( label=_("Checkout card details message"), help_text= _("Set a custom message to use in card details option when doing checkout." ), widget=TextEditorWidget(), required=False) checkout_saved_card_message = forms.CharField( label=_("Checkout saved card message"), help_text= _("Set a custom message to use in saved card option when doing checkout." ), widget=TextEditorWidget(), required=False) saved_card_message = forms.CharField( label=_("Saved card message"), help_text= _("Set a custom message for the saved card section in customer dashboard." ), widget=TextEditorWidget(), required=False) checkout_phase_title = forms.CharField( label=_("Checkout phase title"), help_text=_("Set a custom title for the checkout phase."), required=False)
class Meta: exclude = ("shop",) model = GDPRSettings widgets = { "cookie_banner_content": TextEditorWidget(), "cookie_privacy_excerpt": TextEditorWidget(), "privacy_policy_page": QuickAddPageSelect(editable_model="shuup_simple_cms.Page"), "consent_pages": QuickAddPageMultiSelect() }
class Meta: model = Product fields = ( "accounting_identifier", "barcode", "cost_center", "depth", "gross_weight", "gtin", "height", "manufacturer", "net_weight", "profit_center", "sales_unit", "shipping_mode", "sku", "stock_behavior", "tax_class", "type", "width", # I18n "description", "short_description", "keywords", "name", "slug", "variation_name", ) widgets = { "keywords": forms.TextInput(), "sales_unit": QuickAddSalesUnitSelect(editable_model="shuup.SalesUnit"), "tax_class": QuickAddTaxClassSelect(editable_model="shuup.TaxClass"), "description": TextEditorWidget(), "short_description": forms.TextInput(), }
class Meta: model = Page fields = [ 'title', 'url', 'content', 'available_from', 'available_to', 'identifier', 'visible_in_menu', 'parent', 'list_children_on_page' ] widgets = {"content": TextEditorWidget()}
class Meta: model = Supplier exclude = ("module_data", "options", "contact_address", "deleted") widgets = { "module_identifier": forms.Select, "description": TextEditorWidget() }
class Meta: model = Supplier exclude = ("module_data", "options", "contact_address", "deleted") widgets = { "description": ( TextEditorWidget() if settings.SHUUP_ADMIN_ALLOW_HTML_IN_VENDOR_DESCRIPTION else forms.Textarea(attrs={"rows": 5}) ), }
class Meta: model = None exclude = [ "identifier", "behavior_components", "old_module_identifier", "old_module_data", "shop" ] base_fields = [ "choice_identifier", "name", "description", "enabled", "logo", "tax_class" ] widgets = {"description": TextEditorWidget()}
class Meta: model = Page fields = [ 'title', 'url', 'content', 'available_from', 'available_to', 'identifier', 'visible_in_menu', 'parent', 'template_name', 'list_children_on_page', 'show_child_timestamps', 'render_title', 'available_permission_groups' ] widgets = { "content": TextEditorWidget(attrs={ "data-height": 500, "data-noresize": "true" }) }
class Meta: model = Category fields = ( "parent", "status", "ordering", "visibility", "visible_in_menu", "visibility_groups", "name", "image", "description", "slug", ) widgets = { "status": forms.RadioSelect, "visibility": forms.RadioSelect, "description": TextEditorWidget() }
class Meta: model = Product fields = ( "accounting_identifier", "barcode", "cost_center", "depth", "gross_weight", "gtin", "height", "manufacturer", "net_weight", "profit_center", "sales_unit", "shipping_mode", "sku", "tax_class", "type", "width", # I18n "description", "short_description", "keywords", "name", "slug", "variation_name", ) widgets = { "keywords": forms.TextInput(), "sales_unit": QuickAddSalesUnitSelect(editable_model="shuup.SalesUnit"), "tax_class": QuickAddTaxClassSelect(editable_model="shuup.TaxClass"), "description": (TextEditorWidget() if settings.SHUUP_ADMIN_ALLOW_HTML_IN_PRODUCT_DESCRIPTION else forms.Textarea(attrs={"rows": 5})), "short_description": forms.TextInput(), }
class Meta: model = Page fields = [ "title", "url", "content", "available_from", "available_to", "identifier", "visible_in_menu", "parent", "template_name", "list_children_on_page", "show_child_timestamps", "render_title", "available_permission_groups", ] widgets = { "content": TextEditorWidget(attrs={ "data-height": 500, "data-noresize": "true" }) }
class SendEmail(Action): EMAIL_CONTENT_TYPE_CHOICES = (('plain', _('Plain text')), ('html', _('HTML'))) identifier = "send_email" template_use = TemplateUse.MULTILINGUAL template_fields = { "subject": forms.CharField(required=True, label=_(u"Subject")), "body": forms.CharField(required=True, label=_(u"Email Body"), widget=TextEditorWidget()), "content_type": forms.ChoiceField(required=True, label=_(u"Content type"), choices=EMAIL_CONTENT_TYPE_CHOICES, initial=EMAIL_CONTENT_TYPE_CHOICES[0][0]) } from_email = Binding( _("From email"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=False, help_text=_( 'The from email to be used. It can either be binded to a variable or be a constant like ' '[email protected] or even "Store Support" <*****@*****.**>.')) recipient = Binding(_("Recipient"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=True) reply_to_address = Binding(_("Reply-To"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT) language = Binding(_("Language"), type=Language, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=True) fallback_language = Binding(_("Fallback language"), type=Language, constant_use=ConstantUse.CONSTANT_ONLY, default="en") send_identifier = Binding( _("Send Identifier"), type=Text, constant_use=ConstantUse.CONSTANT_ONLY, required=False, help_text=_( "If set, this identifier will be logged into the event's log target. If the identifier has already " "been logged, the e-mail won't be sent again.")) def execute(self, context): """ :param context: Script Context :type context: shuup.notify.script.Context """ recipient = self.get_value(context, "recipient") if not recipient: context.log(logging.INFO, "%s: Not sending mail, no recipient", self.identifier) return send_identifier = self.get_value(context, "send_identifier") if send_identifier and context.log_entry_queryset.filter( identifier=send_identifier).exists(): context.log(logging.INFO, "%s: Not sending mail, have sent it already (%r)", self.identifier, send_identifier) return languages = [ language for language in [ self.get_value(context, "language"), self.get_value(context, "fallback_language"), ] if language ] strings = self.get_template_values(context, languages) subject = strings.get("subject") body = strings.get("body") content_type = strings.get("content_type") if not (subject and body): context.log( logging.INFO, "%s: Not sending mail to %s, either subject or body empty", self.identifier, recipient) return reply_to = self.get_value(context, "reply_to_address") reply_to = [ reply_to ] if reply_to else None # Push email to a list, unless it is None from_email = self.get_value(context, "from_email") or None subject = " ".join( subject.splitlines()) # Email headers may not contain newlines message = EmailMessage(subject=subject, body=body, to=[recipient], reply_to=reply_to, from_email=from_email) message.content_subtype = content_type message.send() context.log(logging.INFO, "%s: Mail sent to %s :)", self.identifier, recipient) if send_identifier: context.add_log_entry_on_log_target( "Email sent to %s: %s" % (recipient, subject), send_identifier)
class SendEmail(Action): EMAIL_CONTENT_TYPE_CHOICES = (('plain', _('Plain text')), ('html', _('HTML'))) identifier = "send_email" template_use = TemplateUse.MULTILINGUAL template_fields = { "subject": forms.CharField(required=True, label=_(u"Subject")), "body_template": forms.CharField( required=False, label=_("Body Template"), help_text=_( "You can use this template to wrap the HTML body with your custom static template." "Mark the spot for the HTML body with %html_body%."), widget=forms.Textarea()), "body": forms.CharField(required=True, label=_("Email Body"), widget=TextEditorWidget()), "content_type": forms.ChoiceField(required=True, label=_(u"Content type"), choices=EMAIL_CONTENT_TYPE_CHOICES, initial=EMAIL_CONTENT_TYPE_CHOICES[0][0]) } recipient = Binding(_("Recipient"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=True) reply_to_address = Binding(_("Reply-To"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT) cc = Binding( _("Carbon Copy (CC)"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, ) bcc = Binding(_("Blind Carbon Copy (BCC)"), type=Email, constant_use=ConstantUse.VARIABLE_OR_CONSTANT) from_email = Binding( _("From email"), type=Text, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=False, help_text=_( 'Override the default from email to be used. ' 'It can either be binded to a variable or be a constant like ' '[email protected] or even "Store Support" <*****@*****.**>.')) language = Binding(_("Language"), type=Language, constant_use=ConstantUse.VARIABLE_OR_CONSTANT, required=True) fallback_language = Binding(_("Fallback language"), type=Language, constant_use=ConstantUse.CONSTANT_ONLY, default=settings.PARLER_DEFAULT_LANGUAGE_CODE) send_identifier = Binding( _("Send Identifier"), type=Text, constant_use=ConstantUse.CONSTANT_ONLY, required=False, help_text=_( "If set, this identifier will be logged into the event's log target. If the identifier has already " "been logged, the e-mail won't be sent again.")) def execute(self, context): """ :param context: Script Context. :type context: shuup.notify.script.Context """ recipient = get_email_list(self.get_value(context, "recipient")) if not recipient: context.log(logging.INFO, "Info! %s: Not sending mail, no recipient.", self.identifier) return send_identifier = self.get_value(context, "send_identifier") if send_identifier and context.log_entry_queryset.filter( identifier=send_identifier).exists(): context.log( logging.INFO, "Info! %s: Not sending mail, it was already sent (%r).", self.identifier, send_identifier) return languages = [ language for language in [ self.get_value(context, "language"), self.get_value(context, "fallback_language"), ] if language and language in dict(settings.LANGUAGES).keys() ] if not languages: languages = [settings.PARLER_DEFAULT_LANGUAGE_CODE] strings = self.get_template_values(context, languages) subject = strings.get("subject") body = strings.get("body") body_template = strings.get("body_template") if body_template and "%html_body%" in body_template: body = body_template.replace("%html_body%", body) content_type = strings.get("content_type") if not (subject and body): context.log( logging.INFO, "Info! %s: Not sending mail to %s, either subject or body empty.", self.identifier, recipient) return reply_to = get_email_list(self.get_value(context, "reply_to_address")) from_email = self.get_value(context, "from_email") bcc = get_email_list(self.get_value(context, "bcc")) cc = get_email_list(self.get_value(context, "cc")) subject = " ".join( subject.splitlines()) # Email headers may not contain newlines message = EmailMessage(subject=subject, body=body, to=recipient, reply_to=reply_to, from_email=from_email, bcc=bcc, cc=cc) message.content_subtype = content_type message.send() context.log(logging.INFO, "Info! %s: Mail sent to %s.", self.identifier, recipient) if send_identifier: context.add_log_entry_on_log_target( "Info! Email sent to %s: %s" % (recipient, subject), send_identifier)
class BaseThemeFieldsMixin(object): """ Default Theme mixing with fields used in Shuup Front Add this mixing to the theme class if you want to use the same options as the Shuup Front theme provides. """ _base_fields = [ ("hide_prices", forms.BooleanField(required=False, initial=False, label=_("Hide prices"))), ("catalog_mode", forms.BooleanField(required=False, initial=False, label=_("Set shop in catalog mode"))), ("show_supplier_info", forms.BooleanField( required=False, initial=False, label=_("Show supplier info"), help_text=_("Show supplier name in product-box, product-detail, basket- and order-lines") )), ("show_product_detail_section", forms.BooleanField( required=False, initial=True, label=_("Show Product Details"), help_text=_("If you check this, extra information will be shown on product page in frontend.") )), ("show_variation_buttons", forms.BooleanField( required=False, initial=False, label=_("Show Variations as Buttons"), help_text=_("If you check this, the variations will be shown as buttons instead of dropdowns.") )), ("product_detail_extra_tab_title", forms.CharField( required=False, label=_("Product detail extra tab title"), help_text=_("Enter the title for the product detail extra tab.") )), ("product_detail_extra_tab_content", forms.CharField( widget=TextEditorWidget(), required=False, label=_("Product detail extra tab content"), help_text=_("Enter the content for the product detail extra tab.") )) ] def get_product_tabs_options(self): product_detail_tabs = [ ("description", _("Description")), ("details", _("Details")), ("attributes", _("Attributes")), ("files", _("Files")), ] if has_installed("shuup_product_reviews"): product_detail_tabs.append(("product_reviews", _("Product reviews"))) return product_detail_tabs def get_base_fields(self): fields = self._base_fields product_detail_tabs = self.get_product_tabs_options() fields.extend([ ("product_detail_tabs", forms.MultipleChoiceField( required=False, initial=[tab[0] for tab in product_detail_tabs], choices=product_detail_tabs, label=_("Product detail tabs"), help_text=_("Select all tabs that should be renderd in product details.") )) ]) return fields def get_product_details_tabs(self): selected_options = self.get_setting("product_detail_tabs") tab_options = self.get_product_tabs_options() # nothing selected, returns everything by default if not selected_options: return tab_options tabs = [] for selected_option in selected_options: for tab_option in tab_options: if selected_option == tab_option[0]: tabs.append(tab_option) return tabs def should_render_product_detail_tab(self, tab_identifier): return tab_identifier in [tab[0] for tab in self.get_product_details_tabs()]