Skip to content

Commit

Permalink
Merge pull request #100 from plonegovbr/hvelarde-tags
Browse files Browse the repository at this point in the history
Remove needless "subjects" field from Compromisso content type
  • Loading branch information
idgserpro authored Feb 15, 2019
2 parents 1c86a31 + 197e6e4 commit b03551b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 52 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
2.0b2 (unreleased)
^^^^^^^^^^^^^^^^^^

- Nothing changed yet.
- Remove o campo ``subjects`` do tipos de conteúdo ``Compromisso`` por ser considerado `desnecessário <https://listas.interlegis.gov.br/pipermail/plonegov-br/2018-June/004767.html>`_.
[hvelarde]


2.0b1 (2018-11-23)
Expand Down
17 changes: 0 additions & 17 deletions src/brasil/gov/agenda/content/compromisso.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from brasil.gov.agenda.interfaces import ICompromisso
from DateTime import DateTime
from plone.dexterity.content import Container
from plone.dexterity.utils import safe_utf8
from plone.indexer.decorator import indexer
from Products.CMFPlone.utils import safe_hasattr
from zope.interface import implementer
Expand Down Expand Up @@ -39,14 +38,6 @@ def default_location(context):
return getattr(context, 'location', u'')


@provider(IContextAwareDefaultFactory)
def default_subjects(context):
# XXX: deal with testing issues https://stackoverflow.com/q/35799092/644075
if not safe_hasattr(context, 'aq_parent'):
return ()
return getattr(context, 'subjects', ())


@provider(IContextAwareDefaultFactory)
def default_start_date(context):
if IAgendaDiaria.providedBy(context):
Expand Down Expand Up @@ -85,14 +76,6 @@ def end_date(obj):
return DateTime(ICompromisso(obj).end_date)


@indexer(ICompromisso)
def tags(obj):
"""Indexa tags de Compromisso."""
if obj.subjects is None:
return ()
return tuple(safe_utf8(s) for s in obj.subjects)


@indexer(ICompromisso)
def exclude_from_nav(obj):
# Compromissos sempre serao ocultos da navegacao
Expand Down
6 changes: 1 addition & 5 deletions src/brasil/gov/agenda/content/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<configure
xmlns="http://namespaces.zope.org/zope"
i18n_domain="brasil.gov.agenda">
<configure xmlns="http://namespaces.zope.org/zope">

<adapter name="Subject" factory=".agenda.tags" />

<adapter name="start" factory=".compromisso.start_date" />
<adapter name="end" factory=".compromisso.end_date" />
<adapter name="exclude_from_nav" factory=".compromisso.exclude_from_nav" />
<adapter name="Subject" factory=".compromisso.tags" />


<adapter name="start" factory=".agendadiaria.start_date" />
<adapter name="end" factory=".agendadiaria.end_date" />
Expand Down
11 changes: 0 additions & 11 deletions src/brasil/gov/agenda/content/schema/Compromisso.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,5 @@
<defaultFactory>brasil.gov.agenda.content.compromisso.default_location</defaultFactory>
<title i18n:translate="label_event_location">Event Location</title>
</field>
<field name="subjects" type="zope.schema.Tuple" indexer:searchable="true">
<description i18n:translate="">Tags são utilizadas para organização de conteúdo</description>
<default_value>()</default_value>
<missing_value>()</missing_value>
<required>False</required>
<defaultFactory>brasil.gov.agenda.content.compromisso.default_subjects</defaultFactory>
<title>Tags</title>
<value_type type="zope.schema.TextLine">
<title>Tag</title>
</value_type>
</field>
</schema>
</model>
18 changes: 0 additions & 18 deletions src/brasil/gov/agenda/tests/test_compromisso.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,6 @@ def test_exclude_from_nav(self):
def test_exclude_from_nav_behavior(self):
self.assertFalse(IExcludeFromNavigation.providedBy(self.compromisso))

def test_subjects_catalog(self):
compromisso = self.compromisso
compromisso.subjects = (u'Brasil', u'México')
compromisso.reindexObject(idxs=['Subject'])
ct = self.portal.portal_catalog
results = ct.searchResults(portal_type='Compromisso')
b = results[0]
self.assertIn('Brasil', b.Subject)
self.assertIn('México', b.Subject)

def test_default_subjects(self):
from brasil.gov.agenda.content.compromisso import default_subjects
agendadiaria = self.agendadiaria
agendadiaria.subjects = (u'Brasil', u'México')
# default_factory é executado no container
self.assertIn(u'Brasil', default_subjects(agendadiaria))
self.assertIn(u'México', default_subjects(agendadiaria))

def test_default_start_date(self):
from brasil.gov.agenda.content.compromisso import default_start_date
date_fmt = '%Y-%m-%d %H:%M'
Expand Down

0 comments on commit b03551b

Please sign in to comment.