def sendRequestAlbumMail(self): request = self.request fullname = request["fullname"] email = request["email"] team = request["team"] access_type = request["access_type"] new_album_name = request["new_album_name"] usage_description = request["usage_description"] album = request["album"] try: accept_conditions = request["accept_conditions"] except: accept_conditions = False request_content = {} validForm = validateaddress(email) validForm = validForm and fullname and team and accept_conditions if access_type == "New album request": validForm = validForm and new_album_name and usage_description request_content["fullname"] = fullname request_content["email"] = email request_content["team"] = team request_content["usage_description"] = usage_description request_content["access_type"] = access_type request_content["new_album_name"] = new_album_name request_content["album"] = album request_content["accept_conditions"] = accept_conditions if not validForm: request_content["sent"] = "no" return request_content request_content["sent"] = "ok" subject = _(u"[IUEM Photo repository] Album or access request") # message = fullname + '\n' + email + '\n' + team + '\n' # message = message + usage_description + '\n' # message = message + '\n' # import pdb;pdb.set_trace() message = _(u"Your request : ") + _(access_type) + "\n" message += _(u"Name : ") + unicode(fullname, "utf8") + "\n" message += _(u"email adress : ") + unicode(email, "utf-8") + "\n" message += _(u"team : ") + unicode(team, "utf-8") + "\n" message += _(u"full album URL : ") + unicode(album, "utf-8") + "/" + unicode(new_album_name, "utf-8") + "\n" message += _(u"album usage : ") + unicode(usage_description, "utf-8") + "\n\n" reg = getUtility(IRegistry) settings = reg.forInterface(IPhotorepositorySettings) mailhost = getToolByName(self.context, "MailHost") mfrom = settings.request_album_from for target in settings.request_album_emails: mailhost.send(message.encode("utf8"), subject=subject, mto=target, mfrom=mfrom, charset="utf8") copy_message = _(u"copy-of-message :\n\n") + message mailhost.send(copy_message.encode("utf8"), subject=subject, mto=email, mfrom=mfrom, charset="utf8") return request_content
def sendRequestImageMail(self): request = self.request fullname = request['fullname'] email = request['email'] team = request['team'] usage_description = request['usage_description'] urlSourceImage = request['urlSourceImage'] + '/view' try: accept_conditions = request['accept_conditions'] except: accept_conditions = False request_content = {} request_content['fullname'] = fullname request_content['email'] = email request_content['team'] = team request_content['usage_description'] = usage_description request_content['urlSourceImage'] = urlSourceImage request_content['accept_conditions'] = accept_conditions validForm = validateaddress(email) validForm = validForm and fullname and team and usage_description validForm = validForm and accept_conditions if not validForm: request_content['sent'] = 'no' return request_content subject = _(u'[IUEM Photo repository] Image request') # message = fullname + '\n' + email + '\n' + team + '\n' # message = message + usage_description + '\n' # message = message + urlSourceImage + '\n' message = _(u"Original image request from :\n") message += _(u"Name : ") + unicode(fullname,'utf8') + '\n' message += _(u"email adress : ") + email + '\n' message += _(u"team : ") + unicode(team,'utf-8') + '\n' message += _(u"Image usage : ") + unicode(usage_description,'utf-8') + '\n\n' message += _(u"Image URL : ") + urlSourceImage reg = getUtility(IRegistry) settings = reg.forInterface(IPhotorepositorySettings) mailhost = getToolByName(self.context , 'MailHost') mfrom = settings.request_image_from for target in settings.request_image_emails: mailhost.send(message.encode('utf8') , subject = subject ,\ mto = target , mfrom = mfrom , charset='utf8') copy_message = _(u"copy-of-message :\n\n") + message mailhost.send(copy_message.encode('utf8') , subject = subject ,\ mto = email , mfrom = mfrom , charset='utf8') request_content['sent'] = 'ok' return request_content
from zope import schema from plone.supermodel import model from z3c.form import field , button from plone.directives import form from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from iuem.photorepository import iuemRepositoryMessageFactory as _ defaultWatermarkConfigValue = u"var config = {\n" defaultWatermarkConfigValue = defaultWatermarkConfigValue + u' "position": "bottom-left",\n' defaultWatermarkConfigValue = defaultWatermarkConfigValue + u' "opacity": 8,\n' defaultWatermarkConfigValue = defaultWatermarkConfigValue + u' "className": "watermark",\n' defaultWatermarkConfigValue = defaultWatermarkConfigValue + u' "path": "++resource++iuem_repository_static/img/filigrane.png"\n' defaultWatermarkConfigValue = defaultWatermarkConfigValue + u'};' watermarkPos = SimpleVocabulary( [SimpleTerm(value=u'center', title=_(u'Center')), SimpleTerm(value=u'topleft', title=_(u'Top Left')), SimpleTerm(value=u'topright', title=_(u'Top Right')), SimpleTerm(value=u'bottomleft', title=_(u'Bottom Left')), SimpleTerm(value=u'bottomright', title=_(u'Bottom Right'))] ) # thanks to # http://plone.org/documentation/kb/how-to-create-a-plone-control-panel-with-plone.app.registry class IPhotorepositorySettings(Interface): model.fieldset('requestimagessettings' , label = _(u"Requests configurations"), fields = ['request_image_emails', 'request_image_from', 'request_image_url', 'request_album_emails', 'request_album_from', 'request_album_url'], ) request_image_emails = schema.List (