Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Peter fogg/course image upload #700

Merged
merged 8 commits into from
Aug 21, 2013

Conversation

peter-fogg
Copy link
Contributor

@cahrens This should be mostly finished on the dev side. @singingwolfboy, I've made a few small changes to the file upload dialog and moved some code around to support that. Could you take a quick look at e8f40bc to ensure that everything is still OK?

@chrisndodge
Copy link
Contributor

Can't wait to try out the feature. Thanks!

validate: function(attrs, options) {
if(attrs.selectedFile && attrs.selectedFile.type !== this.attributes.mimeType) {
return {
message: "Only " + this.attributes.fileType + " files can be uploaded. Please select a file ending in ." + this.attributes.fileType.toLowerCase() + " to upload.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't counted on error messages with variable interpolations -- and I really should have thought about it. :( To properly internationalize this, we're going to need to do something like _.template(gettext("Only {fileType} files can be uploaded. Please select a file ending in {fileTypeLower} to upload."), {fileType: this.attributes.fileType, fileTypeLower: this.attributes.fileType.toLowerCase()}). Which is going to need restructuring the templates to expect internationalized strings, so it doesn't try to pass them through gettext twice. Ugh.

If you need to get this in quick, I'm fine with this approach for now, but the better way to do this would be to internationalize here. Sorry for my poor design decision when I made this.

@cahrens
Copy link

cahrens commented Aug 16, 2013

Needs a rebase, and a few comments above. In general though, it's looking really good.

@cahrens
Copy link

cahrens commented Aug 20, 2013

All the changes look good to me 👍 . Are you going to allow PNGs as well?

@peter-fogg
Copy link
Contributor Author

@cahrens Added PNG support for course images, as well as support for multiple file types in the uploader.

event.preventDefault();
var upload = new CMS.Models.FileUpload({
title: gettext("Upload your course image."),
message: gettext("Files must be in JPG format."),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or png

Also make how we talk about the extensions consistent (JPG vs .jpg). Or as consistent as you can (this is a nit).

@cahrens
Copy link

cahrens commented Aug 20, 2013

Make sure BDD spec describes which file types are/are not supported.

Peter Fogg and others added 7 commits August 21, 2013 09:42
Previously the file upload dialog was PDF- and textbook-specific. The
changes are adding parameters to the FileUpload model for the file
type, and adding an onSuccess callback to the UploadDialog view. Also
moved upload-specific SASS into its own file.
Authors can upload an image (or choose an existing one) from the
settings page, using the in-context uploader from PDF
textbooks. Includes tests for backwards compatibility with XML courses
-- they used a magic filename (images/course_image.jpg) which is
mapped to a location in the Mongo contentstore.

Still needs some UX work, though the backend plumbing is there.
- Internationalize upload errors.
- Move upload tests into their own files.
- Refactor upload dialog acceptance tests.
Also change the file uploader to accept multiple file types.
@cahrens
Copy link

cahrens commented Aug 21, 2013

Visually looked out the changes (did not check out branch), and they look good to me. Peter will investigate why the job failed. @talbs is going to check out the branch and give it a list whirl before the final OK to merge.

@@ -0,0 +1,209 @@
// studio - views - uploads
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts:

  1. Since this is something shared across views ideally (within PDF textbooks, Files & Uploads later, and now Settings), this should really be within the sass/elements/ directory.
  2. Also, in Sass files we use a 2-space tab indent for code (versus the 4 within JS).
  3. I'd prefer if the body class used to call this functionality was named "feature-upload" (we don't have a lot of body classes focused on features, but I can see this convention being used in the future).

Mind moving this and converting the tabs?

@talbs
Copy link
Contributor

talbs commented Aug 21, 2013

@peter-fogg, thanks for the additional work.

I created a new course to test out the state of when a course didn't have an image set (there's some copy/markup in the settings.html template to try to handle this) and when I checked out the state of the image on the settings page, I get a broken image (bad path/non-existent file) rather than the "Your course currently does not have an image..." copy/state (see screengrab below).

screen shot 2013-08-21 at 10 39 39 am

Is there something else that needs to be set up in the logic of the template or something I missed when setting up the copy?

@peter-fogg
Copy link
Contributor Author

@talbs I'll make those changes. The issue with the placeholder is that the default for course image is 'images_course_image.jpg' which is truthy in Python/Mako. This actually points to a more general issue of setting the image to an asset that doesn't exist. I'll set it to just hide the image on error; unless we've got a suitable default image?

@talbs
Copy link
Contributor

talbs commented Aug 21, 2013

@peter-fogg we don't have a suitable default image, and I can't think of a good one to represent all of the various subject matter/purposes behind courses authored. Unless anyone objects, I'd say lets not force a default image for now.

@peter-fogg
Copy link
Contributor Author

@talbs Sounds good. Is this good to merge, then?

@talbs
Copy link
Contributor

talbs commented Aug 21, 2013

👍 Sadly, this may be one of the last times I say this to you, "looks good, bring it to Mergetown"

@peter-fogg
Copy link
Contributor Author

😦 Sad times in merge city.

peter-fogg pushed a commit that referenced this pull request Aug 21, 2013
@peter-fogg peter-fogg merged commit e177270 into master Aug 21, 2013
@peter-fogg peter-fogg deleted the peter-fogg/course-image-upload branch August 21, 2013 18:17
chrisrossi pushed a commit to jazkarta/edx-platform that referenced this pull request Mar 31, 2014
Reset CapaProblem when state HTML is corrupt
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 3, 2016
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 3, 2016
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 3, 2016
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 3, 2016
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 3, 2016
e-kolpakov referenced this pull request in open-craft/edx-platform Jun 22, 2016
YONK-318: Update organizations list API to return number of courses
jenkins-ks pushed a commit to nttks/edx-platform that referenced this pull request Jun 30, 2016
caesar2164 added a commit to caesar2164/edx-platform that referenced this pull request Oct 24, 2017
…style

Fix positioning of Course Talk widget
jfavellar90 pushed a commit to eduNEXT/edx-platform that referenced this pull request Apr 11, 2018
…ter-courses-by-user-lang

fix filter courses by user lang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants