Exemplo n.º 1
0
 def get_links_by_section(self, section):
     context = self.context
     if IAnnotatedLinkList.providedBy(self.context):
         links = context.Schema().getField('annotatedlinklist').get(context)
         return [i for i in links if i["section"] == section]
     else:
         return None
Exemplo n.º 2
0
    def __init__(self, context):
        self.context = context
        if IAnnotatedLinkList.providedBy(context):
            self._fields.append(
                        extended_fields_dict.get('annotatedlinklist').copy()
                        )

        self._generateMethods(context, self._fields)
Exemplo n.º 3
0
def run(self):
    # This script must be customised before running
    raise Exception

    def log(message):
        self.REQUEST.response.write(str(message) + "\n")

    def get_translation_obs(ob):
        return [i[0] for i in ob.getTranslations().values()]

    subtyper = component.getUtility(ISubtyper)

    portal = self.portal_url.getPortalObject()
    fop_root = portal.en.oshnetwork["focal-points"]
    countries = [
        i for i in fop_root.objectIds() if fop_root[i].portal_type == "Folder"
    ]

    countries = ['slovakia']
    for country in countries:
        fop = fop_root[country]
        doc = fop.get("index_html", None)
        if doc:
            # [log(i) for i in providedBy(doc)]
            # log(IAnnotatedLinkList.providedBy(doc))
            for translation in get_translation_obs(doc):
                type = subtyper.existing_type(doc)
                # log("%s : %s" %(translation.absolute_url(), type))
                if not IAnnotatedLinkList.providedBy(translation):
                    log("ERROR %s : %s" % (translation.absolute_url(), type))
                    subtyper.change_type(translation, 'annotatedlinks')
                    log("Updated %s" % translation.absolute_url())
                    transaction.commit()

                #if type and type.name == 'annotatedlinks':
                #    try:
                #        subtyper.remove_type(translation)
                #    except:
                #        pass
                #subtyper.change_type(translation, 'annotatedlinks')
                # log("Updated %s" %translation.absolute_url())
                # transaction.commit()
        else:
            log("ERROR index_html is missing %s" % fop.absolute_url())
Exemplo n.º 4
0
def run(self):
    # This script must be customised before running
    raise Exception
    def log(message):
        self.REQUEST.response.write(str(message)+"\n")

    def get_translation_obs(ob):
        return [i[0] for i in ob.getTranslations().values()]

    subtyper = component.getUtility(ISubtyper)

    portal = self.portal_url.getPortalObject()
    fop_root = portal.en.oshnetwork["focal-points"]
    countries = [i for i in fop_root.objectIds() if fop_root[i].portal_type == "Folder"]

    countries = ['slovakia']
    for country in countries:
        fop = fop_root[country]
        doc = fop.get("index_html", None)
        if doc:
            # [log(i) for i in providedBy(doc)]
            # log(IAnnotatedLinkList.providedBy(doc))
            for translation in get_translation_obs(doc):
                type = subtyper.existing_type(doc)
                # log("%s : %s" %(translation.absolute_url(), type))
                if not IAnnotatedLinkList.providedBy(translation):
                    log("ERROR %s : %s" %(translation.absolute_url(), type))
                    subtyper.change_type(translation, 'annotatedlinks')
                    log("Updated %s" %translation.absolute_url())
                    transaction.commit()

                #if type and type.name == 'annotatedlinks':
                #    try:
                #        subtyper.remove_type(translation)
                #    except:
                #        pass
                #subtyper.change_type(translation, 'annotatedlinks')
                # log("Updated %s" %translation.absolute_url())
                # transaction.commit()
        else:
            log("ERROR index_html is missing %s" %fop.absolute_url())
Exemplo n.º 5
0
 def get_links(self, obj):
     if IAnnotatedLinkList.providedBy(obj):
         return obj.annotatedlinklist
Exemplo n.º 6
0
 def has_links(self):
     """ Check if this page has been subtyped to provide annotated
     links """
     context = self.context
     return IAnnotatedLinkList.providedBy(context) and \
         context.Schema().getField('annotatedlinklist').get(context)