Example #1
0
    def get_form_defs(self):
        form_defs = []

        if djangoenv.has_installed(
                "wshop.simple_cms") or djangoenv.has_installed("wshop.xtheme"):
            form_defs.append(
                TemplatedWizardFormDef(
                    name="content",
                    template_name="wshop/admin/content/wizard.jinja",
                    form_class=ContentWizardForm,
                    context={
                        "title": _("Configure the initial content pages")
                    },
                    kwargs={"shop": self.object}))

        if djangoenv.has_installed("wshop.notify") and djangoenv.has_installed(
                "wshop.front"):
            form_defs.append(
                TemplatedWizardFormDef(
                    name="behaviors",
                    template_name="wshop/admin/content/wizard.jinja",
                    form_class=BehaviorWizardForm,
                    context={"title": _("Configure some notifications")},
                    kwargs={"shop": self.object}))

        return form_defs
Example #2
0
 def valid(self):
     """
     This pane will be only valid when at least
     SimpleCMS or xTheme or Notify are in INSTALLED APPS
     """
     return (djangoenv.has_installed("wshop.simple_cms")
             or djangoenv.has_installed("wshop.xtheme")
             or djangoenv.has_installed("wshop.notify"))
Example #3
0
    def form_valid(self, form):
        if djangoenv.has_installed(
                "wshop.simple_cms") or djangoenv.has_installed("wshop.xtheme"):
            content_form = form["content"]
            content_form.save()

        if djangoenv.has_installed("wshop.notify"):
            behavior_form = form["behaviors"]
            behavior_form.save()

        configuration.set(None, "wizard_content_completed", True)
Example #4
0
    def text(self):
        cms_xtheme_installed = (djangoenv.has_installed("wshop.simple_cms")
                                or djangoenv.has_installed("wshop.xtheme"))
        notify_installed = djangoenv.has_installed("wshop.notify")

        if cms_xtheme_installed and notify_installed:
            return _(
                "Add the initial content and configure the customer notifications for your shop"
            )
        elif notify_installed:
            return _("Configure notifications for your shop")
        else:
            return _("Add the initial content")
Example #5
0
    def save(self):
        """
        Generate the selected pages is SimpleCMS is installed.
        Generate the Footer if xTheme is installed.
        """
        if not self.is_valid():
            return

        # form must be validated
        if djangoenv.has_installed("wshop.simple_cms"):
            self._handle_simple_cms_save()

        if djangoenv.has_installed(
                "wshop.xtheme") and self.cleaned_data["configure_footer"]:
            self._handle_xtheme_save()
Example #6
0
    def save(self):
        """ Create and configure the selected objects if needed """

        # User wants a order notification and Notify installed and there is no script created previously
        if (self.is_valid() and self.cleaned_data["order_confirm_notification"]
                and djangoenv.has_installed("wshop.notify")
                and not self._get_saved_script()):

            from wshop.front.notify_events import OrderReceived
            from wshop.notify.models.script import Script
            from wshop.notify.script import Step, StepNext

            send_email_action = self._get_send_email_action()

            script = Script(event_identifier=OrderReceived.identifier,
                            name="Order Received",
                            enabled=True,
                            shop=self.shop)
            script.set_steps(
                [Step(next=StepNext.STOP, actions=(send_email_action, ))])
            script.save()

            # save the PK in the configs
            config.set(self.shop, BEHAVIOR_ORDER_CONFIRM_KEY, script.pk)
Example #7
0
    def __init__(self, **kwargs):
        self.shop = kwargs.pop("shop")
        if not self.shop:
            raise ValueError("No shop provided")
        super(ContentWizardForm, self).__init__(**kwargs)

        if djangoenv.has_installed("wshop.simple_cms"):
            pages = self._get_installed_pages()

            self.fields["about_us"] = forms.BooleanField(
                label=_("Create About Us page"),
                required=False,
                initial=True,
                widget=forms.CheckboxInput(
                    attrs={"disabled": (content_data.ABOUT_US_KEY in pages)}))

            # set the help text for different ocasions - whether the content is installed or not
            if content_data.ABOUT_US_KEY in pages:
                self.fields["about_us"].help_text = _(
                    "We have already created an 'About Us' template for you based "
                    "on your shop information. You must review the page and "
                    "change it accordingly.")
            else:
                self.fields["about_us"].help_text = _(
                    "We will create an 'About Us' template for you. "
                    "We will base content of the page on your shop information. "
                    "After we are done, you must review the page and "
                    "change it accordingly.")

            self.fields["privacy_policy"] = forms.BooleanField(
                label=_("Create Privacy Policy page"),
                required=False,
                initial=True,
                widget=forms.CheckboxInput(attrs={
                    "disabled": (content_data.PRIVACY_POLICY_KEY in pages)
                }))
            # set the help text for different ocasions - whether the content is installed or not
            if content_data.PRIVACY_POLICY_KEY in pages:
                self.fields["privacy_policy"].help_text = _(
                    "We have already created a 'Privacy Policy' template "
                    "for you based on your shop information. "
                    "You must review the page and change it accordingly.")
            else:
                self.fields["privacy_policy"].help_text = _(
                    "We will create a 'Privacy Policy' template for you. "
                    "We will base content of the page on "
                    "your shop information. After we are done, "
                    "you must review the page and change it accordingly.")

            self.fields["terms_conditions"] = forms.BooleanField(
                label=_("Create Terms and Conditions page"),
                required=False,
                initial=True,
                widget=forms.CheckboxInput(attrs={
                    "disabled": (
                        content_data.TERMS_AND_CONDITIONS_KEY in pages)
                }),
            )
            # set the help text for different ocasions - whether the content is installed or not
            if content_data.TERMS_AND_CONDITIONS_KEY in pages:
                self.fields["terms_conditions"].help_text = _(
                    "We have already created a 'Terms & Conditions' template "
                    "for you based on your shop information. "
                    "You must review the page and change it accordingly.")
            else:
                self.fields["terms_conditions"].help_text = _(
                    "We will create an 'Terms & Conditions' template "
                    "for you. We will base content of the page on "
                    "your shop information. After we are done, "
                    "you must review the page and change it accordingly.")

            self.fields["refund_policy"] = forms.BooleanField(
                label=_("Create Refund Policy page"),
                required=False,
                initial=True,
                widget=forms.CheckboxInput(attrs={
                    "disabled": (content_data.REFUND_POLICY_KEY in pages)
                }),
            )
            # set the help text for different ocasions - whether the content is installed or not
            if content_data.REFUND_POLICY_KEY in pages:
                self.fields["refund_policy"].help_text = _(
                    "We have already created a 'Refund Policy' template "
                    "for you based on your shop information. "
                    "You must review the page and change it accordingly.")
            else:
                self.fields["refund_policy"].help_text = _(
                    "We will create an 'Refund Policy' template for you. "
                    "We will base content of the page on your shop information. "
                    "After we are done, you must review the page and "
                    "change it accordingly.")

        if djangoenv.has_installed("wshop.xtheme"):
            from wshop.xtheme.models import SavedViewConfig
            svc_pk = config.get(self.shop, CONTENT_FOOTER_KEY)
            svc = SavedViewConfig.objects.filter(pk=svc_pk).first()

            self.fields["configure_footer"] = forms.BooleanField(
                label=_("Configure the footer"),
                required=False,
                initial=True,
                widget=forms.CheckboxInput(attrs={"disabled": bool(svc)}),
                help_text=_(
                    "We will now configure your shop footer and fill it with some of your shop's information. "
                    "Don't worry, you can change this at any time."))
Example #8
0
from logging import getLogger

from django import forms
from django.conf import settings
from django.template import loader as template_loader
from django.utils import translation
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _

from wshop import configuration as config
from wshop.utils import djangoenv

from . import data as content_data

# tries to import xtheme stuff
if djangoenv.has_installed("wshop.xtheme"):
    from wshop.xtheme import XTHEME_GLOBAL_VIEW_NAME
    from wshop.xtheme.plugins.snippets import SnippetsPlugin
    from wshop.xtheme.models import SavedViewConfig, SavedViewConfigStatus
    from wshop.xtheme.layout import Layout
    from wshop.xtheme._theme import get_current_theme

logger = getLogger(__name__)

BEHAVIOR_ORDER_CONFIRM_KEY = "behavior_order_confirm_script_pk"
CONTENT_FOOTER_KEY = "content_footer_pk"


class BehaviorWizardForm(forms.Form):
    order_confirm_notification = forms.BooleanField(
        label=_("Send customer order confirmation email"),