Exemplo n.º 1
0
def get_publishable_website(publishable):

    acceptable_websites = publishable.websites

    current_website = app.website
    if current_website is not None:
        if not acceptable_websites or current_website in acceptable_websites:
            return current_website

    for website in Website.select():
        if not acceptable_websites or website in acceptable_websites:
            return website
def import_old_settings(e):

    from woost.models import Configuration, Website

    for obj in (list(Configuration.select()) + list(Website.select())):
        try:
            value = obj._google_tag_manager_account
        except AttributeError:
            pass
        else:
            del obj._google_tag_manager_account
            obj.x_googletagmananager_container = value
def preserve_woost2_data(e):

    from woost.models import Website

    catalog = BlocksCatalog.require_instance(
        qname="woost.extensions.notices.blocks_catalog")

    for website in Website.select():
        blocks = set()
        try:
            value = website._notices
        except AttributeError:
            pass
        else:
            del website._notices
            if value:
                catalog.blocks.extend(value)
Exemplo n.º 4
0
def preserve_woost2_info(e):

    from woost.models import Configuration, Website, Publishable
    from .opengraphtype import OpenGraphType

    broken = datastore.root.get("woost2_broken_objects")
    ext_map = \
        broken and broken.get("woost.extensions.opengraph.OpenGraphExtension")
    ext = ext_map and ext_map.popitem()[1]

    if ext:

        # Must run before rebuild_indexes_after_conversion_to_python3, since
        # the index rebuilding can trigger the default value production for
        # Publication.x_opengraph_type, which in turn will attempt to obtain
        # a type by code.
        OpenGraphType.code.rebuild_index()

        def rename_attrib(obj, name, new_name=None):
            old_key = "_open_graph_" + name
            try:
                value = getattr(obj, old_key)
            except AttributeError:
                pass
            else:
                delattr(obj, old_key)
                new_key = "_x_opengraph_" + (new_name or name)
                setattr(obj, new_key, value)

        # Disable installation for the extension
        extensions_manager.set_installed("opengrah", True)

        for config in Configuration.select():
            rename_attrib(config, "default_image")
            if ext:
                config._x_opengraph_fb_admins = ext["_facebook_administrators"]
                config._x_opengraph_fb_apps = ext["_facebook_applications"]

        for website in Website.select():
            rename_attrib(website, "default_image")

        for pub in Publishable.select():
            rename_attrib(pub, "enabled")
            rename_attrib(pub, "type")
Exemplo n.º 5
0
def set_exportable_flag():

    for item in [Configuration.instance] + list(Website.select()):
        for key in ("login_page", "maintenance_page", "generic_error_page",
                    "not_found_error_page", "forbidden_error_page"):
            page = getattr(item, key, None)
            if page:
                page.x_staticpub_exportable = False

        for qname in ("woost.password_change_page",
                      "woost.password_change_confirmation_page"):
            page = Publishable.get_instance(qname=qname)
            if page:
                page.included_in_static_publication = False

    for cls in get_publishable_models():
        member = cls.get_member("x_staticpub_exportable")
        if member and member.indexed:
            member.rebuild_index()