From 5335c0bfb66cd2ba9e01a0c9dae8bdadc61c49fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 6 Nov 2016 13:14:11 +0100 Subject: [PATCH] update to "new" tracking code mechanism (#13875) This now requires the theme to declare the "include-tracking-code-form" keyword. --- extra/modules/root.py | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/extra/modules/root.py b/extra/modules/root.py index 6fc6a2d..9ea0f9a 100644 --- a/extra/modules/root.py +++ b/extra/modules/root.py @@ -767,7 +767,7 @@ class AlternateRootDirectory(OldRootDirectory): 'accessibility', 'contact', 'help', 'myspace', 'services', 'agenda', 'categories', 'user', ('tmp-upload', 'tmp_upload'), 'json', '__version__', - 'themes', 'pages', 'payment', 'invoices', 'accesscode', 'roles', + 'themes', 'pages', 'payment', 'invoices', 'roles', 'api', 'code', 'fargo', 'tryauth', 'auth', 'preview', ('reload-top', 'reload_top'), 'static', ('i18n.js', 'i18n_js')] @@ -1094,11 +1094,12 @@ class AlternateRootDirectory(OldRootDirectory): r = TemplateIO(html=True) root_url = get_publisher().get_root_url() - if self.has_anonymous_access_codes(): - r += htmltext('
') % root_url - r += htmltext('

%s

') % _('Tracking') - r += htmltext(' ') % _('Code:') - r += htmltext('') + if self.has_anonymous_access_codes() and path == [''] and ( + 'include-tracking-code-form' in get_response().filter.get('keywords', [])): + r += htmltext('') % root_url + r += htmltext('

%s

') % _('Tracking code') + r += htmltext('') % _('ex: RPQDFVCD') + r += htmltext('') % _('Load') r += htmltext('
') r += self.links() @@ -1143,33 +1144,7 @@ class AlternateRootDirectory(OldRootDirectory): return None def has_anonymous_access_codes(self): - for workflow in Workflow.select(): - for wfstatus in workflow.possible_status: - for wfitem in wfstatus.items: - if wfitem.key == 'create-anonymous-access-code': - return True - return False - - def accesscode(self): - code = get_request().form.get('code') - if not code: - return redirect(get_publisher().get_root_url()) - try: - token = Token.get(code) - except KeyError: - return redirect(get_publisher().get_root_url()) - if token.type != 'anonymous-access-code': - return redirect(get_publisher().get_root_url()) - formdef_urlname, formdata_id = token.formdata_reference - try: - formdata = FormDef.get_by_urlname(formdef_urlname).data_class().get(formdata_id) - except KeyError: - return redirect(get_publisher().get_root_url()) - session = get_session() - if not hasattr(session, '_wf_anonymous_access_authorized'): - session._wf_anonymous_access_authorized = [] - session._wf_anonymous_access_authorized.append(formdata.get_url()) - return redirect(formdata.get_url() + 'access/') + return any((x for x in FormDef.select() if x.enable_tracking_codes)) def links(self): links = Link.select() -- 2.10.2