class ITimelineSettings(Schema): """Form schema for timeline settings""" start_at_end = schema.Bool(title=_(u'Start at End of Timeline')) fonts = schema.Choice(title=_(u'Timeline Fonts'), required=True, default=u'Georgia-Helvetica', vocabulary=FONT_VOCAB) map_style = schema.Choice(title=_(u'Map Style'), required=True, default=u'ROADMAP', vocabulary=MAP_VOCAB)
class TimelineConfigurationForm(form.SchemaEditForm): grok.name('timeline-configuration') grok.require('cmf.ModifyPortalContent') grok.context(interface.Interface) schema = ITimelineSettings label = _(u"Timeline Settings") description = _(u"Settings for timeline view") @property def has_maps_key(self): # Check for Products.Maps google map key properties = getToolByName(self.context, 'portal_properties') maps = getattr(properties, 'maps_properties', None) return bool(maps and getattr(maps, 'map_google_api_keys', None)) def updateWidgets(self): super(TimelineConfigurationForm, self).updateWidgets() if not self.has_maps_key: self.widgets['map_style'].mode = HIDDEN_MODE
class ITimelineBehavior(form.Schema): """Add timeline configuration to content""" form.fieldset( 'timeline', label=_(u'Timeline Config'), fields=timeline_fields, ) use_pub_date = Bool(title=_(u"Use Publication Date(s)")) timeline_date = Datetime(title=_(u"Custom Timeline Date"), required=False) timeline_end = Datetime(title=_(u"Timeline End Date"), required=False) bce_year = Bool(title=_(u'Year is BCE'), default=False) year_only = Bool(title=_(u'Show Year Only'), default=False) show_tag = Bool(title=_(u'Show first tag in timeline'), default=False) form.omitted(*timeline_fields) form.no_omit(IEditForm, *timeline_fields) form.no_omit(IAddForm, *timeline_fields)
class TimelineExtender(object): adapts(IBaseContent) implements(ISchemaExtender) fields = [ ExtensionBooleanField( 'use_pub_date', schemata='Timeline Config', widget=BooleanWidget( label=_(u'Use Publication Date(s)'), visible={'view': 'invisible'}, ), ), ExtensionDateTimeField( 'timeline_date', schemata='Timeline Config', widget=StringWidget( label=_(u'Custom Timeline Date'), description= _(u'Must be entered as "YYYY-MM-DD" or a standalone year (e.g. "0525-02-23" or "25" for year 25)' ), visible={'view': 'invisible'}, )), ExtensionDateTimeField( 'timeline_end', schemata='Timeline Config', widget=StringWidget( label=_(u'Timeline End Date'), description= _(u'Must be entered as "YYYY-MM-DD" or a standalone year (e.g. "0525-02-23" or "25" for year 25)' ), visible={'view': 'invisible'}, )), ExtensionBooleanField( 'bce_year', schemata='Timeline Config', widget=BooleanWidget( label=_(u'Year is BCE'), visible={'view': 'invisible'}, ), ), ExtensionBooleanField( 'year_only', schemata='Timeline Config', widget=BooleanWidget( label=_(u'Display year only on timeline'), visible={'view': 'invisible'}, ), ), ExtensionBooleanField( 'show_tag', schemata='Timeline Config', default=False, widget=BooleanWidget( label=_(u'Show first tag in timeline'), visible={'view': 'invisible'}, ), ), ] def __init__(self, context): self.context = context def getFields(self): # Don't add fields for events if IATEvent.providedBy(self.context): return [] return self.fields
from zope.schema.vocabulary import SimpleVocabulary from collective.timelines import timelinesMessageFactory as _ ANNOTATION_KEY = 'collective.timelines.annotation' MAP_STYLES = ( (u'ROADMAP', _(u'Google Maps: Roadmap')), (u'SATELLITE', _(u'Google Maps: Satellite')), (u'HYBRID', _(u'Google Maps: Hybrid')), (u'TERRAIN', _(u'Google Maps: Terrain')), (u'watercolor', _(u'Stamen Maps: Watercolor')), (u'toner', _(u'Stamen Maps: Toner')), (u'toner-lines', _(u'Stamen Maps: Toner Lines')), (u'toner-labels', _(u'Stamen Maps: Toner Labels')), (u'sterrain', _(u'Stamen Maps: Terrain')), ) FONT_CHOICES = ( (u'Georgia-Helvetica', _(u'Georgia & Helvetica Neue')), (u'Bevan-PotanoSans', _(u'Bevan & Potano Sans')), (u'Merriweather-NewsCycle', _(u'Merriweather & News Cycle')), (u'NewsCycle-Merriweather', _(u'News Cycle & Merriweather')), (u'PoiretOne-Molengo', _(u'Poiret One & Molengo')), (u'Arvo-PTSans', _(u'Arvo & PT Sans')), (u'PTSerif-PTSans', _(u'PT Serif & PT Sans')), (u'DroidSerif-DroidSans', _(u'Droid Serif & Droid Sans')), (u'Lekton-Molengo', _(u'Lekton & Molengo')), (u'NixieOne-Ledger', _(u'Nixie One & Ledger')), (u'AbrilFatface-Average', _(u'Abril Fatface & Average')), (u'PlayfairDisplay-Muli', _(u'Playfair Display & Muli')), (u'Rancho-Gudea', _(u'Rancho & Gudea')),
from zope.schema.vocabulary import SimpleVocabulary from collective.timelines import timelinesMessageFactory as _ ANNOTATION_KEY = "collective.timelines.annotation" MAP_STYLES = ( (u"ROADMAP", _(u"Google Maps: Roadmap")), (u"SATELLITE", _(u"Google Maps: Satellite")), (u"HYBRID", _(u"Google Maps: Hybrid")), (u"TERRAIN", _(u"Google Maps: Terrain")), (u"watercolor", _(u"Stamen Maps: Watercolor")), (u"toner", _(u"Stamen Maps: Toner")), (u"toner-lines", _(u"Stamen Maps: Toner Lines")), (u"toner-labels", _(u"Stamen Maps: Toner Labels")), (u"sterrain", _(u"Stamen Maps: Terrain")), ) FONT_CHOICES = ( (u"Georgia-Helvetica", _(u"Georgia & Helvetica Neue")), (u"Bevan-PotanoSans", _(u"Bevan & Potano Sans")), (u"Merriweather-NewsCycle", _(u"Merriweather & News Cycle")), (u"NewsCycle-Merriweather", _(u"News Cycle & Merriweather")), (u"PoiretOne-Molengo", _(u"Poiret One & Molengo")), (u"Arvo-PTSans", _(u"Arvo & PT Sans")), (u"PTSerif-PTSans", _(u"PT Serif & PT Sans")), (u"DroidSerif-DroidSans", _(u"Droid Serif & Droid Sans")), (u"Lekton-Molengo", _(u"Lekton & Molengo")), (u"NixieOne-Ledger", _(u"Nixie One & Ledger")), (u"AbrilFatface-Average", _(u"Abril Fatface & Average")), (u"PlayfairDisplay-Muli", _(u"Playfair Display & Muli")),