Files
edx-platform/cms/static/js/models/uploads.js
Peter Fogg 9632f4fed8 Address PR comments:
- Internationalize upload errors.
- Move upload tests into their own files.
- Refactor upload dialog acceptance tests.
2013-08-21 09:42:00 -04:00

29 lines
1.0 KiB
JavaScript

CMS.Models.FileUpload = Backbone.Model.extend({
defaults: {
"title": "",
"message": "",
"selectedFile": null,
"uploading": false,
"uploadedBytes": 0,
"totalBytes": 0,
"finished": false,
"mimeType": "application/pdf",
"fileType": "PDF"
},
// NOTE: validation functions should return non-internationalized error
// messages. The messages will be passed through gettext in the template.
validate: function(attrs, options) {
if(attrs.selectedFile && attrs.selectedFile.type !== this.attributes.mimeType) {
return {
message: _.template(
gettext("Only {fileType} files can be uploaded. Please select a file ending in .{fileExtension} to upload."),
{
fileType: this.attributes.fileType,
fileExtension: this.attributes.fileType.toLowerCase()
}),
attributes: {selectedFile: true}
};
}
}
});