Permalink
Browse files

Implement export page. Closes #711.

  • Loading branch information...
1 parent 1cb5d2a commit 6c68f02e41f8cc6138fe3b253c425be681069a90 @onyxfish onyxfish committed May 25, 2012
@@ -4,6 +4,7 @@ PANDA.routers.Index = Backbone.Router.extend({
"login": "login",
"logout": "logout",
"": "search",
+ "search": "search",
"search/:query": "search",
"search/:query/:limit": "search",
"search/:query/:limit/:page": "search",
@@ -20,6 +21,7 @@ PANDA.routers.Index = Backbone.Router.extend({
"dataset/:slug/search/:query/:limit/:page": "dataset_search",
"user/:id": "user",
"dashboard": "dashboard",
+ "export/:id": "export",
"*path": "not_found"
},
@@ -67,6 +69,10 @@ PANDA.routers.Index = Backbone.Router.extend({
this.controller.goto_dashboard();
},
+ export: function(id) {
+ this.controller.goto_export(id);
+ },
+
not_found: function(path) {
this.controller.goto_not_found();
}
@@ -0,0 +1,20 @@
+PANDA.views.Export = Backbone.View.extend({
+ el: $("#content"),
+
+ initialize: function() {
+ _.bindAll(this);
+ },
+
+ reset: function(id) {
+ this.render();
+
+ $("#export-download").attr("src", "/api/1.0/export/" + id + "/download/");
+ },
+
+ render: function() {
+ var context = PANDA.utils.make_context({});
+
+ this.el.html(PANDA.templates.export(context));
+ }
+});
+
@@ -281,7 +281,10 @@ PANDA.views.Root = Backbone.View.extend({
var related_dataset = note.get("related_dataset");
if (related_export) {
- window.location = related_export + "download/";
+ var slash = related_export.lastIndexOf("/", related_export.length - 2);
+ var id = related_export.substring(slash + 1, related_export.length - 1);
+
+ this.goto_export(id);
}
else if (related_dataset) {
var slash = related_dataset.lastIndexOf("/", related_dataset.length - 2);
@@ -372,10 +375,10 @@ PANDA.views.Root = Backbone.View.extend({
this.current_content_view.search(query, limit, page);
- var path = "search/";
+ var path = "search";
if (query) {
- path += query;
+ path += "/" + query;
}
if (limit) {
@@ -491,6 +494,17 @@ PANDA.views.Root = Backbone.View.extend({
this._router.navigate("dashboard");
},
+ goto_export: function(id) {
+ if (!this.authenticate()) {
+ return;
+ }
+
+ this.current_content_view = this.get_or_create_view("Export");
+ this.current_content_view.reset(id);
+
+ this._router.navigate("export/" + id);
+ },
+
goto_not_found: function() {
if (!(this.current_content_view instanceof PANDA.views.NotFound)) {
this.current_content_view = this.get_or_create_view("NotFound");
@@ -0,0 +1,4 @@
+<div id="export">
+ <h2>Your export will begin downloading shortly...<h2>
+ <iframe id="export-download" src="" style="display:none;"></iframe>
+</div>
@@ -119,6 +119,7 @@
<script type="text/javascript" src="{{ settings.STATIC_URL }}js/views/user_change_password.js"></script>
<script type="text/javascript" src="{{ settings.STATIC_URL }}js/views/user.js"></script>
<script type="text/javascript" src="{{ settings.STATIC_URL }}js/views/dashboard.js"></script>
+ <script type="text/javascript" src="{{ settings.STATIC_URL }}js/views/export.js"></script>
<script type="text/javascript" src="{{ settings.STATIC_URL }}js/routers/index.js"></script>
<script type="text/javascript" src="{{ settings.STATIC_URL }}js/views/root.js"></script>
{% endcompress %}
@@ -84,11 +84,11 @@ def send_notifications(self, dataset, query, retval, einfo):
if query:
email_subject = 'Export complete: "%s" in %s' % (query, dataset_name)
- email_message = 'Export complete: "%s" in %s. Download your results:\n\nhttp://%s/api/1.0/export/%i/download/' % (query, dataset_name, config_value('DOMAIN', 'SITE_DOMAIN', export.id), export.id)
+ email_message = 'Export complete: "%s" in %s. Download your results:\n\nhttp://%s/#export/%i' % (query, dataset_name, config_value('DOMAIN', 'SITE_DOMAIN', export.id), export.id)
notification_message = 'Export complete: <strong>"%s" in %s</strong>' % (query, dataset_name)
else:
email_subject = 'Export complete: %s' % dataset_name
- email_message = 'Export complete: %s. Download your results:\n\nhttp://%s/api/1.0/export/%i/download/' % (dataset_name, config_value('DOMAIN', 'SITE_DOMAIN', export.id), export.id)
+ email_message = 'Export complete: %s. Download your results:\n\nhttp://%s/#export/%i' % (dataset_name, config_value('DOMAIN', 'SITE_DOMAIN', export.id), export.id)
notification_message = 'Export complete: <strong>%s</strong>' % dataset_name
notification_type = 'Info'

0 comments on commit 6c68f02

Please sign in to comment.