def send_charter_email(context, pdf, to, sender, body, language): """ sending the charter by mail """ mailhost = context.MailHost msg = MIMEMultipart() msg['Subject'] = translate(_(u"campaign_name", default=u"Healthy Workplaces"), target_language=language) msg['From'] = sender msg['To'] = to msg['Date'] = formatdate(localtime=True) msg.preamble = 'You will not see this in a MIME-aware mail reader.\n' params = dict(charset='utf-8') part = MIMEBase('text', 'html', **params) part.set_payload(body) msg.attach(part) part = MIMEBase('application', 'octet-stream') part.set_payload(pdf) Encoders.encode_base64(part) part.add_header( 'Content-Disposition', 'attachment; filename="campaign-certificate.pdf"', ) msg.attach(part) mailhost._send(sender, to, msg.as_string())
class IRelatedSites(model.Schema): """Marker / Form interface for additional links """ model.fieldset('settings', label=u"Settings", fields=['related_sites_links']) related_sites_links = schema.List( title=_(u"Related sites"), required=False, value_type=DictRow( title=u"tablerow", required=False, schema=ITableRowSchema, ), ) form.widget(related_sites_links=CustomTableWidgetFactory)
class ISeeAlso(model.Schema): """Marker / Form interface for internal references""" model.fieldset('settings', label=u"Settings", fields=['see_also']) see_also = RelationList( title=_(u"See also"), description=u"Pick existing items", required=False, value_type=RelationChoice( title=u"Select an existing item", required=False, source=ObjPathSourceBinder(), ), ) form.widget(see_also=MultiContentTreeFieldWidget) directives.languageindependent('see_also')
'LV': 'Latvia', 'MT': 'Malta', 'NL': 'Netherlands', 'NO': 'Norway', 'PO': 'Poland', 'PT': 'Portugal', 'RO': 'Romania', 'SE': 'Sweden', 'SI': 'Slovenia', 'SK': 'Slovakia', } ORDERED_COUNTRIES = OrderedDict(sorted(COUNTRIES.items(), key=lambda t: t[0])) countries = SimpleVocabulary( [SimpleTerm(value=name, title=_(name)) for (code, name) in ORDERED_COUNTRIES.items()] ) countries_with_ids = SimpleVocabulary( [SimpleTerm(value=code, title=_(name)) for (code, name) in ORDERED_COUNTRIES.items()]) ORG_TYPES = [ 'Enterprises', 'Trade unions', 'Employer organisations', 'OSH professionals', 'Research', 'Other'] organisation_types = SimpleVocabulary( [SimpleTerm(value=item, title=_(item)) for item in ORG_TYPES] ) FOP_ORG_TYPES = [ 'State Agency', 'Labour Inspectorate ', 'Public institution',
def get_translated_validation_messages(self): context = aq_inner(self.context) request = context.REQUEST fieldnames = { 'organisation': translate(_('Company/Organisation')), 'address': translate(_('Address')), 'postal_code': translate(_('Postal Code')), 'city': translate(_('City')), 'country': translate(_('Country')), 'firstname': translate(_('Firstname')), 'lastname': translate(_('Lastname')), 'sector': translate(_('Sector')), 'email': translate(_('Email')), 'telephone': translate(_('Telephone')), 'privacy': translate(_(u'Privacy')), } messages = {} for field_id in fieldnames: fieldname = fieldnames[field_id] err_msgs = { 'required': translate( _(u'error_required', default=u'${name} is required, please correct.', mapping={'name': fieldname}), context=request, ), 'email': translate( _(u"You entered an invalid email address."), context=request, ), } messages[field_id] = err_msgs return {'messages': messages}
# import csv import json import time import xlrd import xlwt PRIVACY_POLICY_NAME = "privacy-policy-certificate-of-participation" log = getLogger(__name__) # consider translating the strings email_template = _(u"charter_feedback_email_text", default=u"""<p>Thank you for actively supporting the Healthy Workplaces Campaign!</p> <p>Please find a PDF version of the Campaign certificate attached to this email, which you may print.</p> <p>For more information on the Healthy Workplaces Campaign, please visit the website at http://www.healthy-workplaces.eu.</p> <p>To keep up to date with the latest news, subscribe to EU-OSHA newsletter https://osha.europa.eu/en/news/oshmail/</p> """) def logit(*kwargs): " log something from the web " try: mesg = '' for kwarg in kwargs: mesg += str(kwarg) + ' ' print mesg except: print [kwargs]
# Add i18n msgids here which do not exist in filesystem code so that # the translation-extract script can find them from osha.hwccontent import _ # Months _("January") _("February") _("March") _("April") _("May") _("June") _("July") _("August") _("September") _("October") _("November") _("December") # organisation types _('Enterprises') _('Trade unions') _('Employer organisations') _('OSH professionals') _('Research') _('Other') # Footer _('Privacy Policy') _('Disclaimer') _('Copyright')
'LV': 'Latvia', 'MT': 'Malta', 'NL': 'Netherlands', 'NO': 'Norway', 'PO': 'Poland', 'PT': 'Portugal', 'RO': 'Romania', 'SE': 'Sweden', 'SI': 'Slovenia', 'SK': 'Slovakia', } ORDERED_COUNTRIES = OrderedDict(sorted(COUNTRIES.items(), key=lambda t: t[0])) countries = SimpleVocabulary([ SimpleTerm(value=name, title=_(name)) for (code, name) in ORDERED_COUNTRIES.items() ]) countries_with_ids = SimpleVocabulary([ SimpleTerm(value=code, title=_(name)) for (code, name) in ORDERED_COUNTRIES.items() ]) ORG_TYPES = [ 'Enterprises', 'Trade unions', 'Employer organisations', 'OSH professionals', 'Research', 'Other' ] organisation_types = SimpleVocabulary( [SimpleTerm(value=item, title=_(item)) for item in ORG_TYPES])
# Add i18n msgids here which do not exist in filesystem code so that # the translation-extract script can find them from osha.hwccontent import _ # Months _("January") _("February") _("March") _("April") _("May") _("June") _("July") _("August") _("September") _("October") _("November") _("December") # organisation types _('Enterprises') _('Trade unions') _('Employer organisations') _('OSH professionals') _('Research') _('Other') # Footer _('Privacy Policy') _('Disclaimer')