-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Code cleanup * Use a macro to remove template duplications * Fix behavior to don't update page URL when there is no appointments in the current day * Review Edit / Remove Appointments test * Code review * Move AgendaMixin to browser module * Code review
- Loading branch information
Showing
14 changed files
with
261 additions
and
403 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
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,66 @@ | ||
# -*- coding: utf-8 -*- | ||
from six.moves import range # noqa: I001 | ||
from datetime import datetime | ||
from datetime import timedelta | ||
from Products.CMFCore.utils import getToolByName | ||
from zope.component import getMultiAdapter | ||
|
||
|
||
class AgendaMixin: | ||
"""Common methods and functions used by views and and tiles.""" | ||
|
||
def _translate(self, msgid, locale='plonelocales', mapping=None): | ||
tool = getToolByName(self.context, 'translation_service') | ||
portal_state = getMultiAdapter((self.context, self.request), | ||
name=u'plone_portal_state') | ||
current_language = portal_state.language() | ||
# XXX: Por que é retornado 'pt-br' do portal_state ao invés de 'pt_BR'? | ||
# Quando uso 'pt-br' ao invés de 'pt_BR', não pega a tradução quando | ||
# feita de forma manual. | ||
target_language = ('pt_BR' if current_language == 'pt-br' | ||
else self.current_language) | ||
return tool.translate(msgid, | ||
locale, | ||
mapping=mapping, | ||
context=self.context, | ||
target_language=target_language) | ||
|
||
def month(self): | ||
tool = getToolByName(self.context, 'translation_service') | ||
today = datetime.now() | ||
strmonth = self._translate(tool.month_msgid(today.strftime('%m'))) | ||
return { | ||
'strmonth': strmonth[:3].upper(), | ||
'strmonthcomplete': strmonth.upper(), | ||
'month': today.month, | ||
'year': today.year, | ||
} | ||
|
||
def days(self): | ||
tool = getToolByName(self.context, 'translation_service') | ||
today = datetime.now() | ||
# get a list with 3 days before and 3 days after today | ||
days = [(today + timedelta(i)) for i in range(-3, 4)] | ||
weekdays = [] | ||
for day in days: | ||
cssclass = ['day'] | ||
if day == today: | ||
cssclass.append('is-selected') | ||
if self.agenda.get(day.strftime('%Y-%m-%d'), False): | ||
cssclass.append('has-appointment') | ||
strweek = self._translate(tool.day_msgid(day.weekday())) | ||
weekdays.append({ | ||
'day': day.day, | ||
'weekday': strweek[:3], | ||
'iso': day.isoformat(), | ||
'cssclass': ' '.join(cssclass), | ||
}) | ||
return weekdays | ||
|
||
@staticmethod | ||
def compromissos(): | ||
return [] | ||
|
||
@staticmethod | ||
def exibe_sem_compromissos(): | ||
return True |
125 changes: 125 additions & 0 deletions
125
src/brasil/gov/agenda/browser/templates/agenda_macros.pt
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,125 @@ | ||
<metal:form define-macro="search" | ||
i18n:domain="brasil.gov.agenda"> | ||
<div class="search-compromisso"> | ||
<form class="search-form" | ||
tal:attributes="action string:${view/agenda/absolute_url}/@@search"> | ||
<div class="LSBox"> | ||
<input class="searchField" | ||
name="SearchableText" | ||
type="text" | ||
size="15" | ||
title="Busca em agenda" | ||
placeholder="Buscar em agenda" | ||
autocomplete="off" /> | ||
<input class="searchButton" type="submit" value="Buscar" /> | ||
<input type="hidden" | ||
name="portal_type:list" | ||
value="AgendaDiaria" | ||
checked="checked" | ||
/> | ||
</div> | ||
</form> | ||
</div> | ||
</metal:form> | ||
|
||
<metal:form define-macro="calendar" | ||
i18n:domain="brasil.gov.agenda"> | ||
<div class="calendar-wrapper"> | ||
<div class="calendar-title" | ||
tal:define="month view/month"> | ||
<span class="strmonth" tal:content="month/strmonthcomplete" /> | ||
<span class="from" i18n:translate="">de</span> | ||
<span class="year" tal:content="month/year" /> | ||
</div> | ||
<div class="calendar"></div> | ||
</div> | ||
</metal:form> | ||
|
||
<metal:form define-macro="daypicker" | ||
i18n:domain="brasil.gov.agenda"> | ||
<div class="daypicker-wrapper"> | ||
<ul class="daypicker" | ||
tal:condition="view/days"> | ||
<tal:event repeat="day view/days"> | ||
<li tal:attributes="data-day day/iso; | ||
class day/cssclass;"> | ||
<div class="daypicker-day" | ||
tal:content="day/day" /> | ||
<div class="daypicker-weekday" | ||
tal:content="day/weekday" /> | ||
</li> | ||
</tal:event> | ||
</ul> | ||
</div> | ||
</metal:form> | ||
|
||
<metal:form define-macro="appointments" | ||
i18n:domain="brasil.gov.agenda"> | ||
<div class="collectionevents-title-wrapper"> | ||
<div class="collectionevents-stroke"></div> | ||
<div class="collectionevents-title" | ||
i18n:translate=""> | ||
Compromissos do dia | ||
</div> | ||
<div class="collectionevents-stroke"></div> | ||
</div> | ||
<ul class="list-compromissos"> | ||
<li class="item-compromisso-wrapper" | ||
tal:repeat="comp view/compromissos"> | ||
<div class="item-compromisso"> | ||
<div class="compromisso-horarios"> | ||
<time class="horario compromisso-inicio" | ||
tal:attributes="datetime comp/start_date" | ||
tal:content="comp/start_time">16h20</time> | ||
<div class="now" | ||
tal:condition="comp/is_now" | ||
i18n:translate="">Agora</div> | ||
</div> | ||
<div class="compromisso-dados"> | ||
<h4 class="compromisso-titulo" | ||
tal:content="comp/title"> | ||
Reunião com Dorneles Treméa | ||
</h4> | ||
<p class="compromisso-participantes" | ||
tal:condition="comp/attendees" | ||
tal:content="structure comp/attendees_formatted"> | ||
Dorneles Treméa | ||
</p> | ||
<p class="compromisso-pauta" | ||
tal:condition="comp/description"> | ||
<label i18n:translate="">Pauta:</label> | ||
<span tal:replace="comp/description">Assunto a ser tratado</span> | ||
</p> | ||
<p class="compromisso-local" | ||
tal:condition="comp/location" | ||
tal:content="comp/location"> | ||
Palácio do Planalto | ||
</p> | ||
<span class="download-compromisso"> | ||
<a class="add-agenda vcal" | ||
tal:attributes="href string:${comp/url}/vcal_view" | ||
i18n:translate="">VCAL</a> | ||
<span i18n:translate="">Adicionar ao meu calendario</span> | ||
</span> | ||
</div> | ||
<ul class="compromisso-acoes" | ||
tal:condition="view/editable"> | ||
<li class="compromisso-acao"> | ||
<a class="compromisso editar_compromisso acao" | ||
tal:attributes="href string:${comp/url}/edit" | ||
i18n:translate="">Editar</a> | ||
</li> | ||
<li class="compromisso-acao"> | ||
<a class="compromisso remover_compromisso acao" | ||
tal:attributes="href string:${comp/url}/delete_confirmation" | ||
i18n:translate="">Remover</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</li> | ||
<li class="sem-compromisso item-compromisso" | ||
tal:condition="view/exibe_sem_compromissos"> | ||
<span i18n:translate="label_agendadiaria_sem_compromissos">Sem compromissos oficiais.</span> | ||
</li> | ||
</ul> | ||
</metal:form> |
Oops, something went wrong.