Permalink
Browse files

Add a warning for large file uploads. Closes #928.

  • Loading branch information...
1 parent b895c30 commit 2c1a1ab166d180de75152fa82c71768d4c56b5aa @onyxfish onyxfish committed Nov 24, 2013
@@ -31,6 +31,7 @@ PANDA.text.DataUpload = function() {
start_over: gettext("Start over"),
error_title: gettext("Error processing dataset"),
error_close: gettext("Close"),
- dataset_upload_error: gettext("Error uploading dataset: %(message)s")
+ dataset_upload_error: gettext("Error uploading dataset: %(message)s"),
+ file_size_warning: gettext('Warning, you are uploading a very large file. In some cases this may fail. For an alternate way of uploading very large files see <a href="http://panda.readthedocs.org/en/latest/manual_imports.html">http://panda.readthedocs.org/en/%(version)s/manual_imports.html</a>.')
}
}
@@ -171,6 +171,10 @@ PANDA.views.DataUpload = Backbone.View.extend({
$("#step-2 .progress-value").css("width", pct + "%");
$("#step-2 .progress-value strong").text(pct + "%");
+
+ if (total >= PANDA.settings.WARN_UPLOAD_SIZE && !$('#step-2-alert').hasClass('alert-warning')) {
+ this.step_two_warning_message(interpolate(this.text.file_size_warning, { version: PANDA.settings.VERSION }, true));
+ }
},
on_complete: function(id, fileName, responseJSON) {
@@ -205,6 +209,10 @@ PANDA.views.DataUpload = Backbone.View.extend({
$("#step-1-alert").alert("alert-error", message + ' <input id="step-1-start-over" type="button" class="btn" value="' + gettext("Try again") + '" />' , false);
},
+ step_two_warning_message: function(message) {
+ $("#step-2-alert").alert("alert-warning", message, false);
+ },
+
step_two_error_message: function(message) {
$("#step-2-alert").alert("alert-error", message + ' <input id="step-2-start-over" type="button" class="btn" value="' + gettext("Try again") + '" />' , false);
},
@@ -97,6 +97,7 @@
PANDA.settings.AVAILABLE_SPACE_WARN = {{ settings.PANDA_AVAILABLE_SPACE_WARN }};
PANDA.settings.AVAILABLE_SPACE_CRITICAL = {{ settings.PANDA_AVAILABLE_SPACE_CRITICAL }};
PANDA.settings.PANDA_NOTIFICATIONS_TO_SHOW = {{ settings.PANDA_NOTIFICATIONS_TO_SHOW }};
+ PANDA.settings.WARN_UPLOAD_SIZE = {{ warn_upload_size }};
PANDA.settings.MAX_UPLOAD_SIZE = {{ max_upload_size }};
PANDA.settings.EMAIL_ENABLED = {{ email_enabled }};
PANDA.settings.DEMO_MODE_ENABLED = {{ demo_mode_enabled }};
View
@@ -43,6 +43,7 @@ def index(request):
return render_to_response('index.html', {
'settings': settings,
+ 'warn_upload_size': int(config_value('MISC', 'WARN_UPLOAD_SIZE')),
'max_upload_size': int(config_value('MISC', 'MAX_UPLOAD_SIZE')),
'email_enabled': int(config_value('EMAIL', 'EMAIL_ENABLED')),
'demo_mode_enabled': int(config_value('MISC', 'DEMO_MODE_ENABLED')),
View
@@ -246,7 +246,7 @@
PANDA_DEFAULT_SEARCH_GROUPS = 10
PANDA_DEFAULT_SEARCH_ROWS_PER_GROUP = 5
PANDA_DEFAULT_SEARCH_ROWS = 50
-PANDA_SNIFFER_MAX_SAMPLE_SIZE = 1024 * 100 # 100kb
+PANDA_SNIFFER_MAX_SAMPLE_SIZE = 1024 * 100 # 100 KB
PANDA_SAMPLE_DATA_ROWS = 5
PANDA_SCHEMA_SAMPLE_ROWS = 100
PANDA_ACTIVATION_PERIOD = datetime.timedelta(days=30)
View
@@ -99,11 +99,20 @@
config_register(PositiveIntegerValue(
MISC_GROUP,
+ 'WARN_UPLOAD_SIZE',
+ description=_('File size at which a warning about large file uploads is issued, in bytes.'),
+ help_text=_('The default value is equivalent to 100MB.'),
+ default=104857600,
+ ordering=1
+))
+
+config_register(PositiveIntegerValue(
+ MISC_GROUP,
'MAX_UPLOAD_SIZE',
description=_('Maximum size allowed for user-uploaded files, in bytes.'),
help_text=_('The default value is equivalent to 1GB.'),
default=1073741824,
- ordering=1
+ ordering=2
))
# Performance settings

0 comments on commit 2c1a1ab

Please sign in to comment.