def get_doclegis(self): results = [] catalog = self.portal_catalog path = '/'.join(self.context.getPhysicalPath()) brains = catalog.searchResults( { 'portal_type': 'DocLegis', 'review_state': 'published' }, path={ 'query': path, 'depth': 1 }, ) for brain in brains: doclegis = brain.getObject() date = doclegis.date formated_date = '' year = '' if date: formated_date = "{0}/{1}/{2}".format(date.day(), date.month(), date.year()) year = date.year() #publication_date = doclegis.getDatepublication() #if publication_date: # year = publication_date.year() msgid = _(doclegis.document_type) document_type = self.context.translate(msgid) trans_theme = [] trans_institution = [] trans_commune = [] for theme in doclegis.theme: msgid = _(theme) trans_theme.append(self.context.translate(msgid)) for institution in doclegis.institution: msgid = _(institution) trans_institution.append(self.context.translate(msgid)) for commune in doclegis.commune: msgid = _(commune) trans_commune.append(self.context.translate(msgid)) results.append({ 'title': doclegis.title, 'document_type': document_type, 'date': formated_date, 'annee': year, 'theme': ", ".join(trans_theme), 'institution': ", ".join(trans_institution), 'commune': ", ".join(trans_commune), 'absolute_url': doclegis.absolute_url, }) return results
def get_doclegis(self): results = [] catalog = self.portal_catalog path = '/'.join(self.context.getPhysicalPath()) brains = catalog.searchResults({'portal_type': 'DocLegis', 'review_state': 'published'}, path={'query': path, 'depth': 1}, ) for brain in brains: doclegis = brain.getObject() date = doclegis.date formated_date = '' year = '' if date: formated_date = "{0}/{1}/{2}".format(date.day(), date.month(), date.year()) year = date.year() #publication_date = doclegis.getDatepublication() #if publication_date: # year = publication_date.year() msgid = _(doclegis.document_type) document_type = self.context.translate(msgid) trans_theme = [] trans_institution = [] trans_commune = [] for theme in doclegis.theme: msgid = _(theme) trans_theme.append(self.context.translate(msgid)) for institution in doclegis.institution: msgid = _(institution) trans_institution.append(self.context.translate(msgid)) for commune in doclegis.commune: msgid = _(commune) trans_commune.append(self.context.translate(msgid)) results.append({ 'title': doclegis.title, 'document_type': document_type, 'date': formated_date, 'annee': year, 'theme': ", ".join(trans_theme), 'institution': ", ".join(trans_institution), 'commune': ", ".join(trans_commune), 'absolute_url': doclegis.absolute_url, }) return results
def get_communes(self): trans_commune = [] for commune in self.context.commune: msgid = _(commune) trans_commune.append(self.context.translate(msgid)) return ", ".join(trans_commune)
def get_inst(self): trans_institution = [] for institution in self.context.institution: msgid = _(institution) trans_institution.append(self.context.translate(msgid)) return ", ".join(trans_institution)
def get_themes(self): trans_theme = [] for theme in self.context.theme: msgid = _(theme) trans_theme.append(self.context.translate(msgid)) return ", ".join(trans_theme)
def get_documenttype(self): msgid = _(self.context.document_type) document_type = self.context.translate(msgid) return document_type
default='', accessor='Title', widget=atapi.StringWidget( label_msgid='label_title', maxlength='1000', visible={'view': 'invisible'}, i18n_domain='plone', ), ), # -*- Your Archetypes field definitions here ... -*- atapi.StringField( 'numero', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u"Numero ou ID"), description=_(u""), ), ), atapi.TextField( 'text', storage=atapi.AnnotationStorage(), allowable_content_types=('text/html', ), default_output_type='text/html', widget=atapi.RichWidget( label=_(u"Corps de texte"), description=_(u""), ), ), atapi.StringField( 'document_type',
class IDocLegis(Interface): """Un document legislatif""" # -*- schema definition goes here -*- numero = schema.TextLine( title=_(u"Numero ou ID"), required=False, description=_(u""), ) # date = schema.Date( title=_(u"Date"), required=False, description=_(u""), ) # text = schema.TextLine( title=_(u"Corps de texte"), required=False, description=_(u""), ) # document_type = schema.TextLine( title=_(u"Type de document"), required=True, description=_(u""), ) # institution = schema.TextLine( title=_(u"Institution(s)"), required=False, description=_(u""), ) # theme = schema.TextLine( title=_(u"Theme(s)"), required=False, description=_(u"Field description"), ) # commune = schema.TextLine( title=_(u"Commune (si applicable)"), required=False, description=_(u""), ) # url = schema.TextLine( title=_(u"Url ou se trouve le document"), required=False, description=_(u""), ) fichier = schema.TextLine( title=_(u"Fichier a attacher"), required=False, description=_(u"Field description"), )
accessor='Title', widget=atapi.StringWidget( label_msgid='label_title', maxlength='1000', visible={'view': 'invisible'}, i18n_domain='plone', ), ), # -*- Your Archetypes field definitions here ... -*- atapi.StringField( 'numero', storage=atapi.AnnotationStorage(), widget=atapi.StringWidget( label=_(u"Numero ou ID"), description=_(u""), ), ), atapi.TextField( 'text', storage=atapi.AnnotationStorage(), allowable_content_types=('text/html',), default_output_type='text/html', widget=atapi.RichWidget( label=_(u"Corps de texte"), description=_(u""), ), ),
# -*- coding: utf-8 -*- from apl.doclegis import doclegisMessageFactory as _ from Products.Archetypes.utils import DisplayList def create_dl(elems): dl = DisplayList() for elem in elems: dl.add(key=elem[0], value=elem[1], msgid=elem[1]) return dl TYPE = create_dl([ ('loi', _(u'loi')), ('ordonnance', _(u'ordonnance')), ('arreteroyal', _(u'arreteroyal')), ('arretegouvernement', _(u'arretegouvernement')), ('arreteministeriel', _(u'arreteministeriel')), ('circulaire', _(u'circulaire')), ('reglement', _(u'reglement')), ('arretecocom', _(u'arretecocom')), ('arretecocof', _(u'arretecocof')), ('arretevgc', _(u'arretevgc')), ]) INSTITUTIONS = create_dl([ ('communes', _(u'communes')), ('cpas', _(u'cpas')), ('cultesetlaicite', _(u'cultesetlaicite')), ('intercommunales', _(u'intercommunales')), ('regiescommunales', _(u'regiescommunales')),