-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68ce179
commit 8b01797
Showing
14 changed files
with
425 additions
and
5 deletions.
There are no files selected for viewing
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
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
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,102 @@ | ||
from plone.autoform import directives | ||
from plone.autoform.interfaces import IFormFieldProvider | ||
from plone.schema.email import Email | ||
from plone.supermodel import model | ||
from procergs.sitedemo import _ | ||
from procergs.sitedemo.utils import validadores | ||
from zope import schema | ||
from zope.interface import provider | ||
|
||
|
||
@provider(IFormFieldProvider) | ||
class IContato(model.Schema): | ||
"""Provê campos de contato.""" | ||
|
||
model.fieldset( | ||
"contato", | ||
_("Contato"), | ||
fields=[ | ||
"email", | ||
"fax", | ||
"telefone_fax", | ||
"tel_comercial", | ||
"tel_celular", | ||
"voip", | ||
"skype", | ||
"whatsapp", | ||
"url", | ||
"horarios", | ||
"link_whatsapp", | ||
"telefones", | ||
], | ||
) | ||
|
||
email = Email( | ||
title=_("Email"), | ||
required=False, | ||
constraint=validadores.is_valid_email, | ||
) | ||
fax = schema.TextLine( | ||
title="FAX", | ||
required=False, | ||
) | ||
telefone_fax = schema.TextLine( | ||
title="TEL/FAX", | ||
required=False, | ||
) | ||
tel_comercial = schema.TextLine( | ||
title="Telefone Comercial", | ||
required=False, | ||
) | ||
tel_celular = schema.TextLine( | ||
title="Telefone Celular", | ||
required=False, | ||
) | ||
voip = schema.TextLine( | ||
title="VOIP", | ||
required=False, | ||
) | ||
skype = schema.TextLine( | ||
title="Skype", | ||
required=False, | ||
) | ||
whatsapp = schema.TextLine( | ||
title="WhatsApp", | ||
required=False, | ||
) | ||
|
||
directives.widget( | ||
"url", | ||
frontendOptions={ | ||
"format": "url", | ||
}, | ||
) | ||
url = schema.TextLine( | ||
title="URL", | ||
required=False, | ||
) | ||
horarios = schema.TextLine( | ||
title="Horários de Atendimento", | ||
required=False, | ||
) | ||
link_whatsapp = schema.TextLine( | ||
title="Link WhatsApp", | ||
required=False, | ||
) | ||
|
||
directives.widget( | ||
"telefones", | ||
frontendOptions={ | ||
"widget": "lista_telefones", | ||
}, | ||
) | ||
telefones = schema.List( | ||
title="Telephone Numbers", | ||
value_type=schema.TextLine( | ||
title="Telefone", | ||
constraint=validadores.is_valid_telefone, | ||
), | ||
required=False, | ||
min_length=1, | ||
max_length=5, | ||
) |
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
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,78 @@ | ||
from plone.autoform.interfaces import IFormFieldProvider | ||
from plone.supermodel import model | ||
from procergs.sitedemo import _ | ||
from zope import schema | ||
from zope.interface import provider | ||
|
||
|
||
@provider(IFormFieldProvider) | ||
class ILocal(model.Schema): | ||
"""Provê campos de endereço.""" | ||
|
||
model.fieldset( | ||
"local", | ||
_("Local"), | ||
fields=[ | ||
"logradouro", | ||
"numero", | ||
"complemento", | ||
"bairro", | ||
"municipio", | ||
"municipio_id", | ||
"estado", | ||
"pais", | ||
"cep", | ||
"coordenadas", | ||
], | ||
) | ||
logradouro = schema.TextLine( | ||
title=_("Logradouro"), | ||
required=False, | ||
default="", | ||
) | ||
numero = schema.TextLine( | ||
title=_("Número"), | ||
required=False, | ||
default="", | ||
) | ||
complemento = schema.TextLine( | ||
title=_("Complemento"), | ||
description=_("Bloco, Apartamento, etc"), | ||
required=False, | ||
default="", | ||
) | ||
bairro = schema.TextLine( | ||
title=_("Bairro"), | ||
required=False, | ||
default="", | ||
) | ||
municipio = schema.TextLine( | ||
title=_("Municipio"), | ||
required=False, | ||
default="", | ||
) | ||
municipio_id = schema.TextLine( | ||
title=_("Municipio ID"), | ||
required=False, | ||
default="", | ||
) | ||
estado = schema.Choice( | ||
title=_("UF"), | ||
vocabulary="procergs.sitedemo.vocabulary.estados", | ||
required=False, | ||
) | ||
pais = schema.TextLine( | ||
title=_("Pais"), | ||
required=False, | ||
default="", | ||
) | ||
cep = schema.TextLine( | ||
title=_("CEP"), | ||
required=False, | ||
default="", | ||
) | ||
coordenadas = schema.TextLine( | ||
title=_("Coordenadas"), | ||
required=False, | ||
default="", | ||
) |
17 changes: 17 additions & 0 deletions
17
src/procergs/sitedemo/profiles/default/types/Plone_Site.xml
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
meta_type="Dexterity FTI" | ||
name="Plone Site" | ||
i18n:domain="plone" | ||
> | ||
<!-- Enabled behaviors --> | ||
<property name="behaviors" | ||
purge="false" | ||
> | ||
<element value="procergs.sitedemo.behavior.informacoes_secretaria" /> | ||
<element value="procergs.sitedemo.behavior.contato" /> | ||
<element value="procergs.sitedemo.behavior.local" /> | ||
</property> | ||
|
||
|
||
</object> |
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
Empty file.
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,13 @@ | ||
import re | ||
|
||
|
||
def is_valid_email(value: str) -> bool: | ||
"""Validar se o email é @rs.gov.br.""" | ||
valid = value.endswith("rs.gov.br") if value else True | ||
return valid | ||
|
||
|
||
def is_valid_telefone(value: str) -> bool: | ||
"""Validar se o telefone é válido.""" | ||
pattern = re.compile(r"^(?P<ddd>[1-9]{2})(?P<fone>([2-8]|9[0-9])[0-9]{3}[0-9]{4})$") | ||
return True if re.match(pattern, value) else False |
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,3 +1,6 @@ | ||
<configure xmlns="http://namespaces.zope.org/zope"> | ||
|
||
<utility | ||
name="procergs.sitedemo.vocabulary.estados" | ||
component=".estados.vocab_estados" | ||
/> | ||
</configure> |
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,44 @@ | ||
from zope.interface import provider | ||
from zope.schema.interfaces import IVocabularyFactory | ||
from zope.schema.vocabulary import SimpleTerm | ||
from zope.schema.vocabulary import SimpleVocabulary | ||
|
||
|
||
OPCOES = [ | ||
("AC", "Acre"), | ||
("AL", "Alagoas"), | ||
("AP", "Amapá"), | ||
("AM", "Amazonas"), | ||
("BA", "Bahia"), | ||
("CE", "Ceará"), | ||
("DF", "Distrito Federal"), | ||
("ES", "Espírito Santo"), | ||
("GO", "Goiás"), | ||
("MA", "Maranhão"), | ||
("MT", "Mato Grosso"), | ||
("MS", "Mato Grosso do Sul"), | ||
("MG", "Minas Gerais"), | ||
("PA", "Pará"), | ||
("PB", "Paraíba"), | ||
("PR", "Paraná"), | ||
("PE", "Pernambuco"), | ||
("PI", "Piauí"), | ||
("RJ", "Rio de Janeiro"), | ||
("RN", "Rio Grande do Norte"), | ||
("RS", "Rio Grande do Sul"), | ||
("RO", "Rondônia"), | ||
("RR", "Roraima"), | ||
("SC", "Santa Catarina"), | ||
("SP", "São Paulo"), | ||
("SE", "Sergipe"), | ||
("TO", "Tocantins"), | ||
] | ||
|
||
|
||
@provider(IVocabularyFactory) | ||
def vocab_estados(context) -> SimpleVocabulary: | ||
"""Estados do Brasil.""" | ||
terms = [] | ||
for token, title in OPCOES: | ||
terms.append(SimpleTerm(token, token, title)) | ||
return SimpleVocabulary(terms) |
Oops, something went wrong.