Created
July 3, 2014 15:42
-
-
Save zopyx/134ad81cfbbed4db0d5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def context_property(name): | |
def getter(self): | |
return getattr(self.context, name) | |
def setter(self, value): | |
setattr(self.context, name, value) | |
def deleter(self): | |
delattr(self.context, name) | |
return property(getter, setter, deleter) | |
certificate_vocabulary = SimpleVocabulary([ | |
SimpleTerm(value=True, title=_(u'yes')), | |
SimpleTerm(value=False, title=_(u'no')) | |
]) | |
class ILocationReference(model.Schema): | |
""" | |
Behavior providing a location reference field | |
""" | |
form.widget('location_reference', SelectWidget, multiple='multiple', size=10) | |
location_reference = RelationList( | |
title=_(u"label_behavior_location_reference"), | |
description=_(u"help__behavior_location_reference"), | |
required=False, | |
relationship='location_reference', | |
value_type=schema.Choice( | |
source=CatalogInterfaceBinder( | |
object_provides=ILocation.__identifier__),) | |
) | |
class ILocalization(ILocationReference): | |
""" | |
Behavior providing ILocationReference in a separate fieldset | |
""" | |
model.fieldset( | |
'fieldset_location_reference', | |
label=_(u'label_fieldset_location_reference'), | |
fields=['location_reference'] | |
) | |
class IEventClassification(ILocationReference): | |
""" | |
Behavior providing a fields to make closer description | |
""" | |
model.fieldset( | |
'fieldset_event_classification', | |
label=_(u'label_fieldset_event_classification'), | |
fields=[ | |
'type_of_event', | |
'form_of_event', | |
'topic', | |
'targetgroup', | |
'deadline', | |
'certificate', | |
'certificate_description', | |
'cost', | |
'cost_description', | |
'location_reference'] | |
) | |
form.widget('type_of_event', SelectWidget) | |
type_of_event = schema.Choice( | |
title=_(u'label_behavior_type_of_event'), | |
description=_(u'help_behavior_type_of_event'), | |
required=False, | |
source=VocabularyBinder('behavior_type_of_event_tags') | |
) | |
form.widget('form_of_event', SelectWidget) | |
form_of_event = schema.Choice( | |
title=_(u'label_behavior_form_of_event'), | |
description=_(u'help_behavior_form_of_event'), | |
required=False, | |
source=VocabularyBinder('behavior_form_of_event_tags') | |
) | |
form.widget('topic', SelectWidget) | |
topic = schema.Choice( | |
title=_(u'label_behavior_topic'), | |
description=_(u'help_behavior_topic'), | |
required=False, | |
source=VocabularyBinder('behavior_topic_tags') | |
) | |
targetgroup = schema.TextLine( | |
title=_(u'label_behavior_targetgroup') , | |
description=_(u'help_behavior_targetgroup'), | |
required=False | |
) | |
deadline = schema.Datetime( | |
title=_(u'label_behavior_deadline'), | |
description=_(u'help_behavior_deadline'), | |
required=False, | |
) | |
certificate = schema.Choice( | |
title=_(u'label_behavior_certificate'), | |
description=_(u'help_behavior_certificate'), | |
required=False, | |
vocabulary=certificate_vocabulary | |
) | |
certificate_description = schema.TextLine( | |
title=_(u'label_behavior_certificate_description') , | |
description=_(u'help_behavior_certificate_description'), | |
required=False | |
) | |
cost = schema.Choice( | |
title=_(u'label_behavior_cost'), | |
description=_(u'help_behavior_cost'), | |
required=False, | |
vocabulary=certificate_vocabulary | |
) | |
cost_description = schema.TextLine( | |
title=_(u'label_behavior_cost_description') , | |
description=_(u'help_behavior_cost_description'), | |
required=False | |
) | |
alsoProvides(ILocationReference, IFormFieldProvider) | |
alsoProvides(ILocalization, IFormFieldProvider) | |
alsoProvides(IEventClassification, IFormFieldProvider) | |
class LocationReference(object): | |
""" | |
Adapter for ILocationReference | |
""" | |
implements(ILocationReference) | |
adapts(IDexterityContent) | |
def __init__(self,context): | |
self.context = context | |
location_reference = context_property('location_reference') | |
class Localization(object): | |
""" | |
Adapter for ILocalization | |
""" | |
implements(ILocalization) | |
adapts(IDexterityContent) | |
def __init__(self,context): | |
self.context = context | |
class EventClassification(object): | |
""" | |
Adapter for IEventClassification | |
""" | |
implements(IEventClassification) | |
adapts(IDexterityContent) | |
def __init__(self,context): | |
self.context = context | |
type_of_event = context_property('type_of_event') | |
form_of_event = context_property('form_of_event') | |
topic = context_property('topic') | |
targetgroup = context_property('targetgroup') | |
deadline = context_property('deadline') | |
certificate = context_property('certificate') | |
certificate_description = context_property('certificate_description') | |
cost = context_property('cost') | |
cost_description = context_property('cost_description') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment