Commit 50c2d5c8d970879d18d4a30f2301cb45639c6cc1
Exists in
master
and in
29 other branches
Merge branch 'AI3292_signup_image_upload' into 'master'
Ai3292 signup image upload Action Item: http://noosfero.org/Development/ActionItem3292 See merge request !318
Showing
3 changed files
with
28 additions
and
0 deletions
Show diff stats
app/controllers/public/account_controller.rb
@@ -97,6 +97,7 @@ class AccountController < ApplicationController | @@ -97,6 +97,7 @@ class AccountController < ApplicationController | ||
97 | @user.return_to = session[:return_to] | 97 | @user.return_to = session[:return_to] |
98 | @person = Person.new(params[:profile_data]) | 98 | @person = Person.new(params[:profile_data]) |
99 | @person.environment = @user.environment | 99 | @person.environment = @user.environment |
100 | + | ||
100 | if request.post? | 101 | if request.post? |
101 | if may_be_a_bot | 102 | if may_be_a_bot |
102 | set_signup_start_time_for_now | 103 | set_signup_start_time_for_now |
@@ -115,6 +116,14 @@ class AccountController < ApplicationController | @@ -115,6 +116,14 @@ class AccountController < ApplicationController | ||
115 | invitation.update_attributes!({:friend => @user.person}) | 116 | invitation.update_attributes!({:friend => @user.person}) |
116 | invitation.finish | 117 | invitation.finish |
117 | end | 118 | end |
119 | + | ||
120 | + unless params[:file].nil? | ||
121 | + image = Image::new :uploaded_data=> params[:file][:image] | ||
122 | + | ||
123 | + @user.person.image = image | ||
124 | + @user.person.save | ||
125 | + end | ||
126 | + | ||
118 | if @user.activated? | 127 | if @user.activated? |
119 | self.current_user = @user | 128 | self.current_user = @user |
120 | check_join_in_community(@user) | 129 | check_join_in_community(@user) |
app/views/profile_editor/_person_form.html.erb
@@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
25 | <%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %> | 25 | <%= optional_field(@person, 'address', labelled_form_field(_('Address (street and number)'), text_field(:profile_data, :address, :rel => _('Address')))) %> |
26 | <%= optional_field(@person, 'address_reference', labelled_form_field(_('Address reference'), text_field(:profile_data, :address_reference, :rel => _('Address reference')))) %> | 26 | <%= optional_field(@person, 'address_reference', labelled_form_field(_('Address reference'), text_field(:profile_data, :address_reference, :rel => _('Address reference')))) %> |
27 | <%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %> | 27 | <%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %> |
28 | +<%= optional_field(@person, 'image', labelled_form_field(_('Image'), file_field(:file, :image, :rel => _('Image')))) %> | ||
28 | 29 | ||
29 | <% optional_field(@person, 'schooling') do %> | 30 | <% optional_field(@person, 'schooling') do %> |
30 | <div class="formfieldline"> | 31 | <div class="formfieldline"> |
test/functional/account_controller_test.rb
@@ -637,6 +637,23 @@ class AccountControllerTest < ActionController::TestCase | @@ -637,6 +637,23 @@ class AccountControllerTest < ActionController::TestCase | ||
637 | assert_equal 'example.com', Person['testuser'].organization | 637 | assert_equal 'example.com', Person['testuser'].organization |
638 | end | 638 | end |
639 | 639 | ||
640 | + should "create a new user with image" do | ||
641 | + post :signup, :user => { | ||
642 | + :login => 'testuser', :password => '123456', :password_confirmation => '123456', :email => 'testuser@example.com' | ||
643 | + }, | ||
644 | + :profile_data => { | ||
645 | + :organization => 'example.com' | ||
646 | + }, | ||
647 | + :file => { | ||
648 | + :image => fixture_file_upload('/files/rails.png', 'image/png') | ||
649 | + } | ||
650 | + | ||
651 | + assert_response :successs | ||
652 | + | ||
653 | + person = Person["testuser"] | ||
654 | + assert_equal "rails.png", person.image.filename | ||
655 | + end | ||
656 | + | ||
640 | should 'activate user after signup if environment is set to skip confirmation' do | 657 | should 'activate user after signup if environment is set to skip confirmation' do |
641 | env = Environment.default | 658 | env = Environment.default |
642 | env.enable('skip_new_user_email_confirmation') | 659 | env.enable('skip_new_user_email_confirmation') |
@@ -965,6 +982,7 @@ class AccountControllerTest < ActionController::TestCase | @@ -965,6 +982,7 @@ class AccountControllerTest < ActionController::TestCase | ||
965 | end | 982 | end |
966 | 983 | ||
967 | protected | 984 | protected |
985 | + | ||
968 | def new_user(options = {}, extra_options ={}) | 986 | def new_user(options = {}, extra_options ={}) |
969 | data = {:profile_data => person_data} | 987 | data = {:profile_data => person_data} |
970 | if extra_options[:profile_data] | 988 | if extra_options[:profile_data] |