Skip to content

Commit

Permalink
feat(nossas): add container plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelzinh3 committed Jan 17, 2024
1 parent 0cfca13 commit 6851601
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2 on 2024-01-17 20:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('landpage', '0009_auto_20231020_1853'),
]

operations = [
migrations.AlterField(
model_name='footer',
name='font',
field=models.CharField(blank=True, choices=[('Abel', 'Abel'), ('Anton', 'Anton'), ('Archivo Narrow', 'Archivo Narrow'), ('Arvo', 'Arvo'), ('Asap', 'Asap'), ('Baloo Bhai', 'Baloo Bhai'), ('Bebas Neue Pro', 'Bebas Neue Pro'), ('Bitter', 'Bitter'), ('Bree Serif', 'Bree Serif'), ('Capriola', 'Capriola'), ('Cabin', 'Cabin'), ('Catamaran', 'Catamaran'), ('Crimson Text', 'Crimson Text'), ('Cuprum', 'Cuprum'), ('David Libre', 'David Libre'), ('Dosis', 'Dosis'), ('Droid Sans', 'Droid Sans'), ('Exo', 'Exo'), ('Exo 2', 'Exo 2'), ('Fira Sans', 'Fira Sans'), ('Fjalla One', 'Fjalla One'), ('Francois One', 'Francois One'), ('Gidugu', 'Gidugu'), ('Hind', 'Hind'), ('Inconsolata', 'Inconsolata'), ('Indie Flower', 'Indie Flower'), ('Josefin Sans', 'Josefin Sans'), ('Karla', 'Karla'), ('Lalezar', 'Lalezar'), ('Lato', 'Lato'), ('Libre Baskerville', 'Libre Baskerville'), ('Lobster', 'Lobster'), ('Lora', 'Lora'), ('Merriweather Sans', 'Merriweather Sans'), ('Montserrat', 'Montserrat'), ('Muli', 'Muli'), ('Noto Serif', 'Noto Serif'), ('Nunito Sans', 'Nunito Sans'), ('Open Sans', 'Open Sans'), ('Open Sans Condensed', 'Open Sans Condensed'), ('Oswald', 'Oswald'), ('Oxygen', 'Oxygen'), ('PT Sans', 'PT Sans'), ('PT Serif', 'PT Serif'), ('Pacifico', 'Pacifico'), ('Playfair Display', 'Playfair Display'), ('Poiret One', 'Poiret One'), ('Poppins', 'Poppins'), ('Quicksand', 'Quicksand'), ('Raleway', 'Raleway'), ('Roboto', 'Roboto'), ('Roboto Condensed', 'Roboto Condensed'), ('Roboto Mono', 'Roboto Mono'), ('Roboto Slab', 'Roboto Slab'), ('Ruslan Display', 'Ruslan Display'), ('Signika', 'Signika'), ('Slabo 27px', 'Slabo 27px'), ('Source Sans Pro', 'Source Sans Pro'), ('Titillium Web', 'Titillium Web'), ('Ubuntu', 'Ubuntu'), ('Ubuntu Condensed', 'Ubuntu Condensed'), ('Varela Round', 'Varela Round'), ('Yanone Kaffeesatz', 'Yanone Kaffeesatz')], max_length=100, null=True, verbose_name='Estilo de fonte'),
),
migrations.AlterField(
model_name='navbar',
name='font',
field=models.CharField(blank=True, choices=[('Abel', 'Abel'), ('Anton', 'Anton'), ('Archivo Narrow', 'Archivo Narrow'), ('Arvo', 'Arvo'), ('Asap', 'Asap'), ('Baloo Bhai', 'Baloo Bhai'), ('Bebas Neue Pro', 'Bebas Neue Pro'), ('Bitter', 'Bitter'), ('Bree Serif', 'Bree Serif'), ('Capriola', 'Capriola'), ('Cabin', 'Cabin'), ('Catamaran', 'Catamaran'), ('Crimson Text', 'Crimson Text'), ('Cuprum', 'Cuprum'), ('David Libre', 'David Libre'), ('Dosis', 'Dosis'), ('Droid Sans', 'Droid Sans'), ('Exo', 'Exo'), ('Exo 2', 'Exo 2'), ('Fira Sans', 'Fira Sans'), ('Fjalla One', 'Fjalla One'), ('Francois One', 'Francois One'), ('Gidugu', 'Gidugu'), ('Hind', 'Hind'), ('Inconsolata', 'Inconsolata'), ('Indie Flower', 'Indie Flower'), ('Josefin Sans', 'Josefin Sans'), ('Karla', 'Karla'), ('Lalezar', 'Lalezar'), ('Lato', 'Lato'), ('Libre Baskerville', 'Libre Baskerville'), ('Lobster', 'Lobster'), ('Lora', 'Lora'), ('Merriweather Sans', 'Merriweather Sans'), ('Montserrat', 'Montserrat'), ('Muli', 'Muli'), ('Noto Serif', 'Noto Serif'), ('Nunito Sans', 'Nunito Sans'), ('Open Sans', 'Open Sans'), ('Open Sans Condensed', 'Open Sans Condensed'), ('Oswald', 'Oswald'), ('Oxygen', 'Oxygen'), ('PT Sans', 'PT Sans'), ('PT Serif', 'PT Serif'), ('Pacifico', 'Pacifico'), ('Playfair Display', 'Playfair Display'), ('Poiret One', 'Poiret One'), ('Poppins', 'Poppins'), ('Quicksand', 'Quicksand'), ('Raleway', 'Raleway'), ('Roboto', 'Roboto'), ('Roboto Condensed', 'Roboto Condensed'), ('Roboto Mono', 'Roboto Mono'), ('Roboto Slab', 'Roboto Slab'), ('Ruslan Display', 'Ruslan Display'), ('Signika', 'Signika'), ('Slabo 27px', 'Slabo 27px'), ('Source Sans Pro', 'Source Sans Pro'), ('Titillium Web', 'Titillium Web'), ('Ubuntu', 'Ubuntu'), ('Ubuntu Condensed', 'Ubuntu Condensed'), ('Varela Round', 'Varela Round'), ('Yanone Kaffeesatz', 'Yanone Kaffeesatz')], max_length=100, null=True, verbose_name='Estilo de fonte'),
),
]
18 changes: 18 additions & 0 deletions app/contrib/frontend/migrations/0005_alter_button_font.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2024-01-17 20:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('frontend', '0004_auto_20231005_1254'),
]

operations = [
migrations.AlterField(
model_name='button',
name='font',
field=models.CharField(blank=True, choices=[('Abel', 'Abel'), ('Anton', 'Anton'), ('Archivo Narrow', 'Archivo Narrow'), ('Arvo', 'Arvo'), ('Asap', 'Asap'), ('Baloo Bhai', 'Baloo Bhai'), ('Bebas Neue Pro', 'Bebas Neue Pro'), ('Bitter', 'Bitter'), ('Bree Serif', 'Bree Serif'), ('Capriola', 'Capriola'), ('Cabin', 'Cabin'), ('Catamaran', 'Catamaran'), ('Crimson Text', 'Crimson Text'), ('Cuprum', 'Cuprum'), ('David Libre', 'David Libre'), ('Dosis', 'Dosis'), ('Droid Sans', 'Droid Sans'), ('Exo', 'Exo'), ('Exo 2', 'Exo 2'), ('Fira Sans', 'Fira Sans'), ('Fjalla One', 'Fjalla One'), ('Francois One', 'Francois One'), ('Gidugu', 'Gidugu'), ('Hind', 'Hind'), ('Inconsolata', 'Inconsolata'), ('Indie Flower', 'Indie Flower'), ('Josefin Sans', 'Josefin Sans'), ('Karla', 'Karla'), ('Lalezar', 'Lalezar'), ('Lato', 'Lato'), ('Libre Baskerville', 'Libre Baskerville'), ('Lobster', 'Lobster'), ('Lora', 'Lora'), ('Merriweather Sans', 'Merriweather Sans'), ('Montserrat', 'Montserrat'), ('Muli', 'Muli'), ('Noto Serif', 'Noto Serif'), ('Nunito Sans', 'Nunito Sans'), ('Open Sans', 'Open Sans'), ('Open Sans Condensed', 'Open Sans Condensed'), ('Oswald', 'Oswald'), ('Oxygen', 'Oxygen'), ('PT Sans', 'PT Sans'), ('PT Serif', 'PT Serif'), ('Pacifico', 'Pacifico'), ('Playfair Display', 'Playfair Display'), ('Poiret One', 'Poiret One'), ('Poppins', 'Poppins'), ('Quicksand', 'Quicksand'), ('Raleway', 'Raleway'), ('Roboto', 'Roboto'), ('Roboto Condensed', 'Roboto Condensed'), ('Roboto Mono', 'Roboto Mono'), ('Roboto Slab', 'Roboto Slab'), ('Ruslan Display', 'Ruslan Display'), ('Signika', 'Signika'), ('Slabo 27px', 'Slabo 27px'), ('Source Sans Pro', 'Source Sans Pro'), ('Titillium Web', 'Titillium Web'), ('Ubuntu', 'Ubuntu'), ('Ubuntu Condensed', 'Ubuntu Condensed'), ('Varela Round', 'Varela Round'), ('Yanone Kaffeesatz', 'Yanone Kaffeesatz')], max_length=100, null=True, verbose_name='Estilo de fonte'),
),
]
1 change: 1 addition & 0 deletions app/nossas/plugins/cms_plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .button import *
from .breadcrumb import *
from .breakline import *
from .container import *
from .footer import *
from .grid import *
from .navbar import *
Expand Down
5 changes: 0 additions & 5 deletions app/nossas/plugins/cms_plugins/button.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
from django.utils.translation import ugettext_lazy as _

from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool

from djangocms_frontend.contrib.link.cms_plugins import LinkPlugin

from nossas.plugins.forms.buttonform import LinkButtonForm

# from nossas.design.cms_plugins import UIPaddingMixin, UIBackgroundMixin, CMSUIPlugin
# from nossas.plugins.models.buttonmodel import Button
# from nossas.plugins.forms.buttonform import ButtonPluginForm


@plugin_pool.register_plugin
class LinkButtonPlugin(LinkPlugin):
Expand Down
34 changes: 34 additions & 0 deletions app/nossas/plugins/cms_plugins/container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from cms.plugin_pool import plugin_pool

from nossas.design.cms_plugins import UICMSPluginBase

from nossas.plugins.models.containermodel import Container
from nossas.plugins.forms.containerform import ContainerPluginForm

@plugin_pool.register_plugin
class ContainerPlugin(UICMSPluginBase):
name = "Container"
module = "NOSSAS"
model = Container
form = ContainerPluginForm
render_template = "nossas/plugins/container.html"
allow_children = True
fieldsets = (
("Atributos", {"fields": ["attributes"]}),
("Fundo", {"fields": ["background"]})
)

def get_form(self, request, obj, change, **kwargs):
if not change:
self.form = ContainerPluginForm

return super().get_form(request, obj, change, **kwargs)

def get_fieldsets(self, request, obj=None):
if not obj:
self.fieldsets = (
(None, {"fields": ["attributes"]}),
("Fundo", {"fields": ["background"]}),
)

return super().get_fieldsets(request, obj)
16 changes: 16 additions & 0 deletions app/nossas/plugins/forms/containerform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django import forms

from nossas.design.forms import (
UIBackgroundFormMixin
)

from nossas.plugins.models.containermodel import Container


class ContainerPluginForm(
UIBackgroundFormMixin, forms.ModelForm
):
class Meta:
model = Container
entangled_fields = {"attributes": []}

27 changes: 27 additions & 0 deletions app/nossas/plugins/migrations/0009_container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2 on 2024-01-17 20:42

from django.db import migrations, models
import django.db.models.deletion
import nossas.design.models


class Migration(migrations.Migration):

dependencies = [
('cms', '0022_auto_20180620_1551'),
('plugins', '0008_accordion'),
]

operations = [
migrations.CreateModel(
name='Container',
fields=[
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='plugins_container', serialize=False, to='cms.cmsplugin')),
('attributes', models.JSONField(blank=True, null=True)),
],
options={
'abstract': False,
},
bases=(nossas.design.models.UIBackgroundMixin, 'cms.cmsplugin'),
),
]
5 changes: 4 additions & 1 deletion app/nossas/plugins/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from .accordionmodel import *
from .boxmodel import *
from .buttonmodel import *
from .containermodel import *
from .gridmodel import *
from .navbarmodel import *
from .slidermodel import *
from .slidermodel import *
2 changes: 0 additions & 2 deletions app/nossas/plugins/models/boxmodel.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from nossas.design.models import (
UICMSPlugin,
UIBackgroundMixin,
UIPaddingMixin,
UIBorderMixin,
)


class Box(
UIBackgroundMixin,
UIPaddingMixin,
UIBorderMixin,
UICMSPlugin,
):
Expand Down
5 changes: 5 additions & 0 deletions app/nossas/plugins/models/containermodel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from nossas.design.models import UICMSPlugin, UIBackgroundMixin


class Container(UIBackgroundMixin, UICMSPlugin):
pass
12 changes: 0 additions & 12 deletions app/nossas/plugins/templates/nossas/plugins/box.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,3 @@
{% endfor %}
</div>


{% comment %} {% load cms_tags frontend %}{% spaceless %}
{% if instance.parent.plugin_type == "CardLayoutPlugin" and instance.parent.get_plugin_instance.0.card_type == "row" %}<div class="col mb-3">{% endif %}
<{{ instance.tag_type }}{{ instance.get_attributes }}>
{% with parent=instance %}
{% for plugin in instance.child_plugin_instances %}
{% with forloop as parentloop %}{% render_plugin plugin %}{% endwith %}
{% endfor %}
{% endwith %}
</{{ instance.tag_type }}>
{% if instance.parent.plugin_type == "CardLayoutPlugin" and instance.parent.get_plugin_instance.0.card_type == "row" %}</div>{% endif %}
{% endspaceless %} {% endcomment %}
9 changes: 9 additions & 0 deletions app/nossas/plugins/templates/nossas/plugins/container.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% load cms_tags %}

<div class="{{ instance.classes }}">
<div class="container">
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
</div>
</div>
1 change: 1 addition & 0 deletions app/nossas/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"plugins": [
"TextPlugin",
"BoxPlugin",
"ContainerPlugin",
"SliderPlugin",
"TeamAccordionPlugin",
"FilterCampaignListPlugin",
Expand Down

0 comments on commit 6851601

Please sign in to comment.