From 197e6e4f6bfa76f6ae7b10ee4c3c0888d8622474 Mon Sep 17 00:00:00 2001 From: hvelarde Date: Tue, 12 Jun 2018 22:54:02 -0300 Subject: [PATCH] Remove needless "subjects" field from Compromisso --- CHANGES.rst | 3 ++- src/brasil/gov/agenda/content/compromisso.py | 17 ----------------- src/brasil/gov/agenda/content/configure.zcml | 6 +----- .../gov/agenda/content/schema/Compromisso.xml | 11 ----------- .../gov/agenda/tests/test_compromisso.py | 18 ------------------ 5 files changed, 3 insertions(+), 52 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index c91e2c9..c933614 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 `_. + [hvelarde] 2.0b1 (2018-11-23) diff --git a/src/brasil/gov/agenda/content/compromisso.py b/src/brasil/gov/agenda/content/compromisso.py index faf5645..461c610 100644 --- a/src/brasil/gov/agenda/content/compromisso.py +++ b/src/brasil/gov/agenda/content/compromisso.py @@ -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 @@ -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): @@ -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 diff --git a/src/brasil/gov/agenda/content/configure.zcml b/src/brasil/gov/agenda/content/configure.zcml index 10dada0..d1e583a 100644 --- a/src/brasil/gov/agenda/content/configure.zcml +++ b/src/brasil/gov/agenda/content/configure.zcml @@ -1,14 +1,10 @@ - + - - diff --git a/src/brasil/gov/agenda/content/schema/Compromisso.xml b/src/brasil/gov/agenda/content/schema/Compromisso.xml index d88ed24..9a1b24f 100644 --- a/src/brasil/gov/agenda/content/schema/Compromisso.xml +++ b/src/brasil/gov/agenda/content/schema/Compromisso.xml @@ -40,16 +40,5 @@ brasil.gov.agenda.content.compromisso.default_location Event Location - - Tags são utilizadas para organização de conteúdo - () - () - False - brasil.gov.agenda.content.compromisso.default_subjects - Tags - - Tag - - diff --git a/src/brasil/gov/agenda/tests/test_compromisso.py b/src/brasil/gov/agenda/tests/test_compromisso.py index c2b004c..55ce6f7 100644 --- a/src/brasil/gov/agenda/tests/test_compromisso.py +++ b/src/brasil/gov/agenda/tests/test_compromisso.py @@ -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'