Revision 5374ecec
Added by Frédéric Péters about 13 years ago
extra/modules/root.ptl | ||
---|---|---|
753 | 753 |
('announces', 'announces_dir'), |
754 | 754 |
'accessibility', 'contact', 'help', |
755 | 755 |
'myspace', 'services', 'agenda', |
756 |
'themes', 'pages', 'payment'] |
|
756 |
'themes', 'pages', 'payment', 'accesscode']
|
|
757 | 757 |
|
758 | 758 |
admin = admin.AdminRootDirectory() |
759 | 759 |
announces_dir = AnnouncesDirectory() |
... | ... | |
1022 | 1022 |
|
1023 | 1023 |
def box_side [html] (self, path): |
1024 | 1024 |
'<div id="sidebox">' |
1025 |
root_url = get_publisher().get_root_url() |
|
1026 |
|
|
1027 |
if self.has_anonymous_access_codes(): |
|
1028 |
'<form id="follow-form" action="%saccesscode">' % root_url |
|
1029 |
'<h3>%s</h3>' % _('Tracking') |
|
1030 |
'<label>%s</label> ' % _('Code:') |
|
1031 |
'<input name="code" size="10"/>' |
|
1032 |
'</form>' |
|
1033 |
|
|
1025 | 1034 |
self.links() |
1026 | 1035 |
|
1027 | 1036 |
cats = Category.select(order_by = 'name') |
... | ... | |
1040 | 1049 |
tags = get_cfg('misc', {}).get('event_tags') |
1041 | 1050 |
if not tags: |
1042 | 1051 |
tags = get_default_event_tags() |
1043 |
root_url = get_publisher().get_root_url() |
|
1044 | 1052 |
'<h3 id="agenda-link"><a href="%sagenda/">%s</a></h3>' % (root_url, _('Agenda')) |
1045 | 1053 |
|
1046 | 1054 |
if path and path[0] == 'agenda': |
... | ... | |
1056 | 1064 |
|
1057 | 1065 |
'</div>' |
1058 | 1066 |
|
1067 |
def has_anonymous_access_codes(self): |
|
1068 |
for workflow in Workflow.select(): |
|
1069 |
for wfstatus in workflow.possible_status: |
|
1070 |
for wfitem in wfstatus.items: |
|
1071 |
if wfitem.key == 'create-anonymous-access-code': |
|
1072 |
return True |
|
1073 |
return False |
|
1074 |
|
|
1075 |
def accesscode(self): |
|
1076 |
code = get_request().form.get('code') |
|
1077 |
if not code: |
|
1078 |
return redirect(get_publisher().get_root_url()) |
|
1079 |
try: |
|
1080 |
token = Token.get(code) |
|
1081 |
except KeyError: |
|
1082 |
return redirect(get_publisher().get_root_url()) |
|
1083 |
if token.type != 'anonymous-access-code': |
|
1084 |
return redirect(get_publisher().get_root_url()) |
|
1085 |
formdef_urlname, formdata_id = token.formdata_reference |
|
1086 |
try: |
|
1087 |
formdata = FormDef.get_by_urlname(formdef_urlname).data_class().get(formdata_id) |
|
1088 |
except KeyError: |
|
1089 |
return redirect(get_publisher().get_root_url()) |
|
1090 |
session = get_session() |
|
1091 |
if not hasattr(session, '_wf_anonymous_access_authorized'): |
|
1092 |
session._wf_anonymous_access_authorized = [] |
|
1093 |
session._wf_anonymous_access_authorized.append(formdata.get_url()) |
|
1094 |
return redirect(formdata.get_url() + 'access/') |
|
1059 | 1095 |
|
1060 | 1096 |
def links [html] (self): |
1061 | 1097 |
links = Link.select() |
Also available in: Unified diff
add a "tracing" form to access submitted requests anonymously