Beispiel #1
0
    def import_layout_type(self):
        """ Allows importing a batch of layouts by their template name
        """
        from eea.climateadapt._importer import import_layout
        from eea.climateadapt._importer import sql

        session = self._make_session()
        eea.climateadapt._importer.session = session
        site = self.context

        template = self.request.form.get('template', '').strip()
        if not template:
            raise ValueError("Please provide a template")

        for layout in session.query(sql.Layout).filter_by(privatelayout=False):
            if layout.type_ in [u'control-panel']:
                # we skip control panel pages
                continue

            settings = parse_settings(layout.typesettings)

            if layout.type_ == u'link_to_layout':
                llid = int(settings['linkToLayoutId'][0])
                try:
                    ll = session.query(
                        sql.Layout).filter_by(layoutid=llid).one()
                except:
                    print "Got error on layout", layout.friendlyurl
                    continue
                    import pdb
                    pdb.set_trace()
                this_url = layout.friendlyurl
                child_url = ll.friendlyurl
                folder = create_folder_at(site, this_url)
                folder.setLayout(child_url.split('/')[-1])
                folder.title = strip_xml(ll.name)
                continue

            try:
                layout_template = settings['layout-template-id'][0]
            except:
                import pdb
                pdb.set_trace()
            if not layout_template == template:
                continue

            try:
                cover = import_layout(layout, site)
            except:
                print "Couldn't import layout %s", layout.friendlyurl
            if cover:
                cover._imported_comment = \
                    "Imported from layout {0}".format(layout.layoutid)
                print "Created cover at %s" % cover.absolute_url()
Beispiel #2
0
    def import_layout_type(self):
        """ Allows importing a batch of layouts by their template name
        """
        from eea.climateadapt._importer import import_layout
        from eea.climateadapt._importer import sql

        session = self._make_session()
        eea.climateadapt._importer.session = session
        site = self.context

        template = self.request.form.get('template', '').strip()
        if not template:
            raise ValueError("Please provide a template")

        for layout in session.query(sql.Layout).filter_by(privatelayout=False):
            if layout.type_ in [u'control-panel']:
                # we skip control panel pages
                continue

            settings = parse_settings(layout.typesettings)

            if layout.type_ == u'link_to_layout':
                llid = int(settings['linkToLayoutId'][0])
                try:
                    ll = session.query(sql.Layout).filter_by(layoutid=llid).one()
                except:
                    print "Got error on layout", layout.friendlyurl
                    continue
                    import pdb; pdb.set_trace()
                this_url = layout.friendlyurl
                child_url = ll.friendlyurl
                folder = create_folder_at(site, this_url)
                folder.setLayout(child_url.split('/')[-1])
                folder.title = strip_xml(ll.name)
                continue

            try:
                layout_template = settings['layout-template-id'][0]
            except:
                import pdb; pdb.set_trace()
            if not layout_template == template:
                continue

            try:
                cover = import_layout(layout, site)
            except:
                print "Couldn't import layout %s", layout.friendlyurl
            if cover:
                cover._imported_comment = \
                    "Imported from layout {0}".format(layout.layoutid)
                print "Created cover at %s" % cover.absolute_url()
Beispiel #3
0
    def import_layout(self):
        from eea.climateadapt._importer import import_layout
        from eea.climateadapt._importer import sql

        session = self._make_session()
        eea.climateadapt._importer.session = session
        site = self.context

        uuid = self.request.form.get('uuid')
        if uuid:
            layout = session.query(sql.Layout).filter_by(privatelayout=False,
                                                         uuid_=uuid).one()
        else:
            id = self.request.form.get('layout')
            layout = session.query(sql.Layout).filter_by(privatelayout=False,
                                                         layoutid=id).one()

        cover = import_layout(layout, site)
        if cover:
            return self.request.response.redirect(cover.absolute_url())

        return "no cover?"