Allow users to remove their image. Closes #1010.
This commit is contained in:
parent
9c580277ef
commit
1e98eb9950
3 changed files with 14 additions and 4 deletions
|
@ -2,8 +2,8 @@ class UserController < ApplicationController
|
|||
layout 'site'
|
||||
|
||||
before_filter :authorize, :only => [:api_details, :api_gpx_files]
|
||||
before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend, :remove_friend, :upload_image]
|
||||
before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image]
|
||||
before_filter :authorize_web, :only => [:account, :go_public, :view, :diary, :make_friend, :remove_friend, :upload_image, :delete_image]
|
||||
before_filter :require_user, :only => [:set_home, :account, :go_public, :make_friend, :remove_friend, :upload_image, :delete_image]
|
||||
before_filter :check_database_availability, :except => [:api_details, :api_gpx_files]
|
||||
before_filter :check_read_availability, :only => [:api_details, :api_gpx_files]
|
||||
|
||||
|
@ -167,6 +167,12 @@ class UserController < ApplicationController
|
|||
redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
|
||||
end
|
||||
|
||||
def delete_image
|
||||
@user.image = nil
|
||||
@user.save!
|
||||
redirect_to :controller => 'user', :action => 'view', :display_name => @user.display_name
|
||||
end
|
||||
|
||||
def api_details
|
||||
render :text => @user.to_xml.to_s, :content_type => "text/xml"
|
||||
end
|
||||
|
|
|
@ -20,7 +20,10 @@
|
|||
|
||||
<h3>User image</h3>
|
||||
<% if @this_user.image %>
|
||||
<%= image_tag url_for_file_column(@this_user, "image") %>
|
||||
<%= image_tag url_for_file_column(@this_user, "image") %>
|
||||
<% if @user and @this_user.id == @user.id %>
|
||||
<%= button_to 'Delete Image', :action => 'delete_image' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<br />
|
||||
|
||||
|
@ -28,7 +31,7 @@
|
|||
Upload an image<br />
|
||||
<%= form_tag({:action=>'upload_image'}, :multipart => true)%>
|
||||
<%= file_column_field 'user', 'image' %>
|
||||
<input type="submit" name="Upload" />
|
||||
<%= submit_tag 'Add Image' %>
|
||||
</form>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect '/user/go_public', :controller => 'user', :action => 'go_public'
|
||||
map.connect '/user/reset-password', :controller => 'user', :action => 'reset_password'
|
||||
map.connect '/user/upload-image', :controller => 'user', :action => 'upload_image'
|
||||
map.connect '/user/delete-image', :controller => 'user', :action => 'delete_image'
|
||||
map.connect '/user/forgot-password', :controller => 'user', :action => 'lost_password'
|
||||
|
||||
map.connect '/index.html', :controller => 'site', :action => 'index'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue