class IBluechurchpage(model.Schema): """ Marker interface for Bluechurchpage """ homepage = URI_bluechurch( title=_(u"Website"), description=_(u"e.g. www.abcjazzz.com"), required=False, ) beteiligte = RelationList( title=_(u"Artists"), description=_(u"Beteiligte Artists, Veranstalter"), required=False, value_type=RelationChoice( vocabulary='plone.app.vocabularies.Catalog', )) widget('beteiligte', RelatedItemsFieldWidget, pattern_options={ 'selectableTypes': [ 'dexterity.membrane.bluechurchmembraneprofile', ], 'basePath': get_profiles_base_path, }) model.fieldset('categorization', fields=[ 'beteiligte', ]) model.load('bluechurchpage.xml')
class IOwnercontact(model.Schema): """Add kontaktperson to content """ # Kontaktperson # TODO: Default Kontaktperson # read_permission(kontaktperson='zope2View') # write_permission(kontaktperson='rohberg.bluechurch.addbluechurchcontent') kontaktperson = RelationChoice( title=_(u"Kontaktperson"), # description=_(u"Kontaktperson"), required=True, vocabulary='plone.app.vocabularies.Catalog', defaultFactory=profile_current_user, ) # order_after(notes='*') widget('kontaktperson', RelatedItemsFieldWidget, pattern_options={ 'selectableTypes': [ 'dexterity.membrane.bluechurchmembraneprofile', ], 'basePath': get_profiles_base_path, }) model.fieldset('categorization', label=_(u'Relations'), fields=['kontaktperson'])
class IBluechurchevent(model.Schema): """ Marker interface for Bluechurchevent """ directives.order_after(city='IEventLocation.location') city = schema.TextLine(title=_(u'label_city', default=u'City'), description=_(u'help_city', default=u''), required=True) directives.order_after(country='city') country = schema.Choice(title=_(u'label_country', default=u'Country'), description=_( u'help_country', default=u'Select the country from the list.'), required=True, vocabulary='collective.address.CountryVocabulary') widget(eventformen='z3c.form.browser.checkbox.CheckBoxFieldWidget') eventformen = schema.Set( title=_(u'Event Type'), value_type=schema.Choice(vocabulary='rohberg.bluechurch.Eventformen'), required=False, ) model.load('bluechurchevent.xml')
class ProfileContactFormSchema(interface.Interface): messagesubject = schema.TextLine( title=_(u"label_subject"), required=True, ) messagetext = schema.Text( title=_(u"label_messagetext"), required=True, )
class IBluechurchlocation(model.Schema): """ Marker interface for Bluechurchlocation """ # TODO: make location fields searchable # dexteritytextindexer.searchable('bio') homepage = URI_bluechurch( title=_(u"Website"), description=_(u"e.g. www.abcjazzz.com"), required=False, ) model.load('bluechurchlocation.xml')
def map_configuration(self): map_layers = getrec('rohberg.bluechurch.map_layers') or [] config = { "minimap": True, "default_map_layer": getrec('rohberg.bluechurch.default_map_layer'), "map_layers": [ {"title": _(it), "id": it} for it in map_layers ], } return json.dumps(config)
def update(self): # TODO: Profile nur in Folder "profiles". cleanup restriction to folder profiles container = aq_inner(self.context) if container.id != "profiles": raise Unauthorized(_(u"No Profiles here. Change to 'Profiles'.")) is_manager = api.user.has_permission('Manage portal') is_sitemanager = False if not (api.user.is_anonymous() or is_manager): current = api.user.get_current() user = current username = user.getName() roles = api.user.get_roles(username=username) is_sitemanager = "Site Administrator" in roles logger.info("roles and is_anonymous: {} {}".format( roles, is_sitemanager)) if not (api.user.is_anonymous() or is_manager or is_sitemanager): raise Unauthorized(_(u"You are already registered.")) # try: # super(AddForm, self).update() # except ValueError, e: # logger.warn("User tried to add Profile outside folder profile") super(AddForm, self).update()
def handleApply(self, action): logger.info("contact_bluechurchprofile") context = self.context data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return # Handle order here. For now, just print it to the console. A more # realistic action would be to send the order to another system, send # an email, or similar fullname = INameFromTitle(context).title response = self.request.response request = self.request current = api.user.get_current() current_profile = api.content.get(UID=current.id) if not current_profile: response.redirect(self.context.absolute_url()) return recipient = self.context sender = current_profile subject = data['messagesubject'] # subject = subject or _(u"{} wants to contact you due to Jazz and Sermon stuff.".format(INameFromTitle(sender).title)) # subject = subject.decode('utf-8') text = data['messagetext'] #.decode('utf-8') messages = IStatusMessage(request) try: sendMail(sender, recipient, subject, text, request) logger.info("contact_bluechurchprofile send.") except Exception, e: msg = _(u"Message '{}' not sent to {}. There were errors.".format( subject, recipient.email)) logger.error(msg) logger.error(str(e)) # messages.addStatusMessage(_(msg, "error")) raise e
class IBluechurchmembraneprofile(IMember): """ Artist or Event Manager """ # TODO: make membrane fields searchable dexteritytextindexer.searchable('first_name') dexteritytextindexer.searchable('last_name') dexteritytextindexer.searchable('bio') website = URI_bluechurch( title=_(u"Website"), description=_(u"e.g. www.abcjazzz.com"), required=False, ) widget(profile_type='z3c.form.browser.checkbox.CheckBoxFieldWidget') profile_type = schema.Set( title=_(u"Profile Type"), value_type=schema.Choice(vocabulary=profile_types), required=True, ) directives.widget( bluechurchtags='z3c.form.browser.checkbox.CheckBoxFieldWidget') bluechurchtags = schema.Set( title=_(u'Bluechurch Tags'), value_type=schema.Choice( vocabulary='rohberg.bluechurch.BluchurchTags'), required=False, ) zip_code = schema.TextLine(title=_(u'label_zip_code', default=u'Zip Code'), description=_(u'help_zip_code', default=u''), required=True) city = schema.TextLine(title=_(u'label_city', default=u'City'), description=_(u'help_city', default=u''), required=True) country = schema.Choice(title=_(u'label_country', default=u'Country'), description=_( u'help_country', default=u'Select the country from the list.'), required=True, vocabulary='collective.address.CountryVocabulary') bluechurchcaptcha = schema.Int( title=_(u"bluechurchcaptcha"), description=_(u"Prevent spam by typing in the result of 13 + 4."), min=17, max=17) directives.omitted('bluechurchcaptcha') directives.no_omit(IAddForm, 'bluechurchcaptcha') model.fieldset('categorization', label=_(u'Relations')) # directives.omitted('relatedItems') # directives.no_omit(IEditForm, 'relatedItems') model.load('bluechurchmembraneprofile.xml')
from dexterity.membrane.content.member import IMember from collective import dexteritytextindexer from dexterity.membrane.behavior.password import IProvidePasswords from dexterity.membrane.behavior.user import INameFromFullName from rohberg.bluechurch.fields import URI_bluechurch import logging logger = logging.getLogger(__name__) from rohberg.bluechurch import _ profile_types = SimpleVocabulary([ SimpleTerm(value=u'artist', title=_(u'Artist')), SimpleTerm(value=u'band', title=_(u'Band')), SimpleTerm(value=u'theologian', title=_(u'Theologian')), SimpleTerm(value=u'interested', title=_(u'Interested Person')), SimpleTerm(value=u'eventmanager', title=_(u'Event Manager')) ]) class IBluechurchmembraneprofile(IMember): """ Artist or Event Manager """ # TODO: make membrane fields searchable dexteritytextindexer.searchable('first_name') dexteritytextindexer.searchable('last_name') dexteritytextindexer.searchable('bio')
class IBluechurchControlPanel(Interface): # TODO widget for bluechurchtags # form.widget(bluechurchtags=AjaxSelectWidget) bluechurchtags = schema.List(title=u'Schlagworte', description=u'Schlagworte, Tags, ', value_type=schema.TextLine(), default=[ "Spiritual Jazz/Sacred Jazz", "Dixie", "Swing", "Bebop", "Latin", "Cool Jazz", "Kinder", "Ethno" ]) eventformen = schema.List( title=u'Eventformen', description=u'Jazzgottesdienst, etc', value_type=schema.TextLine(), default=[ "Jazzgottesdienst", "Liturgischer Jazz", "Konzert", "Workshop" ], ) profiles_base = schema.TextLine( title=_(u"Profiles Folder"), default=u"", required=False, ) locations_base = schema.TextLine( title=_(u"Locations Folder"), default=u"", required=False, ) default_map_layer = schema.Choice( title=_(u'default_map_layer', u'Default map layer'), description=_(u'help_default_map_layer', default=u'Set the default map layer'), required=False, default=default_map_layer, vocabulary='rohberg.bluechurch.map_layers') map_layers = schema.List( title=_(u'label_map_layers', u'Map Layers'), description=_(u'help_map_layers', default=u'Set the available map layers'), required=False, default=default_map_layers, missing_value=[], value_type=schema.Choice(vocabulary='rohberg.bluechurch.map_layers')) GTMCode = schema.TextLine( title=u'GTMCode', description=u'Google Tag Manager Code', required=False, ) google_api_key = schema.TextLine( title=_(u'label_google_api_key', default=u'Google maps API Key'), description=_( u'help_google_api_key', default= u'If you want to use the Google Maps search API for higher accuracy, you have to provide a Google Maps API key here.' ), required=False, default=None)
class ProfileContactForm(AutoExtensibleForm, form.Form): schema = ProfileContactFormSchema form_name = 'contact_form' label = _(u"Contact an Artist or Event Manager" ) # TODO: name des Artists anzeigen # description = _(u"We will contact you to confirm your order and delivery.") description = _( u"The recipient gets an email with your email address to get back to you." ) def update(self): # disable Plone's editable border self.request.set('disable_border', True) # call the base class version - this is very important! super(ProfileContactForm, self).update() @button.buttonAndHandler(_(u'label_send')) def handleApply(self, action): logger.info("contact_bluechurchprofile") context = self.context data, errors = self.extractData() if errors: self.status = self.formErrorsMessage return # Handle order here. For now, just print it to the console. A more # realistic action would be to send the order to another system, send # an email, or similar fullname = INameFromTitle(context).title response = self.request.response request = self.request current = api.user.get_current() current_profile = api.content.get(UID=current.id) if not current_profile: response.redirect(self.context.absolute_url()) return recipient = self.context sender = current_profile subject = data['messagesubject'] # subject = subject or _(u"{} wants to contact you due to Jazz and Sermon stuff.".format(INameFromTitle(sender).title)) # subject = subject.decode('utf-8') text = data['messagetext'] #.decode('utf-8') messages = IStatusMessage(request) try: sendMail(sender, recipient, subject, text, request) logger.info("contact_bluechurchprofile send.") except Exception, e: msg = _(u"Message '{}' not sent to {}. There were errors.".format( subject, recipient.email)) logger.error(msg) logger.error(str(e)) # messages.addStatusMessage(_(msg, "error")) raise e # Redirect back to the front page with a status message messages.addStatusMessage( _(u"Message '{}' sent to {}.".format(subject, fullname)), "info") logger.info("jetzt redirect") # TODO: im Modal bleiben. contextURL = recipient.absolute_url() self.request.response.redirect(contextURL)
# subject = subject or _(u"{} wants to contact you due to Jazz and Sermon stuff.".format(INameFromTitle(sender).title)) # subject = subject.decode('utf-8') text = data['messagetext'] #.decode('utf-8') messages = IStatusMessage(request) try: sendMail(sender, recipient, subject, text, request) logger.info("contact_bluechurchprofile send.") except Exception, e: msg = _(u"Message '{}' not sent to {}. There were errors.".format( subject, recipient.email)) logger.error(msg) logger.error(str(e)) # messages.addStatusMessage(_(msg, "error")) raise e # Redirect back to the front page with a status message messages.addStatusMessage( _(u"Message '{}' sent to {}.".format(subject, fullname)), "info") logger.info("jetzt redirect") # TODO: im Modal bleiben. contextURL = recipient.absolute_url() self.request.response.redirect(contextURL) @button.buttonAndHandler(_(u"label_cancel")) def handleCancel(self, action): """User cancelled. Redirect back to the front page. """ contextURL = self.context.absolute_url() self.request.response.redirect(contextURL)