From 73a15d508110dc55391116642f02c95032ce9f3f 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) --- extra/modules/root.py | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/extra/modules/root.py b/extra/modules/root.py index 6fc6a2d..4b6ac33 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')] @@ -1095,10 +1095,10 @@ class AlternateRootDirectory(OldRootDirectory): 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('') + r += htmltext('') % root_url + r += htmltext('

%s

') % _('Tracking code') + r += htmltext('') % _('ex: RPQDFVCD') + r += htmltext('') % _('Load') r += htmltext('
') r += self.links() @@ -1143,33 +1143,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