class EditForm(base.EditForm): form_fields = form.Fields(IRegionMapPortlet) label = _(u"Edit Region Map Portlet") description = _(u"Portlet showing the region map") form_fields['africa'].custom_widget = UberSelectionWidget form_fields['north_america'].custom_widget = UberSelectionWidget form_fields['south_america'].custom_widget = UberSelectionWidget form_fields['pacific'].custom_widget = UberSelectionWidget form_fields['caribbean'].custom_widget = UberSelectionWidget form_fields['asia'].custom_widget = UberSelectionWidget form_fields['europe'].custom_widget = UberSelectionWidget form_fields['middle_east'].custom_widget = UberSelectionWidget
class AddForm(base.AddForm): form_fields = form.Fields(IRegionMapPortlet) label = _(u"Add Region Map Portlet") description = _(u"Portlet showing the region map") form_fields['africa'].custom_widget = UberSelectionWidget form_fields['north_america'].custom_widget = UberSelectionWidget form_fields['south_america'].custom_widget = UberSelectionWidget form_fields['pacific'].custom_widget = UberSelectionWidget form_fields['caribbean'].custom_widget = UberSelectionWidget form_fields['asia'].custom_widget = UberSelectionWidget form_fields['europe'].custom_widget = UberSelectionWidget form_fields['middle_east'].custom_widget = UberSelectionWidget def create(self, data): return Assignment(**data)
class ICountry(form.Schema, IImageScaleTraversable): """ Country Information """ # If you want a schema-defined interface, delete the form.model # line below and delete the matching file in the models sub-directory. # If you want a model-based interface, edit # models/country.xml to define the content type # and add directives here as necessary. country_code = schema.Choice( title=_(u'Country Code'), description=_(u'ISO 3166-1 alpha-2 code for this country'), required=True, vocabulary='wcc.vocabulary.country' )
class IChurchFamily(form.Schema, IImageScaleTraversable): """ Church Family """ websites = schema.List( title=_(u'label_websites', u'Websites'), value_type=schema.TextLine(), required=False, )
def table_widgets(self): result = [] provider = self.provider for i in ['population', 'surface_area']: widget = self.w[i] result.append({ 'label': widget.label, 'render': widget.render() }) result.append({ 'label': _(u'Capital'), 'render': lookup_capital(self.context.country_code) }) for i in ['gni_percapita', 'classification', 'languages']: widget = self.w[i] result.append({ 'label': widget.label, 'render': widget.render(), }) # religion religions = getattr(self.context, 'religions', []) rows = ['<tr><th>%s :</th><td>%s%%</td></tr>' % (i['religion'], i['percentage']) for i in religions] result.append({ 'label': _(u'Religions'), 'render': '<table id="country-religions-table">%s</table>' % ''.join(rows) }) denominations = getattr(self.context, 'christianity_denominations', []) rows = ['<tr><th>%s :</th><td>%s</td></tr>' % (i['denomination'], i['count']) for i in denominations] result.append({ 'label': _(u'Denominations'), 'render': '<table id="country-denominations-table">%s</table>' % ''.join(rows) }) return result
class IChurchBody(form.Schema, IBasic, IImageScaleTraversable): """ Church Body """ # If you want a schema-defined interface, delete the form.model # line below and delete the matching file in the models sub-directory. # If you want a model-based interface, edit # models/churchbody.xml to define the content type # and add directives here as necessary. title = schema.TextLine( title = _(u'label_short_title', default=u'Short Name / Abbreviation'), required = True ) full_title = schema.TextLine( title=_(u'label_full_title', u'Full Name'), required=True ) dexteritytextindexer.searchable('text') form.widget(text="plone.app.z3cform.wysiwyg.WysiwygFieldWidget") text = schema.Text( title=_(u'label_body_text', u"Body Text"), description=u'', required=False, ) member_of = RelationChoice( title=_(u'label_member_of', u"Member Of"), source=ObjectProvidesPathSourceBinder(object_provides=[ 'wcc.churches.churchfamily.IChurchFamily', 'wcc.churches.churchbody.IChurchBody' ]), required=False ) assoc_member_of = RelationChoice( title=_(u'label_assoc_member_of', u'Associate Member Of'), source=ObjectProvidesPathSourceBinder( object_provides=[ 'wcc.churches.churchfamily.IChurchFamily', 'wcc.churches.churchbody.IChurchBody', ] ), required=False ) form.widget(other_members="plone.app.z3cform.wysiwyg.WysiwygFieldWidget") other_members = schema.Text( title=_(u'label_other_members', u'Other Members'), required=False ) form.widget(other_assoc_members="plone.app.z3cform.wysiwyg.WysiwygFieldWidget") other_assoc_members = schema.Text( title=_(u'label_other_assoc_members', u'Other Associate Members'), required=False ) remoteUrl = schema.TextLine( title=_(u"Website"), default=u'http://', description=u"", required=False, ) form.order_before(full_title = '*') form.order_before(title = '*')
class IChurchMember(form.Schema, IImageScaleTraversable): """ Church Member """ languageindependent('church_image') church_image = NamedBlobImage( title=_(u'Image'), required=False, ) languageindependent('church_family') church_family = RelationChoice( title=_(u'Church Family'), source=ObjectProvidesPathSourceBinder( object_provides='wcc.churches.churchfamily.IChurchFamily'), required=False) languageindependent('based_in') based_in = schema.Choice( title=_(u'Based in'), vocabulary='wcc.vocabulary.country', description=_(u''), required=False, ) languageindependent('present_in') present_in = schema.List( title=_(u'Present in'), value_type=schema.Choice(vocabulary='wcc.vocabulary.country'), description=_(u''), required=False, ) languageindependent('membership') membership = schema.Int( title=_(u'Membership'), description=_(u''), required=False, ) languageindependent('pastors') pastors = schema.Int(title=_(u'Pastors'), description=_(u''), required=False) languageindependent('congregations') congregations = schema.Int(title=_(u'Congregations'), description=_(u''), required=False) languageindependent('member_of') member_of = RelationList( title=_(u'label_member_of', u"Member Of"), default=[], value_type=RelationChoice(source=ObjectProvidesPathSourceBinder( object_provides='wcc.churches.churchbody.IChurchBody')), required=False) languageindependent('assoc_member_of') assoc_member_of = RelationList( title=_(u'label_assoc_member_of', u'Associate Member Of'), default=[], value_type=RelationChoice(source=ObjectProvidesPathSourceBinder( object_provides='wcc.churches.churchbody.IChurchBody'), ), required=False) languageindependent('wcc_member_since') wcc_member_since = schema.Date(title=u'WCC Member Since', min=date(1900, 1, 1), max=date.today(), required=False) languageindependent('remoteUrl') remoteUrl = schema.TextLine( title=_(u"Website"), default=u'http://', description=u"", required=False, )
from collective.grok import gs from wcc.churches import MessageFactory as _ from plone.registry.interfaces import IRegistry from zope.component import getUtility from wcc.churches.interfaces import IWccChurchSettings @gs.importstep( name=u'wcc.churches', title=_('wcc.churches import handler'), description=_('')) def setupVarious(context): if context.readDataFile('wcc.churches.marker.txt') is None: return portal = context.getSite() registry = getUtility(IRegistry) registry.registerInterface(IWccChurchSettings) # do anything here
from collective.grok import gs from wcc.churches import MessageFactory as _ from plone.registry.interfaces import IRegistry from zope.component import getUtility from wcc.churches.interfaces import IWccChurchSettings @gs.importstep(name=u'wcc.churches', title=_('wcc.churches import handler'), description=_('')) def setupVarious(context): if context.readDataFile('wcc.churches.marker.txt') is None: return portal = context.getSite() registry = getUtility(IRegistry) registry.registerInterface(IWccChurchSettings) # do anything here
class ILocationTags(form.Schema): countries = schema.List( title=_(u"Related Countries"), value_type=schema.Choice(vocabulary="wcc.vocabulary.country"), required=False)
from collective.grok import gs from wcc.churches import MessageFactory as _ @gs.importstep(name=u"wcc.churches", title=_("wcc.churches import handler"), description=_("")) def setupVarious(context): if context.readDataFile("wcc.churches.marker.txt") is None: return portal = context.getSite() # do anything here
def title(self): return _('Region Map Portlet')
class IRegionMapPortlet(IPortletDataProvider): """ Define your portlet schema here """ africa = schema.Choice( title=_(u"Africa"), description=_(u'Region content to link the Africa region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) north_america = schema.Choice( title=_(u"North America"), description=_(u'Region content to link the North America region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) south_america = schema.Choice( title=_(u"South America"), description=_(u'Region content to link the South America region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) pacific = schema.Choice( title=_(u"Pacific"), description=_(u'Region content to link the Pacific region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) caribbean = schema.Choice( title=_(u"Caribbean"), description=_(u'Region content to link the Caribbean region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) asia = schema.Choice( title=_(u"Asia"), description=_(u'Region content to link the Asia region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) europe = schema.Choice( title=_(u"Europe"), description=_(u'Region content to link the Europe region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False ) middle_east = schema.Choice( title=_(u"Middle East"), description=_(u'Region content to link the Middle East region to'), source=SearchableTextSourceBinder({'portal_type': 'wcc.churches.region'}, default_query='path:'), required=False )