def __call__(self):
     registry = queryUtility(IRegistry)
     settings = registry.forInterface(ICookieConsentSettings)
     portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     site = portal_state.portal()
     data_settings = IJSONifier(settings).json()
     data_settings["actual_url"] = self.request["ACTUAL_URL"]
     data_settings["here_url"] = self.context.absolute_url()
     data_settings["dashboard_url"] = get_url_to_dashboard()
     data_settings["portal_path"] = site.absolute_url_path()
     return data_settings
Exemplo n.º 2
0
 def __call__(self):
     registry = queryUtility(IRegistry)
     settings = registry.forInterface(ICookieConsentSettings)
     portal_state = getMultiAdapter((self.context, self.request),
                                    name=u'plone_portal_state')
     site = portal_state.portal()
     data_settings = IJSONifier(settings).json()
     data_settings['actual_url'] = self.request['ACTUAL_URL']
     data_settings['here_url'] = self.context.absolute_url()
     data_settings['dashboard_url'] = get_url_to_dashboard()
     data_settings['portal_path'] = site.absolute_url_path()
     data_settings['portal_url'] = site.absolute_url()
     return data_settings
Exemplo n.º 3
0
 def __call__(self):
     registry = queryUtility(IRegistry)
     settings = registry.forInterface(ICookieConsentSettings)
     portal_state = getMultiAdapter((self.context, self.request),
                                    name=u"plone_portal_state")
     site = portal_state.portal()
     data_settings = IJSONifier(settings).json()
     data_settings["actual_url"] = (self.request["ACTUAL_URL"] + "?" +
                                    self.request.QUERY_STRING)
     data_settings["here_url"] = self.context.absolute_url()
     data_settings["dashboard_url"] = get_url_to_dashboard()
     data_settings["portal_path"] = site.absolute_url_path()
     data_settings["portal_url"] = site.absolute_url()
     return data_settings
Exemplo n.º 4
0
    def data(self, record):
        result = super(CookieBannerSettingsAdapter, self).data(record)
        new_text = result['text']

        # privacy_link_url can be a document path, not an URL
        privacy_link_url = result['privacy_link_url']
        if privacy_link_url and privacy_link_url.startswith('/'):
            site = getSite()
            privacy_link_url = site.absolute_url() + privacy_link_url
        privacy_link_text = result['privacy_link_text'] or privacy_link_url

        dashboard_link_url = get_url_to_dashboard()
        dashboard_link_text = result[
            'dashboard_link_text'] or dashboard_link_url

        # privacy link
        new_text = pattern_privacy_link.sub(
            URL_MODEL.format(privacy_link_url, privacy_link_text, r'\2'),
            new_text)
        new_text = pattern_privacy_link_url.sub(privacy_link_url + r'\2',
                                                new_text)
        new_text = pattern_privacy_link_text.sub(privacy_link_text + r'\2',
                                                 new_text)

        # opt-out dashboard link
        new_text = pattern_dashboard_link.sub(
            URL_MODEL.format(dashboard_link_url, dashboard_link_text, r'\2'),
            new_text)
        new_text = pattern_dashboard_link_url.sub(dashboard_link_url + r'\2',
                                                  new_text)
        new_text = pattern_dashboard_link_text.sub(dashboard_link_text + r'\2',
                                                   new_text)

        new_text = new_text.strip().replace("\n", "<br />\n")
        result['text'] = self.cleanHTML(new_text)
        result['privacy_link_url'] = privacy_link_url
        del result['privacy_link_text']
        del result['dashboard_link_text']
        return result
    def data(self, record):
        result = super(CookieBannerSettingsAdapter, self).data(record)
        new_text = result['text']

        # privacy_link_url can be a document path, not an URL
        privacy_link_url = result['privacy_link_url']
        if privacy_link_url.startswith('/'):
            site = getSite()
            privacy_link_url = site.absolute_url() + privacy_link_url
        privacy_link_text = result['privacy_link_text'] or privacy_link_url

        dashboard_link_url = get_url_to_dashboard()
        dashboard_link_text = result['dashboard_link_text'] or dashboard_link_url

        # privacy link
        new_text = pattern_privacy_link.sub(URL_MODEL.format(privacy_link_url,
                                                             privacy_link_text,
                                                             r'\2'),
                                    new_text)
        new_text = pattern_privacy_link_url.sub(privacy_link_url + r'\2', new_text)
        new_text = pattern_privacy_link_text.sub(privacy_link_text + r'\2', new_text)

        # opt-out dashboard link
        new_text = pattern_dashboard_link.sub(URL_MODEL.format(dashboard_link_url,
                                                               dashboard_link_text,
                                                             r'\2'),
                                    new_text)
        new_text = pattern_dashboard_link_url.sub(dashboard_link_url + r'\2', new_text)
        new_text = pattern_dashboard_link_text.sub(dashboard_link_text + r'\2', new_text)

        new_text = new_text.strip().replace("\n", "<br />\n")
        result['text'] = self.cleanHTML(new_text)
        result['privacy_link_url'] = privacy_link_url
        del result['privacy_link_text']
        del result['dashboard_link_text']
        return result