Esempio n. 1
0
 def _dynamic_content(self):
     context = aq_inner(self.context)
     memberinfo = self.memberdata()
     data = {}
     data['title'] = context.Title()
     data['summary'] = context.Description()
     data['location'] = context.location
     data['text'] = context.text.output
     data['url'] = self._construct_webview_link()
     data['pdf'] = self.pdf_download_link(context)
     data['date'] = self.localize(datetime.now(), longformat=False)
     if IPressRelease.providedBy(context):
         if context.kicker:
             data['kicker'] = context.kicker
         else:
             data['kicker'] = ''
         if context.subtitle:
             data['subtitle'] = context.subtitle
         else:
             data['subtitle'] = ''
         if context.image:
             url = context.absolute_url()
             filename = context.image.filename
             data['file_url'] = url + '/@@download/attachment/' + filename
             data['file_name'] = filename
             data['image_tag'] = self.getImageTag(context)
             data['file_caption'] = context.imagename
         data['attachments'] = self.getAttachments()
     if IPressInvitation.providedBy(context):
         if context.schedule:
             data['schedule'] = context.schedule.output
         else:
             data['schedule'] = ''
         if context.travel:
             data['travel'] = context.travel
         else:
             data['travel'] = ''
         if context.directions:
             data['directions'] = context.directions
         else:
             data['directions'] = ''
         data['start'] = context.start.strftime("%d.%m.%Y %H:%M")
         data['end'] = context.end.strftime("%d.%m.%Y %H:%M")
         closed = context.closed
         if closed is True:
             closed_msg = translate(
                 _(u"Diese Veranstaltung kann nur auf Einladung besucht "
                   u"werden. Von einer Publikation bitten wir daher "
                   u"abzusehen."),
                 domain='pressapp.presscontent',
                 target_language='de')
             data['closed'] = closed_msg
         else:
             data['closed'] = ''
     if memberinfo:
         data['org'] = memberinfo['org']
         data['link'] = memberinfo['link']
     return data
Esempio n. 2
0
 def generate_pdf(self):
     item = self.target_item
     if IPressRelease.providedBy(item):
         attachment = item.unrestrictedTraverse(
             '@@asPlainPDFCustom')(converter='pdf-pisa',
                                   resource='pressapp_resource',
                                   template='pdf_template_standalone')
     if IPressInvitation.providedBy(item):
         attachment = item.unrestrictedTraverse(
             '@@asPlainPDFCustom')(converter='pdf-pisa',
                                   resource='pressapp_resource',
                                   template='pdf_template_standalone_pi')
     return attachment
Esempio n. 3
0
 def _getPressCenterData(self):
     context = aq_inner(self.context)
     portal = getSite()
     presscenter = portal['presscenter']
     data = {}
     if IPressInvitation.providedBy(context):
         data['template'] = presscenter.mailtemplate_pi
     else:
         data['template'] = presscenter.mailtemplate
     data['stylesheet'] = presscenter.stylesheet
     data['sender'] = presscenter.name
     data['email'] = presscenter.email
     return data
Esempio n. 4
0
 def _getPressCenterData(self, obj):
     context = obj
     portal = getSite()
     presscenter = portal["presscenter"]
     data = {}
     if IPressInvitation.providedBy(context):
         data["template"] = presscenter.mailtemplate_pi
     else:
         data["template"] = presscenter.mailtemplate
     data["stylesheet"] = presscenter.stylesheet
     data["sender"] = presscenter.name
     data["email"] = presscenter.email
     return data
Esempio n. 5
0
 def applyChanges(self, data):
     context = aq_inner(self.context)
     assert IPressInvitation.providedBy(context)
     fti = getUtility(IDexterityFTI,
             name='pressapp.presscontent.pressinvitation')
     schema = fti.lookupSchema()
     fields = getFieldsInOrder(schema)
     for key, value in fields:
         try:
             new_value = data[key]
             setattr(context, key, new_value)
         except KeyError:
             continue
     context.setDescription(data['description'])
     modified(context)
     context.reindexObject(idxs='modified')
     IStatusMessage(self.request).addStatusMessage(
         _(u"Press invitation was successfully updated"),
         type='info')
     return self.request.response.redirect(context.absolute_url() + '/view')
Esempio n. 6
0
 def applyChanges(self, data):
     context = aq_inner(self.context)
     if IPressRelease.providedBy(context):
         fti_name = "pressapp.presscontent.pressrelease"
     if IPressInvitation.providedBy(context):
         fti_name = "pressapp.presscontent.pressinvitation"
     fti = getUtility(IDexterityFTI, name=fti_name)
     schema = fti.lookupSchema()
     fields = getFieldsInOrder(schema)
     for key, value in fields:
         try:
             new_value = data[key]
             setattr(context, key, new_value)
         except KeyError:
             continue
     setattr(context, "channel", list(data["channel"]))
     if self.has_recipients_info():
         setattr(context, "recipients", list())
     modified(context)
     context.reindexObject(idxs="modified")
     IStatusMessage(self.request).addStatusMessage(_(u"A channel was successfully selected"), type="info")
     next_url = context.absolute_url() + "/@@recipient-list"
     return self.request.response.redirect(next_url)
Esempio n. 7
0
 def is_pressinvitation(self):
     context = aq_inner(self.context)
     return IPressInvitation.providedBy(context)
Esempio n. 8
0
 def _dynamic_content(self, target_obj):
     context = target_obj
     memberinfo = self.memberdata()
     data = {}
     data["title"] = context.Title()
     data["summary"] = context.Description()
     data["location"] = context.location
     data["text"] = context.text.output
     data["url"] = self._construct_webview_link(context)
     data["pdf"] = self.pdf_download_link(context)
     data["date"] = self.format_time(context.Date())
     if IPressRelease.providedBy(context):
         if context.kicker:
             data["kicker"] = getattr(context, "kicker", "")
         else:
             data["kicker"] = ""
         if context.subtitle:
             data["subtitle"] = context.subtitle
         else:
             data["subtitle"] = ""
         if context.image:
             url = context.absolute_url()
             filename = context.image.filename
             data["file_url"] = url + "/@@download/attachment/" + filename
             data["file_name"] = filename
             data["image_tag"] = self.getImageTag(context)
             data["file_caption"] = context.imagename
         data["attachments"] = self.getAttachments()
     if IPressInvitation.providedBy(context):
         if context.schedule:
             data["schedule"] = context.schedule.output
         else:
             data["schedule"] = ""
         if context.travel:
             data["travel"] = context.travel
         else:
             data["travel"] = ""
         if context.directions:
             data["directions"] = context.directions
         else:
             data["directions"] = ""
         data["start"] = context.start.strftime("%d.%m.%Y %H:%M")
         data["end"] = context.end.strftime("%d.%m.%Y %H:%M")
         closed = context.closed
         if closed is True:
             closed_msg = translate(
                 _(
                     u"Diese Veranstaltung kann nur auf Einladung besucht "
                     u"werden. Von einer Publikation bitten wir daher "
                     u"abzusehen."
                 ),
                 domain="pressapp.presscontent",
                 target_language="de",
             )
             data["closed"] = closed_msg
         else:
             data["closed"] = ""
     if memberinfo:
         data["org"] = memberinfo["org"]
         data["link"] = memberinfo["link"]
     return data