FEATURE: Allow a user to upload an image for their expansion background.

This commit is contained in:
Robin Ward
2014-10-16 15:05:36 -04:00
parent bde0820cd4
commit 4d465362b5
11 changed files with 112 additions and 9 deletions
+8 -1
View File
@@ -461,6 +461,8 @@ class UsersController < ApplicationController
upload_avatar_for(user, upload)
when "profile_background"
upload_profile_background_for(user.user_profile, upload)
when "expansion_background"
upload_expansion_background_for(user.user_profile, upload)
end
else
render status: 422, text: upload.errors.full_messages
@@ -490,6 +492,8 @@ class UsersController < ApplicationController
image_type = params.require(:image_type)
if image_type == 'profile_background'
user.user_profile.clear_profile_background
elsif image_type == 'expansion_background'
user.user_profile.clear_expansion_background
else
raise Discourse::InvalidParameters.new(:image_type)
end
@@ -547,8 +551,11 @@ class UsersController < ApplicationController
def upload_profile_background_for(user_profile, upload)
user_profile.upload_profile_background(upload)
# TODO: add a resize job here
render json: { url: upload.url, width: upload.width, height: upload.height }
end
def upload_expansion_background_for(user_profile, upload)
user_profile.upload_expansion_background(upload)
render json: { url: upload.url, width: upload.width, height: upload.height }
end