-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add bootstrap grid plugin with choices
- Loading branch information
1 parent
e4962f1
commit 4447e4b
Showing
8 changed files
with
256 additions
and
5 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/nossas/apps/institutional/migrations/0002_auto_20240111_2048.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2 on 2024-01-11 20:48 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('institutional', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='institutionalinformation', | ||
name='contact_phone', | ||
field=models.CharField(max_length=16, verbose_name='Telefone de contato'), | ||
), | ||
migrations.AlterField( | ||
model_name='institutionalinformation', | ||
name='zipcode', | ||
field=models.CharField(max_length=9, verbose_name='CEP'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
from cms.plugin_base import CMSPluginBase | ||
from cms.plugin_pool import plugin_pool | ||
|
||
from nossas.plugins.models.gridmodel import Grid, Column | ||
|
||
@plugin_pool.register_plugin | ||
class BootstrapGridPlugin(CMSPluginBase): | ||
name = "Grid" | ||
module = "NOSSAS" | ||
render_template = "nossas/plugins/grid.html" | ||
model = Grid | ||
render_template = "nossas/plugins/grid.html" | ||
allow_children = True | ||
child_classes = [ | ||
"BootstrapColumnPlugin" | ||
] | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class BootstrapColumnPlugin(CMSPluginBase): | ||
name = "Coluna" | ||
module = "NOSSAS" | ||
model = Column | ||
render_template = "nossas/plugins/column.html" | ||
allow_children = True | ||
|
||
def render(self, context, instance, placeholder): | ||
parent_instance = instance.parent.get_plugin_instance()[0] | ||
context['parent_instance'] = parent_instance | ||
return super().render(context, instance, placeholder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 3.2 on 2024-01-11 20:48 | ||
|
||
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', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Grid', | ||
fields=[ | ||
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='plugins_grid', serialize=False, to='cms.cmsplugin')), | ||
('attributes', models.JSONField(blank=True, null=True)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(nossas.design.models.UIBackgroundMixin, 'cms.cmsplugin'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 3.2 on 2024-01-11 22:18 | ||
|
||
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', '0002_grid'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Column', | ||
fields=[ | ||
('cmsplugin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, related_name='plugins_column', serialize=False, to='cms.cmsplugin')), | ||
('attributes', models.JSONField(blank=True, null=True)), | ||
('col', models.CharField(choices=[('', 'Auto'), ('g-col-1', 'Col 1'), ('g-col-2', 'Col 2'), ('g-col-3', 'Col 3'), ('g-col-4', 'Col 4'), ('g-col-5', 'Col 5'), ('g-col-6', 'Col 6'), ('g-col-7', 'Col 7'), ('g-col-8', 'Col 8'), ('g-col-9', 'Col 9'), ('g-col-10', 'Col 10'), ('g-col-11', 'Col 11'), ('g-col-12', 'Col 12')], default='', help_text='Defina manualmente o número de colunas que esta coluna ocupará.', max_length=15, verbose_name='Coluna')), | ||
('rows', models.CharField(choices=[('', 'Auto'), ('grid-row: 2', 'Linha 2'), ('grid-row: 3', 'Linha 3'), ('grid-row: 4', 'Linha 4')], default='', help_text='Escolha manualmente o número da linha que esta coluna ocupará.', max_length=15, verbose_name='Linhas')), | ||
('col_start_at', models.CharField(choices=[('', 'Auto'), ('g-start-1', 'Start at Col 1'), ('g-start-2', 'Start at Col 2'), ('g-start-3', 'Start at Col 3'), ('g-start-4', 'Start at Col 4'), ('g-start-5', 'Start at Col 5'), ('g-start-6', 'Start at Col 6'), ('g-start-7', 'Start at Col 7'), ('g-start-8', 'Start at Col 8'), ('g-start-9', 'Start at Col 9'), ('g-start-10', 'Start at Col 10'), ('g-start-11', 'Start at Col 11'), ('g-start-12', 'Start at Col 12')], default='', help_text='Defina em qual coluna o elemento deve iniciar.', max_length=30, verbose_name='Alinhamento horizontal da coluna')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(nossas.design.models.UIBackgroundMixin, 'cms.cmsplugin'), | ||
), | ||
migrations.AddField( | ||
model_name='grid', | ||
name='grid_gap', | ||
field=models.CharField(choices=[('row-gap: 0;', 'Sem espaçamento'), ('row-gap: 4;', 'Pequeno'), ('row-gap: 8;', 'Grande')], default='row-gap: 0;', help_text='Selecione o espaço entre colunas do Grid.', max_length=15, verbose_name='Espaçamento do Grid'), | ||
), | ||
migrations.AddField( | ||
model_name='grid', | ||
name='grid_layout', | ||
field=models.CharField(choices=[('', 'Auto'), ('g-col-12', '1 Coluna'), ('g-col-12 g-col-md-6', '2 Colunas'), ('g-col-12 g-col-md-4', '3 Colunas'), ('g-col-12 g-col-sm-2 g-col-4', '4 Colunas'), ('g-col-12 g-col-sm-2 g-col-2', '6 Colunas'), ('g-col-12 g-col-sm-2 g-col-1', '12 Colunas')], default='', help_text="Escolha 'Auto' para um layout responsivo automático ou para selecionar o número de colunas manualmente.", max_length=80, verbose_name='Layout do Grid'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 3.2 on 2024-01-11 22:21 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('plugins', '0003_auto_20240111_2218'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='column', | ||
name='col', | ||
field=models.CharField(choices=[(' ', 'Auto'), ('g-col-1', 'Col 1'), ('g-col-2', 'Col 2'), ('g-col-3', 'Col 3'), ('g-col-4', 'Col 4'), ('g-col-5', 'Col 5'), ('g-col-6', 'Col 6'), ('g-col-7', 'Col 7'), ('g-col-8', 'Col 8'), ('g-col-9', 'Col 9'), ('g-col-10', 'Col 10'), ('g-col-11', 'Col 11'), ('g-col-12', 'Col 12')], default=' ', help_text='Defina manualmente o número de colunas que esta coluna ocupará.', max_length=15, verbose_name='Coluna'), | ||
), | ||
migrations.AlterField( | ||
model_name='column', | ||
name='col_start_at', | ||
field=models.CharField(choices=[(' ', 'Auto'), ('g-start-1', 'Start at Col 1'), ('g-start-2', 'Start at Col 2'), ('g-start-3', 'Start at Col 3'), ('g-start-4', 'Start at Col 4'), ('g-start-5', 'Start at Col 5'), ('g-start-6', 'Start at Col 6'), ('g-start-7', 'Start at Col 7'), ('g-start-8', 'Start at Col 8'), ('g-start-9', 'Start at Col 9'), ('g-start-10', 'Start at Col 10'), ('g-start-11', 'Start at Col 11'), ('g-start-12', 'Start at Col 12')], default=' ', help_text='Defina em qual coluna o elemento deve iniciar.', max_length=30, verbose_name='Alinhamento horizontal da coluna'), | ||
), | ||
migrations.AlterField( | ||
model_name='column', | ||
name='rows', | ||
field=models.CharField(choices=[(' ', 'Auto'), ('grid-row: 2', 'Linha 2'), ('grid-row: 3', 'Linha 3'), ('grid-row: 4', 'Linha 4')], default=' ', help_text='Escolha manualmente o número da linha que esta coluna ocupará.', max_length=15, verbose_name='Linhas'), | ||
), | ||
migrations.AlterField( | ||
model_name='grid', | ||
name='grid_layout', | ||
field=models.CharField(choices=[(' ', 'Auto'), ('g-col-12', '1 Coluna'), ('g-col-12 g-col-md-6', '2 Colunas'), ('g-col-12 g-col-md-4', '3 Colunas'), ('g-col-12 g-col-sm-2 g-col-4', '4 Colunas'), ('g-col-12 g-col-sm-2 g-col-2', '6 Colunas'), ('g-col-12 g-col-sm-2 g-col-1', '12 Colunas')], default=' ', help_text="Escolha 'Auto' para um layout responsivo automático ou para selecionar o número de colunas manualmente.", max_length=80, verbose_name='Layout do Grid'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
from django.db import models | ||
from nossas.design.models import UICMSPlugin, UIBackgroundMixin | ||
|
||
|
||
class GridLayoutChoices(models.TextChoices): | ||
grid_auto = " ", "Auto" | ||
grid_1 = "g-col-12", "1 Coluna" | ||
grid_2 = "g-col-12 g-col-md-6", "2 Colunas" | ||
grid_3 = "g-col-12 g-col-md-4", "3 Colunas" | ||
grid_4 = "g-col-12 g-col-sm-2 g-col-4", "4 Colunas" | ||
grid_6 = "g-col-12 g-col-sm-2 g-col-2", "6 Colunas" | ||
grid_12 = "g-col-12 g-col-sm-2 g-col-1", "12 Colunas" | ||
|
||
|
||
class GridSpacingChoices(models.TextChoices): | ||
gap_0 = "row-gap: 0;", "Sem espaçamento" | ||
gap_4 = "row-gap: 4;", "Pequeno" | ||
gap_8 = "row-gap: 8;", "Grande" | ||
|
||
|
||
class Grid(UIBackgroundMixin, UICMSPlugin): | ||
grid_layout = models.CharField( | ||
"Layout do Grid", | ||
max_length=80, | ||
default=GridLayoutChoices.grid_auto, | ||
choices=GridLayoutChoices.choices, | ||
help_text="Escolha 'Auto' para um layout responsivo automático ou para selecionar o número de colunas manualmente.", | ||
) | ||
grid_gap = models.CharField( | ||
"Espaçamento do Grid", | ||
default=GridSpacingChoices.gap_0, | ||
choices=GridSpacingChoices.choices, | ||
max_length=15, | ||
help_text="Selecione o espaço entre colunas do Grid.", | ||
) | ||
|
||
|
||
class ColumnChoices(models.TextChoices): | ||
auto = " ", "Auto" | ||
col_1 = "g-col-1", "Col 1" | ||
col_2 = "g-col-2", "Col 2" | ||
col_3 = "g-col-3", "Col 3" | ||
col_4 = "g-col-4", "Col 4" | ||
col_5 = "g-col-5", "Col 5" | ||
col_6 = "g-col-6", "Col 6" | ||
col_7 = "g-col-7", "Col 7" | ||
col_8 = "g-col-8", "Col 8" | ||
col_9 = "g-col-9", "Col 9" | ||
col_10 = "g-col-10", "Col 10" | ||
col_11 = "g-col-11", "Col 11" | ||
col_12 = "g-col-12", "Col 12" | ||
|
||
|
||
class RowChoices(models.TextChoices): | ||
auto = " ", "Auto" | ||
row_1 = "grid-row: 2", "Linha 2" | ||
row_2 = "grid-row: 3", "Linha 3" | ||
row_3 = "grid-row: 4", "Linha 4" | ||
|
||
|
||
class ColumnStartAtChoices(models.TextChoices): | ||
auto = " ", "Auto" | ||
g_start_1 = "g-start-1", "Start at Col 1" | ||
g_start_2 = "g-start-2", "Start at Col 2" | ||
g_start_3 = "g-start-3", "Start at Col 3" | ||
g_start_4 = "g-start-4", "Start at Col 4" | ||
g_start_5 = "g-start-5", "Start at Col 5" | ||
g_start_6 = "g-start-6", "Start at Col 6" | ||
g_start_7 = "g-start-7", "Start at Col 7" | ||
g_start_8 = "g-start-8", "Start at Col 8" | ||
g_start_9 = "g-start-9", "Start at Col 9" | ||
g_start_10 = "g-start-10", "Start at Col 10" | ||
g_start_11 = "g-start-11", "Start at Col 11" | ||
g_start_12 = "g-start-12", "Start at Col 12" | ||
|
||
|
||
class Column(UIBackgroundMixin, UICMSPlugin): | ||
col = models.CharField( | ||
"Coluna", | ||
choices=ColumnChoices.choices, | ||
default=ColumnChoices.auto, | ||
max_length=15, | ||
help_text="Defina manualmente o número de colunas que esta coluna ocupará.", | ||
) | ||
rows = models.CharField( | ||
"Linhas", | ||
choices=RowChoices.choices, | ||
default=RowChoices.auto, | ||
max_length=15, | ||
help_text="Escolha manualmente o número da linha que esta coluna ocupará.", | ||
) | ||
col_start_at = models.CharField( | ||
"Alinhamento horizontal da coluna", | ||
choices=ColumnStartAtChoices.choices, | ||
default=ColumnStartAtChoices.auto, | ||
max_length=30, | ||
help_text="Defina em qual coluna o elemento deve iniciar.", | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% load cms_tags %} | ||
|
||
<div class="{{ instance.col }} {{ parent_instance.grid_layout }} {{ instance.col_start_at }}" style="{{ instance.rows }}"> | ||
{% for plugin in instance.child_plugin_instances %} | ||
{% render_plugin plugin %} | ||
{% endfor %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<div class="grid"> | ||
<div class="g-col-4">.g-col-4</div> | ||
<div class="g-col-4">.g-col-4</div> | ||
<div class="g-col-4">.g-col-4</div> | ||
{% load cms_tags %} | ||
|
||
<div class="grid" style="{{ instance.grid_gap }}"> | ||
{% for plugin in instance.child_plugin_instances %} | ||
{% render_plugin plugin %} | ||
{% endfor %} | ||
</div> |