def related_news(self): result = [] curr_lang = queryAdapter(self.context, ILanguage).get_language() for i in self.refs: if IATNewsItem.providedBy(i): item_lang = queryAdapter(i, ILanguage).get_language() if item_lang == curr_lang: result.append(i) return result
def unfeedable_from_microsite(self): return ( IATDocument.providedBy( self.context ) or IATEvent.providedBy( self.context ) or IATNewsItem.providedBy( self.context ) ) and IMicroSiteFeed.providedBy(self.context)
def unfeedable_from_top(self): return ( IATDocument.providedBy( self.context ) or IATEvent.providedBy( self.context ) or IATNewsItem.providedBy( self.context ) ) and ITopPageFeed.providedBy(self.context)
def _is_document(self, item): if IATNewsItem.providedBy(item): return False if IDocument.providedBy(item): return True if IATFile.providedBy(item): return True if IATFolder.providedBy(item): return True return False
def categories(self): """Return list of dictionary :rtype: list """ res = [] if IATEvent.providedBy(self.context) or IATNewsItem.providedBy(self.context): parent_url = aq_parent(aq_inner(self.context)).absolute_url() for category in self.context.Subject(): res.append({ 'title': category, 'url': '{}?Subject={}'.format(parent_url, category), }) return res
def categories(self): """Return list of dictionary :rtype: list """ res = [] if IATEvent.providedBy(self.context) or IATNewsItem.providedBy( self.context): parent_url = aq_parent(aq_inner(self.context)).absolute_url() for category in self.context.Subject(): res.append({ 'title': category, 'url': '{}?Subject={}'.format(parent_url, category), }) return res
def unfeedable_from_microsite(self): return (IATDocument.providedBy(self.context) or IATEvent.providedBy(self.context) or IATNewsItem.providedBy( self.context)) and IMicroSiteFeed.providedBy(self.context)
def unfeedable_from_top(self): return (IATDocument.providedBy(self.context) or IATEvent.providedBy(self.context) or IATNewsItem.providedBy( self.context)) and ITopPageFeed.providedBy(self.context)
def data(self): context = self.context data = {} if ICollegeHomepage.providedBy(self.context): data = { '@context': 'http://schema.org', '@type': 'EducationalOrganization', 'address': { '@type': 'PostalAddress', 'addressLocality': 'University Park', 'addressRegion': 'PA', 'postalCode': '16802', 'streetAddress': 'Penn State University'}, 'logo': 'http://agsci.psu.edu/psu-agsciences-logo.png', 'name': 'Penn State College of Agricultural Sciences', 'sameAs': [ 'http://www.facebook.com/agsciences', 'http://www.twitter.com/agsciences', 'http://plus.google.com/+PennStateAgSciences', 'http://instagram.com/agsciences', 'http://www.linkedin.com/company/penn-state-college-of-agricultural-sciences', 'http://www.youtube.com/psuagsciences', 'http://en.wikipedia.org/wiki/Penn_State_College_of_Agricultural_Sciences'], 'telephone': '+1-814-865-7521', 'url': 'http://agsci.psu.edu' } elif IATEvent.providedBy(context): data = { '@context': 'http://schema.org', '@type': 'Event', 'name': context.Title(), 'description' : context.Description(), 'startDate' : toISO(context.start()), 'endDate' : toISO(context.end()), 'url' : context.absolute_url(), 'location' : { "@type" : "Place", "address" : getattr(context, 'location', ''), "name" : getattr(context, 'location', ''), } } elif IATNewsItem.providedBy(context): data = { '@context': 'http://schema.org', '@type': 'Article', 'headline': context.Title(), 'description' : context.Description(), 'datePublished' : toISO(context.effective()), 'url' : context.absolute_url(), } elif IPerson.providedBy(context): jobTitles = context.getJobTitles() if jobTitles: job_title = jobTitles[0] else: job_title = "" address = ', '.join(context.getOfficeAddress().strip().split("\n")) data = { '@context': 'http://schema.org', '@type': 'Person', 'url' : context.absolute_url(), 'email' : context.getEmail(), 'givenName' : context.getFirstName(), 'additionalName' : context.getMiddleName(), 'familyName' : context.getLastName(), 'telephone' : context.getOfficePhone(), 'jobTitle' : job_title, 'workLocation' : { '@type' : 'PostalAddress', 'addressCountry' : 'US', 'addressLocality' : context.getOfficeCity(), 'addressRegion' : context.getOfficeState(), 'postalCode' : context.getOfficePostalCode(), 'streetAddress' : address, } } data['image'] = self.getImage() if data: return json.dumps(data, indent=4) return None