diff options
author | Francis Irving <francis@mysociety.org> | 2010-07-15 16:09:39 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-07-15 16:09:39 +0100 |
commit | e9a1132bb4d860fa92a6a1eb13dd291f5acdb978 (patch) | |
tree | 7cf70cccff33577bbbd2775f145308596415f6b0 | |
parent | 160645b6f067ff0a8bb43118aafe5bd0a4370a91 (diff) |
Make profile photo upload work without javascript (for Matthew :)
-rw-r--r-- | app/controllers/user_controller.rb | 10 | ||||
-rw-r--r-- | app/views/user/set_draft_profile_photo.rhtml | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index e2998333c..85d09abc7 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -372,6 +372,16 @@ class UserController < ApplicationController end @draft_profile_photo.save + if params[:automatically_crop] + # no javascript, crop automatically + @profile_photo = ProfilePhoto.new(:data => @draft_profile_photo.data, :draft => false) + @user.set_profile_photo(@profile_photo) + @draft_profile_photo.destroy + flash[:notice] = "Thank you for updating your profile photo" + redirect_to user_url(@user) + return + end + render :template => 'user/set_crop_profile_photo.rhtml' return elsif !params[:submitted_crop_profile_photo].nil? diff --git a/app/views/user/set_draft_profile_photo.rhtml b/app/views/user/set_draft_profile_photo.rhtml index 2fffd519f..03ebb05d3 100644 --- a/app/views/user/set_draft_profile_photo.rhtml +++ b/app/views/user/set_draft_profile_photo.rhtml @@ -19,7 +19,14 @@ <p> <%= hidden_field_tag 'submitted_draft_profile_photo', 1 %> - <%= submit_tag "Next, crop your photo >>" %> + + <script type="text/javascript" charset="utf-8"> + document.write('<%= submit_tag "Next, crop your photo >>" %>'); + </script> + <noscript> + <%= hidden_field_tag 'automatically_crop', 1 %> + <%= submit_tag "Done >>" %> + </noscript> </p> <% end %> |