Skip to main content

Your project description goes here

Project description

https://badge.fury.io/py/django-cms-bootstrap-grid-builder.svg/?style=flat-square https://readthedocs.org/projects/pip/badge/?version=latest&style=flat-square Coverage Status

This tool offers the preliminary drafting of a grid layout consisting of containers, rows and columns, allows you to correctly define the spaces assigned to each page content, and to map these spaces for the different responsive steps.

See our youtube video! https://youtu.be/GXr_xEXcwZw

Documentation

The full documentation is at https://django-cms-bootstrap-grid-builder.readthedocs.io/en/latest/.

Quickstart

warning:

ATTENTION !!! This package requires django-cms already installed.

Install Django CMS bootstrap grid builder:

pip install django-cms-bootstrap-grid-builder

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'bootstrap_grid_builder',
    ...
)

The first thing to do is to override the page creation wizard with the one offered by the package.

# project/urls.py

from cms.cms_wizards import cms_page_wizard, cms_subpage_wizard
from bootstrap_grid_builder.cms_wizards import cms_wizards
from cms.wizards.wizard_pool import wizard_pool

# OVERRIDE CMS WIZARD
wizard_pool.unregister(cms_page_wizard)
wizard_pool.unregister(cms_subpage_wizard)

wizard_pool.register(cms_wizards.cms_page_wizard)
wizard_pool.register(cms_wizards.cms_subpage_wizard)

A variable must be defined to specify the name of the placeholder that will contain the plugins generated by the page creation wizard.

GRID_PLUGIN_STRUCTURE_PLACEHOLDER = "grid_placeholder"

Add the placeholder name inside your home.html template like this:

{% load cms_tags sekizai_tags %}
<html>
    <head>
        <title>{% page_attribute "page_title" %}</title>
        {% render_block "css" %}
    </head>
    <body>
        {% cms_toolbar %}
        {% placeholder "grid_placeholder" %}
        {% render_block "js" %}
    </body>
</html>

Then run migrate to apply package migrations:

$ python manage.py migrate

HowTo customize Grid Plugins & Grid Plugin Models

You can customize the wizard-generated plugins to add functionality or fields to the basic implementation of the tool.

The plugins registered by the package are:

  • GridContainerPlugin

  • GridRowPlugin

  • GridColPlugin

To modify one of these plugins you need:

  • Create an associated model in which to add your own field.

  • Create a plugin in which to insert the field previously added to the model and make the unregister of the base plugin and the register of the plugin just created.

# your_app/models.py

class MyCustomGridContainerPluginModel(GridContainerPluginAbstractModel):
    my_field = models.CharField("My Field", max_length=255)

    class Meta:
        verbose_name = _("My Custom grid container plugin")
        verbose_name_plural = _("My Custom grid container plugins")

# your_app/cms_plugins.py

plugin_pool.unregister_plugin(GridContainerPlugin)

@plugin_pool.register_plugin
class MyCustomGridContainerPlugin(GridContainerPlugin):
    model = MyCustomGridContainerPluginModel
    module = _("Custom")
    name = _("Custom Grid Container")
    render_template = 'path/to/my/custom/template.html'

    fieldsets = (
        (None, {"fields": (
            ("variant_class", "tag_type",),
            ("my_field",),
        )}),
    )

Following these changes it is necessary to set variables in the settings.py file to specify the name of the plugin that must be generated by the wizard instead of the base plugin.

# project/settings.py

GRID_CONTAINER_PLUGIN = "MyCustomGridContainerPlugin"
# this are the others plugins variables
GRID_COL_PLUGIN = ""
GRID_ROW_PLUGIN = ""

After models creation run makemigration & migrate to create yours models in database.

$ python manage.py makemigrations
$ python manage.py migrate

Running Tests

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Development commands

# Back-end
$ pip install -r requirements_dev.txt
$ pre-commit install
$ python manage.py migrate
$ python manage.py runserver

Frontend

This is a Vue.js application for creating custom bootstrap grids throughout an intuitive interface and draggable elements

Browser Compatibility

The page-layout-builder component is compatible with modern browsers such as Chrome, Firefox, Safari, Opera, and Edge. It also supports Internet Explorer 11 but with limited performance.

Frontend source folder ascii tree

/django-cms-bootstrap-grid-builder/src
├─ main.js  //Entrypoint for build
├─ index.js  //Entrypoint for development
├─ components
│  ├─ CustomDragElement.vue
│  ├─ page-layout-builder.vue
│  ├─ GridItem.vue
│  ├─ GridLayout.vue
│  └─ index.js
└─ helpers
   ├─ DOM.js
   ├─ draggableUtils.js
   ├─ responsiveUtils.js
   └─ utils.js

How it works

The informations obtained from the interface configuration are serialized into a JSON object and sent to the backend wich replicates the desired grid structure with Django plugins templates

Development commands

# Front-end
$ npm i -g yarn rimraf @vue/cliz
$ yarn install
$ yarn serve (for development, lauches local live reloading server)
$ yarn build (for production build, creates dist at django-cms-bootstrap-grid-builder/bootstrap_grid_builder/static/cms_plugin_structure/dist)

Credits

Tools used in rendering this package:

History

0.1.0 (2021-11-04)

  • First release on PyPI.

0.1.1 (2021-11-05)

  • Renamed LICENSE file in LICENSE.md for publication on PyPI.

0.1.2 (2021-11-08)

  • Added dist files removing dist from .gitignore and updated README.rst.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-cms-bootstrap-grid-builder-0.1.2.tar.gz (141.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_cms_bootstrap_grid_builder-0.1.2-py2.py3-none-any.whl (146.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-cms-bootstrap-grid-builder-0.1.2.tar.gz.

File metadata

  • Download URL: django-cms-bootstrap-grid-builder-0.1.2.tar.gz
  • Upload date:
  • Size: 141.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django-cms-bootstrap-grid-builder-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fad17ef7ea1394b05032c2e9cd047925b9e42f1db3b58e29a9ea8cb391b23362
MD5 346e32a79da4ffb0c66b0c03dc0e6a16
BLAKE2b-256 b5b26a5055baf71d0aaa7d176cde44380c8ff233e41bd4a057a5505171c949cb

See more details on using hashes here.

File details

Details for the file django_cms_bootstrap_grid_builder-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: django_cms_bootstrap_grid_builder-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 146.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for django_cms_bootstrap_grid_builder-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 177cb5a4b0f9699aae6ff3290803e676eee82ec2e004f4fba47b8282a9a24957
MD5 8b8721ce160c6b1973ff3862f79b5431
BLAKE2b-256 2ca4643c174d910cd9af5d10e808998d4801fbf5deac6313aa1b96da4467148f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page