aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/user_controller.rb16
-rw-r--r--app/views/user/set_crop_profile_photo.rhtml2
-rw-r--r--app/views/user/set_draft_profile_photo.rhtml11
-rw-r--r--config/routes.rb1
4 files changed, 28 insertions, 2 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index fd9eb9fbf..854c0d989 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -398,6 +398,22 @@ class UserController < ApplicationController
end
end
+ def clear_profile_photo
+ # check they are logged in (the upload photo option is anyway only available when logged in)
+ if authenticated_user.nil?
+ flash[:error] = "You need to be logged in to clear your profile photo."
+ redirect_to frontpage_url
+ return
+ end
+
+ if @user.profile_photo
+ @user.profile_photo.destroy
+ end
+
+ flash[:notice] = "You've now cleared your profile photo"
+ redirect_to user_url(@user)
+ end
+
# before they've cropped it
def get_draft_profile_photo
profile_photo = ProfilePhoto.find(params[:id])
diff --git a/app/views/user/set_crop_profile_photo.rhtml b/app/views/user/set_crop_profile_photo.rhtml
index 7390f78a6..12ba4eba2 100644
--- a/app/views/user/set_crop_profile_photo.rhtml
+++ b/app/views/user/set_crop_profile_photo.rhtml
@@ -3,7 +3,7 @@
<% raise "internal error" if not @user %>
-<h2>2. Crop your profile photo</h2>
+<h2>Crop your profile photo</h2>
<%= foi_error_messages_for :set_profile_photo %>
diff --git a/app/views/user/set_draft_profile_photo.rhtml b/app/views/user/set_draft_profile_photo.rhtml
index de8566651..f0fb2d7ef 100644
--- a/app/views/user/set_draft_profile_photo.rhtml
+++ b/app/views/user/set_draft_profile_photo.rhtml
@@ -2,7 +2,7 @@
<% raise "internal error" if not @user %>
-<h2>1. Choose your profile photo</h2>
+<h2>Choose your profile photo</h2>
<%= foi_error_messages_for :set_profile_photo %>
@@ -34,5 +34,14 @@
<% end %>
+<% if @user.profile_photo %>
+
+ <h2>OR remove the existing photo</h2>
+
+ <% form_tag 'clear_photo', :id => 'clear_profile_photo_form', :multipart => true do %>
+ <%= submit_tag "Clear photo" %>
+ <% end %>
+
+<% end %>
</div>
diff --git a/config/routes.rb b/config/routes.rb
index 93936d681..d18bbb833 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -68,6 +68,7 @@ ActionController::Routing::Routes.draw do |map|
user.signchangeemail '/profile/change_email', :action => 'signchangeemail'
user.set_profile_photo '/profile/set_photo', :action => 'set_profile_photo'
+ user.clear_profile_photo '/profile/clear_photo', :action => 'clear_profile_photo'
user.get_profile_photo '/user/:url_name/photo.png', :action => 'get_profile_photo'
user.get_draft_profile_photo '/profile/draft_photo/:id.png', :action => 'get_draft_profile_photo'
user.set_profile_about_me '/profile/set_about_me', :action => 'set_profile_about_me'