-
Notifications
You must be signed in to change notification settings - Fork 8
/
petition_download.html
87 lines (73 loc) · 2.68 KB
/
petition_download.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{% extends "./wrapper.html" %}
{% block title %}
Download constituent comments and signatures
{% endblock %}
{% block script_additions %}
<script>
function showStatus(details) {
if ( details.status == 'error' ) {
var error = status.details.error.replace(/\n/g, '<br>');
$('#task-status').addClass('ak-err').html(
'Error: ' + (error || generic_error)
);
window.clearInterval(statusCheckTimer);
}
if ( details.status == 'complete' ) {
var download_url = (
'/constituents/finish_download/'
+ '?akid={{user.token}}&backgroundtask_id={{backgroundtask.id}}'
+ '&_rand=' + Math.random()
)
$('#task-status').html('<a href="' + download_url + '">Your file is ready! Click here to download.</a>');
window.clearInterval(statusCheckTimer);
}
if ( details.status == 'failed' ) {
$('#task-status').html('<b>Sorry, there was an error preparing your file</b>');
window.clearInterval(statusCheckTimer);
}
}
function checkStatus() {
actionkit.forms.createScriptElement(
'/constituents/check_download/'
+ '?akid={{user.token}}&backgroundtask_id={{backgroundtask.id}}'
+ '&_rand=' + Math.random()
);
}
</script>
{% endblock %}
{% block content %}
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-12-of-12">
{% if fmt %}
{% comment %}
Monitor the status of the PDF job, and
provide a download link when it's done.
{% endcomment %}
<h2>Download Constituent Signatures And Comments</h2>
<h2 id="task-status">We're preparing your file now...</h2>
<script>
actionkit.forms.initForm = function() {} // not an action form
statusCheckTimer = window.setInterval(checkStatus, 5000);
checkStatus();
</script>
{% else %}
{% comment %}
Need to pick format
{% endcomment %}
<h2>Choose Download Format</h2>
<ul>
<li>
<a href="?akid={{user.token}}&job_id={{job.id}}&fmt=pdf">
Download printable PDF
</a>
</li>
<li>
<a href="?akid={{user.token}}&job_id={{job.id}}&fmt=csv">
Download spreadsheet in CSV format (Excel-compatible)
</a>
</li>
</ul>
{% endif %}
</div>
</div>
{% endblock %}