Skip to content

Commit

Permalink
Adiciona configuração do site
Browse files Browse the repository at this point in the history
  • Loading branch information
robertatakenaka committed Sep 1, 2022
1 parent be1bb96 commit 711d884
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
13 changes: 10 additions & 3 deletions core_settings/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
# Generated by Django 3.2.12 on 2022-07-18 11:12
# Generated by Django 3.2.12 on 2022-08-29 09:10

from django.db import migrations, models
import django.db.models.deletion
import wagtail.core.fields


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0066_collection_management_permissions'),
('wagtailimages', '0023_add_choose_permissions'),
('wagtailcore', '0066_collection_management_permissions'),
]

operations = [
migrations.CreateModel(
name='CustomSettings',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(blank=True, max_length=100, null=True)),
('email', models.EmailField(blank=True, max_length=100, null=True)),
('phone', models.CharField(blank=True, max_length=100, null=True)),
('footer_text', wagtail.core.fields.RichTextField(blank=True, null=True)),
('admin_logo', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
('favicon', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
('site', models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='wagtailcore.site')),
('site_logo', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
],
options={
'abstract': False,
'verbose_name': 'Configuração do site',
'verbose_name_plural': 'Configuração do site',
},
),
]
38 changes: 36 additions & 2 deletions core_settings/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.db import models
from django.utils.translation import gettext as _

from wagtail.core.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel, TabbedInterface, ObjectList
from wagtail.images.edit_handlers import ImageChooserPanel

from wagtail.contrib.settings.models import BaseSetting, register_setting


Expand All @@ -13,6 +15,16 @@ class CustomSettings(BaseSetting):
More about look:
https://docs.wagtail.org/en/stable/reference/contrib/settings.html
"""
class Meta:
verbose_name = _('Configuração do site')
verbose_name_plural = _('Configuração do site')

name = models.CharField(max_length=100, null=True, blank=True)
email = models.EmailField(max_length=100, null=True, blank=True)
phone = models.CharField(max_length=100, null=True, blank=True)

footer_text = RichTextField(null=True, blank=True)

favicon = models.ForeignKey(
'wagtailimages.Image',
null=True,
Expand All @@ -29,7 +41,29 @@ class CustomSettings(BaseSetting):
related_name='+'
)

panels = [
site_logo = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)

site_panels = [
FieldPanel('name'),
FieldPanel('email'),
FieldPanel('phone'),
FieldPanel('footer_text', classname="full"),
ImageChooserPanel('favicon'),
ImageChooserPanel('site_logo'),
]

admin_panels = [
ImageChooserPanel('admin_logo'),
]

edit_handler = TabbedInterface([
ObjectList(site_panels, heading=_('Site settings')),
ObjectList(admin_panels, heading=_('Admin settings')),
])

0 comments on commit 711d884

Please sign in to comment.