def municipality_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, METATYPE_OBJECT) return self.getFormsTool().getContent( {'here': self, 'kind': METATYPE_OBJECT, 'action': 'addNyMunicipality', 'form_helper': form_helper}, 'municipality_add')
def youtube_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent( {'here': self, 'kind': config['meta_type'], 'action': 'addNyYoutube', 'form_helper': form_helper}, 'youtube_add')
def meeting_add_html(self): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent( {'here': self, 'kind': config['meta_type'], 'action': 'addNyMeeting', 'form_helper': form_helper}, 'meeting_add')
def sempublication_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent({'here': self, 'kind': METATYPE_OBJECT, 'action': 'addNySemPublication', 'form_helper': form_helper}, 'sempublication_add')
def meeting_add_html(self): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config["meta_type"]) return self.getFormsTool().getContent( {"here": self, "kind": config["meta_type"], "action": "addNyMeeting", "form_helper": form_helper}, "meeting_add" )
def semdocument_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config["meta_type"]) return self.getFormsTool().getContent( {"here": self, "kind": METATYPE_OBJECT, "action": "addNySemDocument", "form_helper": form_helper}, "semdocument_add", )
def disseminate_publication(self, REQUEST=None, RESPONSE=None): """ Disseminate your sust. tour publications or tools (NyPublication) """ meta_type = 'Naaya Publication' form_helper = get_schema_helper_for_metatype(self, meta_type) return self.getFormsTool().getContent({ 'here': self, 'kind': meta_type, 'action': 'addNyPublication_disseminate', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), }, 'publication_add')
def exfile_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent({ 'here': self, 'kind': config['meta_type'], 'action': 'addNyExFile', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), }, 'exfile_add')
def market_place_publication(self, REQUEST=None, RESPONSE=None): """ Place your product/service on the global sust tour. Market Place """ meta_type = 'Naaya Publication' form_helper = get_schema_helper_for_metatype(self, meta_type) return self.getFormsTool().getContent({ 'here': self, 'kind': meta_type, 'action': 'addNyPublication_market', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), }, 'publication_add')
def _update(self, portal): catalog = portal.portal_catalog all_objects = catalog.searchResults(something=True) schemas = {} portal_name = portal.id self.log.info('Start migration of internal links') for brain in all_objects: if not brain.meta_type in schemas: helper = get_schema_helper_for_metatype(portal, brain.meta_type) schemas[brain.meta_type] = helper.schema schema = schemas[brain.meta_type] if not schema: self.log.debug("No schema for %s", brain.meta_type) continue for field in schema.objectValues(): if field.meta_type == "Naaya Schema Text Area Widget": field_id = field.prop_name() obj = brain.getObject() self.log.debug("Checking field %s for %s", field_id, obj.absolute_url()) prop = getattr(obj, field_id, None) if prop: changed = False etree = lxml.html.fromstring(prop) for selector, attr in [('//a', 'href'), ('//img', 'src')]: elements = etree.xpath(selector) for el in elements: old_value = el.get(attr) if not old_value: continue split = filter(None, old_value.split('/')) if split[0] in ['http:', 'https:']: continue if split[0].startswith('mailto:'): continue if not portal_name == split[0]: new_value = "/".join(['', portal_name] + split) el.set(attr, new_value) changed = True self.log.debug("Fixing %s, %s => %s", selector, old_value, el.get(attr)) if changed: setattr(obj, field_id, lxml.html.tostring(etree)) self.log.info("Migrated links for %s", obj.absolute_url()) obj = brain.getObject() self.log.info('Finished migration of internal links') return True
def upload_html(self, REQUEST): """ Upload form for photo or zip file """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype def value_callback(prop_name): if prop_name in self.inherit_fields: return getattr(self, prop_name) form_helper = get_schema_helper_for_metatype(self, self.photo_metatype, value_callback) def fields_filter(item): return item['name'] in self.inherit_fields.union(['title']) form_items = list(filter(fields_filter, form_helper.form_items())) return self._upload_html(REQUEST, form_items=form_items)
def blog_entry_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent( { 'here': self, 'kind': config['meta_type'], 'action': 'addNyBlogEntry', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), }, 'blog_entry_add')
def add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import \ get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) parent = self.aq_parent return self.getFormsTool().getContent({ 'here': self, 'kind': config['meta_type'], 'action': 'process_add', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(parent, REQUEST), }, 'document_add')
def show_on_atlas(self, REQUEST=None, RESPONSE=None): """ Show your organisation on the global DestiNet Atlas """ meta_type = "Naaya Contact" form_helper = get_schema_helper_for_metatype(self, meta_type) return self.getFormsTool().getContent( { "here": self, "kind": meta_type, "action": "addNyContact_who_who", "form_helper": form_helper, "submitter_info_html": submitter.info_html(self, REQUEST), }, "contact_add", )
def market_place_publication(self, REQUEST=None, RESPONSE=None): """ Place your product/service on the global sust tour. Market Place """ meta_type = "Naaya Publication" form_helper = get_schema_helper_for_metatype(self, meta_type) return self.getFormsTool().getContent( { "here": self, "kind": meta_type, "action": "addNyPublication_market", "form_helper": form_helper, "submitter_info_html": submitter.info_html(self, REQUEST), }, "publication_add", )
def disseminate_publication(self, REQUEST=None, RESPONSE=None): """ Disseminate your sust. tour publications or tools (NyPublication) """ meta_type = "Naaya Publication" form_helper = get_schema_helper_for_metatype(self, meta_type) return self.getFormsTool().getContent( { "here": self, "kind": meta_type, "action": "addNyPublication_disseminate", "form_helper": form_helper, "submitter_info_html": submitter.info_html(self, REQUEST), }, "publication_add", )
def geopoint_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config["meta_type"]) return self.getFormsTool().getContent( { "here": self, "kind": config["meta_type"], "action": "addNyGeoPoint", "form_helper": form_helper, "submitter_info_html": submitter.info_html(self, REQUEST), }, "geopoint_add", )
def localizedbfile_add_html(self, REQUEST=None, RESPONSE=None): """ Create a Localized BFile object """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) d = { 'here': self, 'kind': config['meta_type'], 'action': 'addNyLocalizedBFile', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), } to_return = self.getFormsTool().getContent(d, 'localizedbfile_add') return to_return
def add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config["meta_type"]) parent = self.aq_parent return self.getFormsTool().getContent( { "here": self, "kind": config["meta_type"], "action": "process_add", "form_helper": form_helper, "submitter_info_html": submitter.info_html(parent, REQUEST), }, "story_add", )
def __call__(self, REQUEST): context = self.aq_parent try: ids = REQUEST.form['id'] except KeyError: self.context.setSessionErrorsTrans('No keywords were selected!') return self.request.RESPONSE.redirect(context.absolute_url()) if isinstance(ids, basestring): ids = [ids] items, schemas, keywords = [], [], [] for id in ids: item = context.getObjectById(id) if not item: item = context.unrestrictedTraverse(id) item_schema = get_schema_helper_for_metatype( context, item.meta_type) keywords_glossary = getattr(item_schema.schema, 'keywords-property', None) if not keywords_glossary: raise ValueError("%s meta type does not have keywords-property" " in schema" % item.meta_type) items.append(item) schemas.append(item_schema) keywords.append(keywords_glossary) glossary_id = context.getSite()._getOb('destinet_glossary_id', None) if glossary_id: glossary = context.getSite()._getOb(glossary_id, None) else: glossary = None options = { 'here': context, 'objects': items, 'schemas': schemas, 'keywords': keywords, 'site_glossary': glossary } return tmpl.__of__(context)(**options)
def __call__(self, REQUEST): context = self.aq_parent try: ids = REQUEST.form['id'] except KeyError: self.context.setSessionErrorsTrans('No keywords were selected!') return self.request.RESPONSE.redirect(context.absolute_url()) if isinstance(ids, basestring): ids = [ids] items, schemas, keywords = [], [], [] for id in ids: item = context.getObjectById(id) if not item: item = context.unrestrictedTraverse(id) item_schema = get_schema_helper_for_metatype(context, item.meta_type) keywords_glossary = getattr(item_schema.schema, 'keywords-property', None) if not keywords_glossary: raise ValueError("%s meta type does not have keywords-property" " in schema" % item.meta_type) items.append(item) schemas.append(item_schema) keywords.append(keywords_glossary) glossary_id = context.getSite()._getOb('destinet_glossary_id', None) if glossary_id: glossary = context.getSite()._getOb(glossary_id, None) else: glossary = None options = { 'here': context, 'objects': items, 'schemas': schemas, 'keywords': keywords, 'site_glossary': glossary } return tmpl.__of__(context)(**options)
def show_on_atlas(self, REQUEST=None, RESPONSE=None): """ Show your organisation on the global DestiNet Atlas """ meta_type = 'Naaya Contact' form_helper = get_schema_helper_for_metatype(self, meta_type) schema_tool = self.getSite().getSchemaTool() register_extra_schema = schema_tool['registration'] register_helper = SchemaFormHelper(register_extra_schema, self) groups_widget = register_helper._get_renderer( 'groups', register_extra_schema['groups-property'], False) return self.getFormsTool().getContent({ 'here': self, 'kind': meta_type, 'action': 'addNyContact_who_who', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), 'groups_widget':groups_widget, }, 'contact_add')
def show_on_atlas(self, REQUEST=None, RESPONSE=None): """ Show your organisation on the global DestiNet Atlas """ meta_type = 'Naaya Contact' form_helper = get_schema_helper_for_metatype(self, meta_type) schema_tool = self.getSite().getSchemaTool() register_extra_schema = schema_tool['registration'] register_helper = SchemaFormHelper(register_extra_schema, self) groups_widget = register_helper._get_renderer( 'groups', register_extra_schema['groups-property'], False) return self.getFormsTool().getContent( { 'here': self, 'kind': meta_type, 'action': 'addNyContact_who_who', 'form_helper': form_helper, 'submitter_info_html': submitter.info_html(self, REQUEST), 'groups_widget': groups_widget, }, 'contact_add')
def photo_add_html(self, REQUEST): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, METATYPE_NYPHOTO) return _photo_add_html.__of__(self)(REQUEST, form_helper=form_helper)
def network_add_html(self, REQUEST=None, RESPONSE=None): """ """ form_helper = get_schema_helper_for_metatype(self, METATYPE_OBJECT) return self.getFormsTool().getContent({'here': self, 'kind': METATYPE_OBJECT, 'action': 'addNyNetwork', 'form_helper': form_helper}, 'sdo_info_add')
def infofolder_add_html(self, REQUEST=None, RESPONSE=None): """ """ form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent({'here': self, 'kind': config['meta_type'], 'action': 'addNyInfoFolder', 'form_helper': form_helper}, 'infofolder_add')
def _update(self, portal): catalog = portal.portal_catalog all_objects = catalog.searchResults(something=True) schemas = {} portal_name = portal.id self.log.info('Start migration of internal links') for brain in all_objects: if not brain.meta_type in schemas: helper = get_schema_helper_for_metatype( portal, brain.meta_type) schemas[brain.meta_type] = helper.schema schema = schemas[brain.meta_type] if not schema: self.log.debug("No schema for %s", brain.meta_type) continue for field in schema.objectValues(): if field.meta_type == "Naaya Schema Text Area Widget": field_id = field.prop_name() obj = brain.getObject() self.log.debug("Checking field %s for %s", field_id, obj.absolute_url()) prop = getattr(obj, field_id, None) if prop: changed = False etree = lxml.html.fromstring(prop) for selector, attr in [('//a', 'href'), ('//img', 'src')]: elements = etree.xpath(selector) for el in elements: old_value = el.get(attr) if not old_value: continue split = filter(None, old_value.split('/')) if split[0] in ['http:', 'https:']: continue if split[0].startswith('mailto:'): continue if not portal_name == split[0]: new_value = "/".join(['', portal_name] + split) el.set(attr, new_value) changed = True self.log.debug("Fixing %s, %s => %s", selector, old_value, el.get(attr)) if changed: setattr(obj, field_id, lxml.html.tostring(etree)) self.log.info("Migrated links for %s", obj.absolute_url()) obj = brain.getObject() self.log.info('Finished migration of internal links') return True
def semevent_add_html(self, REQUEST=None, RESPONSE=None): """ """ from Products.NaayaBase.NyContentType import get_schema_helper_for_metatype form_helper = get_schema_helper_for_metatype(self, config['meta_type']) return self.getFormsTool().getContent({'here': self, 'kind': METATYPE_OBJECT, 'action': 'addNySemEvent', 'form_helper': form_helper}, 'semevent_add')