def _fill_page_body(self, page, lang):
     ph_en = page.placeholders.get(slot="body")
     # add misc plugins
     mcol1 = add_plugin(ph_en, "MultiColumnPlugin", lang, position="first-child")
     add_plugin(ph_en, "ColumnPlugin", lang, position="first-child", target=mcol1)
     col2 = add_plugin(ph_en, "ColumnPlugin", lang, position="first-child", target=mcol1)
     mcol2 = add_plugin(ph_en, "MultiColumnPlugin", lang, position="first-child", target=col2)
     add_plugin(ph_en, "ColumnPlugin", lang, position="first-child", target=mcol2)
     col4 = add_plugin(ph_en, "ColumnPlugin", lang, position="first-child", target=mcol2)
     # add a *nested* link plugin
     add_plugin(ph_en, "LinkPlugin", lang, target=col4,
                                 name="A Link", url="https://www.django-cms.org")
     static_placeholder = StaticPlaceholder(code=str(uuid.uuid4()), site_id=1)
     static_placeholder.save()
     add_plugin(static_placeholder.draft, "TextPlugin", lang, body="example content")
Exemple #2
0
    def init_repanier(cls):
        from repanier.const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR
        from repanier.models.producer import Producer
        from repanier.models.bankaccount import BankAccount
        from repanier.models.staff import Staff
        from repanier.models.customer import Customer

        # Create the configuration record managed via the admin UI
        config = Configuration.objects.filter(id=DECIMAL_ONE).first()
        if config is not None:
            return config
        group_name = settings.REPANIER_SETTINGS_GROUP_NAME
        site = Site.objects.get_current()
        if site is not None:
            site.name = group_name
            site.domain = group_name
            site.save()
        config = Configuration.objects.create(
            group_name=group_name,
            name=PERMANENCE_NAME_PERMANENCE,
            bank_account="BE99 9999 9999 9999",
            currency=CURRENCY_EUR)
        config.init_email()
        config.save()

        # Create firsts users
        Producer.get_or_create_group()
        customer_buyinggroup = Customer.get_or_create_group()
        very_first_customer = Customer.get_or_create_the_very_first_customer()

        BankAccount.open_account(customer_buyinggroup=customer_buyinggroup,
                                 very_first_customer=very_first_customer)

        coordinator = Staff.get_or_create_any_coordinator()
        Staff.get_or_create_order_responsible()
        Staff.get_or_create_invoice_responsible()
        # Create and publish first web page
        if not coordinator.is_webmaster:
            # This should not be the case...
            return

        from cms.models import StaticPlaceholder
        from cms.constants import X_FRAME_OPTIONS_DENY
        from cms import api
        page = api.create_page(title=_("Home"),
                               soft_root=False,
                               template=settings.CMS_TEMPLATE_HOME,
                               language=settings.LANGUAGE_CODE,
                               published=True,
                               parent=None,
                               xframe_options=X_FRAME_OPTIONS_DENY,
                               in_navigation=True)
        try:
            # New in CMS 3.5
            page.set_as_homepage()
        except:
            pass

        placeholder = page.placeholders.get(slot="home-hero")
        api.add_plugin(placeholder=placeholder,
                       plugin_type='TextPlugin',
                       language=settings.LANGUAGE_CODE,
                       body=settings.CMS_TEMPLATE_HOME_HERO)
        placeholder = page.placeholders.get(slot="home-col-1")
        api.add_plugin(placeholder=placeholder,
                       plugin_type='TextPlugin',
                       language=settings.LANGUAGE_CODE,
                       body=settings.CMS_TEMPLATE_HOME_COL_1)
        placeholder = page.placeholders.get(slot="home-col-2")
        api.add_plugin(placeholder=placeholder,
                       plugin_type='TextPlugin',
                       language=settings.LANGUAGE_CODE,
                       body=settings.CMS_TEMPLATE_HOME_COL_2)
        placeholder = page.placeholders.get(slot="home-col-3")
        api.add_plugin(placeholder=placeholder,
                       plugin_type='TextPlugin',
                       language=settings.LANGUAGE_CODE,
                       body=settings.CMS_TEMPLATE_HOME_COL_3)
        static_placeholder = StaticPlaceholder(code="footer",
                                               # site_id=1
                                               )
        static_placeholder.save()
        api.add_plugin(placeholder=static_placeholder.draft,
                       plugin_type='TextPlugin',
                       language=settings.LANGUAGE_CODE,
                       body='hello world footer')
        static_placeholder.publish(request=None,
                                   language=settings.LANGUAGE_CODE,
                                   force=True)
        api.publish_page(page=page,
                         user=coordinator.user,
                         language=settings.LANGUAGE_CODE)

        return config
Exemple #3
0
    def init_repanier(cls):
        from repanier.const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR
        from repanier.models.producer import Producer
        from repanier.models.bankaccount import BankAccount
        from repanier.models.staff import Staff
        from repanier.models.customer import Customer
        from repanier.models.lut import LUT_DepartmentForCustomer

        logger.debug("######## start of init_repanier")

        # Create the configuration record managed via the admin UI
        config = Configuration.objects.filter(id=DECIMAL_ONE).first()
        if config is not None:
            return config
        site = Site.objects.get_current()
        if site is not None:
            site.name = settings.REPANIER_SETTINGS_GROUP_NAME
            site.domain = settings.ALLOWED_HOSTS[0]
            site.save()
        config = Configuration.objects.create(
            group_name=settings.REPANIER_SETTINGS_GROUP_NAME,
            name=PERMANENCE_NAME_PERMANENCE,
            bank_account="BE99 9999 9999 9999",
            currency=CURRENCY_EUR,
        )
        config.init_email()
        config.save()

        # Create firsts users
        Producer.get_or_create_group()
        customer_buyinggroup = Customer.get_or_create_group()
        very_first_customer = Customer.get_or_create_the_very_first_customer()

        BankAccount.open_account(
            customer_buyinggroup=customer_buyinggroup,
            very_first_customer=very_first_customer,
        )
        very_first_customer = Customer.get_or_create_the_very_first_customer()
        coordinator = Staff.get_or_create_any_coordinator()
        Staff.get_or_create_order_responsible()
        Staff.get_or_create_invoice_responsible()
        # Create and publish first web page
        if not coordinator.is_webmaster:
            # This should not be the case...
            return

        from cms.models import StaticPlaceholder
        from cms.constants import X_FRAME_OPTIONS_DENY
        from cms import api

        page = api.create_page(
            title=_("Home"),
            soft_root=False,
            template=settings.CMS_TEMPLATE_HOME,
            language=settings.LANGUAGE_CODE,
            published=True,
            parent=None,
            xframe_options=X_FRAME_OPTIONS_DENY,
            in_navigation=True,
        )
        try:
            # New in CMS 3.5
            page.set_as_homepage()
        except:
            pass

        placeholder = page.placeholders.get(slot="home-hero")
        api.add_plugin(
            placeholder=placeholder,
            plugin_type="TextPlugin",
            language=settings.LANGUAGE_CODE,
            body=settings.CMS_TEMPLATE_HOME_HERO,
        )
        static_placeholder = StaticPlaceholder(
            code="footer",
            # site_id=1
        )
        static_placeholder.save()
        api.add_plugin(
            placeholder=static_placeholder.draft,
            plugin_type="TextPlugin",
            language=settings.LANGUAGE_CODE,
            body="hello world footer",
        )
        static_placeholder.publish(
            request=None, language=settings.LANGUAGE_CODE, force=True
        )
        api.publish_page(
            page=page,
            user=coordinator.customer_responsible.user,
            language=settings.LANGUAGE_CODE,
        )

        if LUT_DepartmentForCustomer.objects.count() == 0:
            # Generate a template of LUT_DepartmentForCustomer
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Vegetable"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Basket of vegetables"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Salad"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Tomato"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Potato"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Green"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Cabbage"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Fruit"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Basket of fruits"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Apple"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Pear"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Plum"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Bakery"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Flour"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Bread"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Pastry"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Butchery"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Delicatessen"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Chicken"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Pork"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Beef"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Beef and pork"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Veal"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Lamb"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Grocery"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Takeaway"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Pasta"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Chocolate"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(short_name=_("Oil"), parent=parent)
            LUT_DepartmentForCustomer.objects.create(short_name=_("Egg"), parent=parent)
            LUT_DepartmentForCustomer.objects.create(short_name=_("Jam"), parent=parent)
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Cookie"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Creamery"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Dairy"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Cow cheese"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Goat cheese"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Sheep cheese"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Mixed cheese"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Icecream"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Cup of icecream"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Icecream per liter"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Icecream in frisco"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Icecream cake"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Sorbet"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Cup of sorbet"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Sorbet per liter"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Drink"))
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Juice"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Coffee"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(short_name=_("Tea"), parent=parent)
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Herbal tea"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Wine"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Aperitif"), parent=parent
            )
            LUT_DepartmentForCustomer.objects.create(
                short_name=_("Liqueurs"), parent=parent
            )
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Hygiene"))
            parent = LUT_DepartmentForCustomer.objects.create(short_name=_("Deposit"))
            parent = LUT_DepartmentForCustomer.objects.create(
                short_name=_("Subscription")
            )

        logger.debug("######## end of init_repanier")

        return config
Exemple #4
0
    def init_repanier(cls):
        from repanier.const import DECIMAL_ONE, PERMANENCE_NAME_PERMANENCE, CURRENCY_EUR
        from repanier.models.producer import Producer
        from repanier.models.bankaccount import BankAccount
        from repanier.models.staff import Staff
        from repanier.models.customer import Customer

        # Create the configuration record managed via the admin UI
        config = Configuration.objects.filter(id=DECIMAL_ONE).first()
        if config is not None:
            return config
        site = Site.objects.get_current()
        if site is not None:
            site.name = settings.REPANIER_SETTINGS_GROUP_NAME
            site.domain = settings.ALLOWED_HOSTS[0]
            site.save()
        config = Configuration.objects.create(
            group_name=settings.REPANIER_SETTINGS_GROUP_NAME,
            name=PERMANENCE_NAME_PERMANENCE,
            bank_account="BE99 9999 9999 9999",
            currency=CURRENCY_EUR
        )
        config.init_email()
        config.save()

        # Create firsts users
        Producer.get_or_create_group()
        customer_buyinggroup = Customer.get_or_create_group()
        very_first_customer = Customer.get_or_create_the_very_first_customer()

        BankAccount.open_account(
            customer_buyinggroup=customer_buyinggroup,
            very_first_customer=very_first_customer
        )

        coordinator = Staff.get_or_create_any_coordinator()
        Staff.get_or_create_order_responsible()
        Staff.get_or_create_invoice_responsible()
        # Create and publish first web page
        if not coordinator.is_webmaster:
            # This should not be the case...
            return

        from cms.models import StaticPlaceholder
        from cms.constants import X_FRAME_OPTIONS_DENY
        from cms import api
        page = api.create_page(
            title=_("Home"),
            soft_root=False,
            template=settings.CMS_TEMPLATE_HOME,
            language=settings.LANGUAGE_CODE,
            published=True,
            parent=None,
            xframe_options=X_FRAME_OPTIONS_DENY,
            in_navigation=True
        )
        try:
            # New in CMS 3.5
            page.set_as_homepage()
        except:
            pass

        placeholder = page.placeholders.get(slot="home-hero")
        api.add_plugin(
            placeholder=placeholder,
            plugin_type='TextPlugin',
            language=settings.LANGUAGE_CODE,
            body=settings.CMS_TEMPLATE_HOME_HERO)
        placeholder = page.placeholders.get(slot="home-col-1")
        api.add_plugin(
            placeholder=placeholder,
            plugin_type='TextPlugin',
            language=settings.LANGUAGE_CODE,
            body=settings.CMS_TEMPLATE_HOME_COL_1)
        placeholder = page.placeholders.get(slot="home-col-2")
        api.add_plugin(
            placeholder=placeholder,
            plugin_type='TextPlugin',
            language=settings.LANGUAGE_CODE,
            body=settings.CMS_TEMPLATE_HOME_COL_2)
        placeholder = page.placeholders.get(slot="home-col-3")
        api.add_plugin(
            placeholder=placeholder,
            plugin_type='TextPlugin',
            language=settings.LANGUAGE_CODE,
            body=settings.CMS_TEMPLATE_HOME_COL_3)
        static_placeholder = StaticPlaceholder(
            code="footer",
            # site_id=1
        )
        static_placeholder.save()
        api.add_plugin(
            placeholder=static_placeholder.draft,
            plugin_type='TextPlugin',
            language=settings.LANGUAGE_CODE,
            body='hello world footer'
        )
        static_placeholder.publish(
            request=None,
            language=settings.LANGUAGE_CODE,
            force=True
        )
        api.publish_page(
            page=page,
            user=coordinator.user,
            language=settings.LANGUAGE_CODE)

        return config