Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jun 18, 2018
1 parent 9cdfd43 commit 7cab498
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 55 deletions.
6 changes: 3 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Changelog
Esta versão também remove a dependência no collective.portlet.calendar.
Remova manualmente todos os portlets de calendario estendido e desinstale o pacote antes de atualizar.

- Corrige funcionamento da view padrão do tipo de conteúdo ``AgendaDiaria`` para evitar `problemas com proxies intermediárias <https://community.plone.org/t/6658>`_.
[rodfersou]

- Remove dependência no collective.portlet.calendar;
o layout do IDG 2.x não faz uso de portlets.
[hvelarde]

- Remove restapi para evitar problemas com `proxies intermediárias <https://community.plone.org/t/6658>`_.
[rodfersou]

- Remove upgrade steps do branch 1.x.
[hvelarde]

Expand Down
1 change: 1 addition & 0 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extends =
package-name = brasil.gov.agenda
package-extras = [test]
eggs +=
cssselect # XXX: needed by plone.protect
z3c.unconfigure

parts +=
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
install_requires=[
'Acquisition',
'collective.cover',
'cssselect',
'plone.api',
'plone.app.content',
'plone.app.contenttypes',
Expand Down
21 changes: 11 additions & 10 deletions src/brasil/gov/agenda/browser/agenda.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from six.moves import range # noqa: I001
from brasil.gov.agenda import _
from brasil.gov.agenda.config import AGENDADIARIAFMT
from brasil.gov.agenda.interfaces import ICompromisso
Expand All @@ -9,7 +10,7 @@
from dateutil.tz import tzlocal
from plone import api
from Products.Five.browser import BrowserView
from six.moves import range # noqa: I001
from zExceptions import NotFound
from zope.component import getMultiAdapter
from zope.i18nmessageid import Message
from zope.interface import implementer
Expand Down Expand Up @@ -104,20 +105,21 @@ def imagem(self):

@implementer(IPublishTraverse)
class AgendaJSONView(BrowserView, AgendaMixin):
"""Visao padrao da agenda."""

def setup(self):
self._ts = api.portal.get_tool('translation_service')
"""JSON view."""

def publishTraverse(self, request, date):
"""Pega a data da agenda diaria."""
# this raises ValueError if date is invalid date
datetime.strptime(date, AGENDADIARIAFMT)
"""Get the selected date."""
try:
datetime.strptime(date, AGENDADIARIAFMT)
except ValueError: # invalid date format
raise NotFound

self.date = date
return self

def weekday(self, date):
return self._translate(self._ts.day_msgid(date.strftime('%w')))
ts = api.portal.get_tool('translation_service')
return self._translate(ts.day_msgid(date.strftime('%w')))

def extract_data(self):
data = []
Expand Down Expand Up @@ -160,7 +162,6 @@ def extract_data(self):
return data

def __call__(self):
self.setup()
response = self.request.response
response.setHeader('content-type', 'application/json')
return response.setBody(json.dumps(self.extract_data()))
2 changes: 1 addition & 1 deletion src/brasil/gov/agenda/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<metadata>
<version>4101</version>
<version>4100</version>
<dependencies>
<dependency>profile-collective.cover:default</dependency>
<dependency>profile-plone.app.dexterity:default</dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/brasil/gov/agenda/tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_installed(self):

def test_version(self):
self.assertEqual(
self.st.getLastVersionForProfile(self.profile), (u'4101',))
self.st.getLastVersionForProfile(self.profile), (u'4100',))

def test_css_registered(self):
cssreg = getattr(self.portal, 'portal_css')
Expand Down
11 changes: 0 additions & 11 deletions src/brasil/gov/agenda/tests/test_upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,3 @@ def test_fix_resources_references(self):
ids = js_tool.getResourceIds()
self.assertEqual(SWIPER_JS, ids[0])
self.assertIn(NEW_JS, ids)


class to4101TestCase(UpgradeTestCaseBase):

def setUp(self):
UpgradeTestCaseBase.setUp(self, u'*', u'4101')

def test_registrations(self):
version = self.setup.getLastVersionForProfile(self.profile_id)[0]
self.assertGreaterEqual(int(version), int(self.to_version))
self.assertEqual(self.total_steps, 2)
1 change: 0 additions & 1 deletion src/brasil/gov/agenda/upgrades/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<configure xmlns="http://namespaces.zope.org/zope">
<include package=".v4100" />
<include package=".v4101" />
</configure>
1 change: 0 additions & 1 deletion src/brasil/gov/agenda/upgrades/v4101/__init__.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/brasil/gov/agenda/upgrades/v4101/configure.zcml

This file was deleted.

0 comments on commit 7cab498

Please sign in to comment.