-
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
Showing
11 changed files
with
226 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from plone.dexterity.content import Container | ||
from plone.supermodel import model | ||
from zope.interface import implementer | ||
|
||
|
||
class IPessoa(model.Schema): | ||
"""Definição de uma Pessoa.""" | ||
|
||
|
||
@implementer(IPessoa) | ||
class Pessoa(Container): | ||
"""Uma Pessoa no TRE-PR.""" |
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
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 |
---|---|---|
|
@@ -7,4 +7,8 @@ | |
name="Area" | ||
/> | ||
|
||
<object meta_type="Dexterity FTI" | ||
name="Pessoa" | ||
/> | ||
|
||
</object> |
44 changes: 44 additions & 0 deletions
44
backend/src/trepr/intranet/profiles/default/types/Pessoa.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,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
meta_type="Dexterity FTI" | ||
name="Pessoa" | ||
i18n:domain="trepr.intranet" | ||
> | ||
|
||
<!-- Basic properties --> | ||
<property name="title" | ||
i18n:translate="" | ||
>Pessoa</property> | ||
<property name="description" | ||
i18n:translate="" | ||
>Uma Pessoa do TRE-PR</property> | ||
|
||
<property name="allow_discussion">False</property> | ||
<property name="factory">Pessoa</property> | ||
|
||
<!-- Hierarchy control --> | ||
<property name="filter_content_types">False</property> | ||
<property name="allowed_content_types" /> | ||
<property name="global_allow">True</property> | ||
|
||
<!-- Schema, class and security --> | ||
<property name="add_permission">trepr.intranet.pessoa.add</property> | ||
<property name="klass">trepr.intranet.content.pessoa.Pessoa</property> | ||
<property name="schema">trepr.intranet.content.pessoa.IPessoa</property> | ||
|
||
<!-- Enabled behaviors --> | ||
<property name="behaviors" | ||
purge="false" | ||
> | ||
<element value="plone.basic" /> | ||
<element value="plone.namefromtitle" /> | ||
<element value="plone.shortname" /> | ||
<element value="plone.excludefromnavigation" /> | ||
<element value="trepr.intranet.behavior.contato" /> | ||
<element value="trepr.intranet.behavior.endereco" /> | ||
<element value="plone.leadimage" /> | ||
<element value="plone.constraintypes" /> | ||
<element value="plone.versioning" /> | ||
</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
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,77 @@ | ||
from AccessControl import Unauthorized | ||
from plone import api | ||
from plone.dexterity.fti import DexterityFTI | ||
from trepr.intranet.content.pessoa import Pessoa | ||
from zope.component import createObject | ||
|
||
import pytest | ||
|
||
|
||
CONTENT_TYPE = "Pessoa" | ||
|
||
|
||
@pytest.fixture | ||
def area_payload() -> dict: | ||
"""Return a payload to create a new pessoa.""" | ||
return { | ||
"type": "Pessoa", | ||
"id": "jadir", | ||
"title": "Jadir Junior", | ||
"description": ("Trabalha no NWEB"), | ||
"email": "[email protected]", | ||
"telefone": "(41) 3330.8485", | ||
} | ||
|
||
|
||
class TestPessoa: | ||
@pytest.fixture(autouse=True) | ||
def _setup(self, get_fti, portal): | ||
self.fti = get_fti(CONTENT_TYPE) | ||
self.portal = portal | ||
|
||
def test_fti(self): | ||
assert isinstance(self.fti, DexterityFTI) | ||
|
||
def test_factory(self): | ||
factory = self.fti.factory | ||
obj = createObject(factory) | ||
assert obj is not None | ||
assert isinstance(obj, Pessoa) | ||
|
||
@pytest.mark.parametrize( | ||
"behavior", | ||
[ | ||
"plone.basic", | ||
"plone.namefromtitle", | ||
"plone.shortname", | ||
"plone.excludefromnavigation", | ||
"plone.versioning", | ||
"trepr.intranet.behavior.contato", | ||
"trepr.intranet.behavior.endereco", | ||
"plone.leadimage", | ||
"plone.constraintypes", | ||
], | ||
) | ||
def test_has_behavior(self, get_behaviors, behavior): | ||
assert behavior in get_behaviors(CONTENT_TYPE) | ||
|
||
@pytest.mark.parametrize( | ||
"role,allowed", | ||
[ | ||
["Manager", True], | ||
["Site Administrator", True], | ||
["Editor", True], | ||
["Reviewer", False], | ||
["Contributor", False], | ||
["Reader", False], | ||
], | ||
) | ||
def test_create(self, area_payload, role: str, allowed: bool): | ||
with api.env.adopt_roles([role]): | ||
if allowed: | ||
content = api.content.create(container=self.portal, **area_payload) | ||
assert content.portal_type == CONTENT_TYPE | ||
assert isinstance(content, Pessoa) | ||
else: | ||
with pytest.raises(Unauthorized): | ||
api.content.create(container=self.portal, **area_payload) |
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
58 changes: 58 additions & 0 deletions
58
frontend/packages/volto-trepr-intranet/src/components/Views/PessoaView.jsx
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,58 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Container } from '@plone/components'; | ||
import { Image } from '@plone/volto/components'; | ||
import ContactInfo from '../ContactInfo/ContactInfo'; | ||
import EnderecoInfo from '../EnderecoInfo/EnderecoInfo'; | ||
|
||
const PessoaView = (props) => { | ||
const { content } = props; | ||
return ( | ||
<Container narrow id="page-document" className="view-wrapper pessoa-view"> | ||
{content.image && ( | ||
<Container className={'image'}> | ||
<Image | ||
className="documentImage ui right floated image" | ||
alt={content.title} | ||
title={content.title} | ||
item={content} | ||
imageField="image" | ||
responsive={true} | ||
/> | ||
</Container> | ||
)} | ||
<h1 className="documentFirstHeading">{content.title}</h1> | ||
{content.description && ( | ||
<p className="documentDescription">{content.description}</p> | ||
)} | ||
<EnderecoInfo content={content} /> | ||
<ContactInfo content={content} /> | ||
</Container> | ||
); | ||
}; | ||
/** | ||
* Property types. | ||
* @property {Object} propTypes Property types. | ||
* @static | ||
*/ | ||
PessoaView.propTypes = { | ||
content: PropTypes.shape({ | ||
title: PropTypes.string, | ||
description: PropTypes.string, | ||
image: PropTypes.shape({ | ||
scales: PropTypes.shape({ | ||
preview: PropTypes.shape({ | ||
download: PropTypes.string, | ||
}), | ||
}), | ||
}), | ||
email: PropTypes.string, | ||
telefone: PropTypes.string, | ||
endereco: PropTypes.string, | ||
complemento: PropTypes.string, | ||
cidade: PropTypes.string, | ||
estado: PropTypes.string, | ||
cep: PropTypes.string, | ||
}).isRequired, | ||
}; | ||
export default PessoaView; |
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