From bb0f88bc0bd65d32e3d8512d28381caf1b654038 Mon Sep 17 00:00:00 2001 From: Skud Date: Tue, 22 Jul 2014 14:26:22 +1000 Subject: [PATCH 1/9] Small amount of b3ification when merging dev into b3 branch --- app/views/crops/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 3c89648be..8db5a5d8c 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -31,7 +31,7 @@ %span.help-block You may enter up to 3 scientific names for a crop. Most crops will have only one. = f.fields_for :scientific_names do |sn| - .control-group + .form-group = sn.label :scientific_name, "Scientific name", :class => 'control-label' .controls = sn.text_field :scientific_name From a684efcf2a6d01247cdb10a9adb6b2bfc99dcea1 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 11 Aug 2014 13:02:08 +1000 Subject: [PATCH 2/9] b3ified some of the forms --- app/views/comments/_form.html.haml | 5 +-- app/views/comments/new.html.haml | 2 -- app/views/harvests/_form.html.haml | 49 ++++++++++++++++------------- app/views/plantings/_form.html.haml | 16 +++++----- app/views/posts/_form.html.haml | 22 +++++++------ app/views/seeds/_form.html.haml | 49 ++++++++++++++++------------- 6 files changed, 77 insertions(+), 66 deletions(-) diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml index bbb96d1a7..5d13ec6b5 100644 --- a/app/views/comments/_form.html.haml +++ b/app/views/comments/_form.html.haml @@ -1,4 +1,4 @@ -= form_for @comment do |f| += form_for(@comment, :html => {:class => "form-horizontal", :role => "form"}) do |f| - if @comment.errors.any? #error_explanation %h2= "#{pluralize(@comment.errors.count, "error")} prohibited this comment from being saved:" @@ -6,7 +6,8 @@ - @comment.errors.full_messages.each do |msg| %li= msg - .field + .form-group + = f.label :body, "Your comment:" = f.text_area :body, :rows => 6, :class => 'form-control' %span.help-block = render :partial => "shared/markdown_help" diff --git a/app/views/comments/new.html.haml b/app/views/comments/new.html.haml index c01ee755f..ca74fb99b 100644 --- a/app/views/comments/new.html.haml +++ b/app/views/comments/new.html.haml @@ -4,6 +4,4 @@ = render :partial => "posts/comments", :locals => {:post => @post || @comment.post} -%p Your comment: - = render 'form' diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml index f2a0b183c..3f712feb6 100644 --- a/app/views/harvests/_form.html.haml +++ b/app/views/harvests/_form.html.haml @@ -1,4 +1,4 @@ -= form_for(@harvest, :html => {:class => "form-horizontal"}) do |f| += form_for(@harvest, :html => {:class => "form-horizontal", :role => :form}) do |f| - if @harvest.errors.any? #error_explanation %h2= "#{pluralize(@harvest.errors.count, "error")} prohibited this harvest from being saved:" @@ -7,37 +7,42 @@ %li= msg .form-group - = f.label 'What did you harvest?', :class => 'control-label' - .controls - = collection_select(:harvest, :crop_id, Crop.all, :id, :name, :selected => @harvest.crop_id || @crop.id) - = collection_select(:harvest, :plant_part_id, PlantPart.all, :id, :name, :selected => @harvest.plant_part_id) - %span.help-block - Can't find what you're looking for? - = link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link + = f.label 'What did you harvest?', :class => 'control-label col-md-2' + .col-md-4 + = collection_select(:harvest, :crop_id, Crop.all, :id, :name, { :selected => @harvest.crop_id || @crop.id }, { :class => 'form-control' }) + .col-md-4 + = collection_select(:harvest, :plant_part_id, PlantPart.all, :id, :name, { :selected => @harvest.plant_part_id }, { :class => 'form-control' }) + %span.help-block.col-md-8 + Can't find what you're looking for? + = link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link .form-group - = f.label 'When?', :class => 'control-label' - .controls= f.text_field :harvested_at, :value => @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', :class => 'add-datepicker' + = f.label 'When?', :class => 'control-label col-md-2' + .col-md-2 + = f.text_field :harvested_at, :value => @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', :class => 'add-datepicker form-control' .form-group - = f.label 'How many?', :class => 'control-label' - .controls + = f.label 'How many?', :class => 'control-label col-md-2' + .col-md-2 -# Some browsers (eg Firefox for Android) assume "number" means -# "integer" unless you specify step="any": -# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/ - = f.number_field :quantity, :class => 'input-small', :step => 'any' - = f.select(:unit, Harvest::UNITS_VALUES, {:include_blank => false}, :class => 'input-medium') + = f.number_field :quantity, :class => 'input-small', :step => 'any', :class => 'form-control' + .col-md-2 + = f.select(:unit, Harvest::UNITS_VALUES, {:include_blank => false}, :class => 'input-medium form-control') .form-group - = f.label 'Weighing:', :class => 'control-label' - .controls - = f.number_field :weight_quantity, :class => 'input-small', :step => 'any' - = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, {:include_blank => false}, :class => 'input-medium') - in total + = f.label 'Weighing (in total):', :class => 'control-label col-md-2' + .col-md-2 + = f.number_field :weight_quantity, :class => 'input-small', :step => 'any', :class => 'form-control' + .col-md-2 + = f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, {:include_blank => false}, :class => 'form-control') .form-group - = f.label 'Notes', :class => 'control-label' - .controls= f.text_area :description, :rows => 6 + = f.label 'Notes', :class => 'control-label col-md-2' + .col-md-8 + = f.text_area :description, :rows => 6, :class => 'form-control' - .form-actions + .form-group + .form-actions.col-md-offset-2.col-md-8 = f.submit 'Save', :class => 'btn btn-primary' diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml index 2decb9d68..7d3f10a8f 100644 --- a/app/views/plantings/_form.html.haml +++ b/app/views/plantings/_form.html.haml @@ -8,35 +8,35 @@ .form-group = f.label 'What did you plant?', :class => 'control-label col-md-2' - .col-md-4 + .col-md-8 = collection_select(:planting, :crop_id, Crop.all, :id, :name, {:selected => @planting.crop_id || @crop.id}, {:class => 'form-control'}) %span.help-inline Can't find what you're looking for? = link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link .form-group = f.label 'Where did you plant it?', :class => 'control-label col-md-2' - .col-md-4 + .col-md-8 = collection_select(:planting, :garden_id, Garden.active.where(:owner_id => current_member), :id, :name, {:selected => @planting.garden_id || @garden.id}, {:class => 'form-control'}) %span.help-inline = link_to "Add a garden.", new_garden_path .form-group = f.label 'When?', :class => 'control-label col-md-2' - .col-md-3= f.text_field :planted_at, :value => @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', :class => 'add-datepicker form-control' + .col-md-2= f.text_field :planted_at, :value => @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', :class => 'add-datepicker form-control' .form-group = f.label 'How many?', :class => 'control-label col-md-2' .col-md-2 = f.number_field :quantity, :class => 'form-control' .form-group = f.label 'Planted from:', :class => 'control-label col-md-2' - .col-md-4 + .col-md-8 = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, {:include_blank => true}, :class => 'form-control') .form-group = f.label 'Sun or shade?', :class => 'control-label col-md-2' - .col-md-4 + .col-md-8 = f.select(:sunniness, Planting::SUNNINESS_VALUES, {:include_blank => true}, :class => 'form-control') .form-group = f.label 'Tell us more about it', :class => 'control-label col-md-2' - .col-md-4= f.text_area :description, :rows => 6, :class => 'form-control' + .col-md-8= f.text_area :description, :rows => 6, :class => 'form-control' .form-group - .form-actions - = f.submit 'Save', :class => 'btn btn-primary col-md-offset-2' + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', :class => 'btn btn-primary' diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index d08a577a5..3ae4e5172 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -1,4 +1,4 @@ -= form_for @post do |f| += form_for(@post, :html => {:role => "form"}) do |f| - if @post.errors.any? #error_explanation %h2= "#{pluralize(@post.errors.count, "error")} prohibited this post from being saved:" @@ -6,16 +6,18 @@ - @post.errors.full_messages.each do |msg| %li= msg + .form-group + = label_tag :post, "Subject", :class => 'control-label' + = f.text_field :subject, :class => 'form-control' - = label_tag :post, "Subject" - = f.text_field :subject, :class => 'form-control' - - if @post.forum || @forum - = label_tag :body, "What's up?" - - else - = label_tag :body, "What's going on in your food garden?" - = f.text_area :body, :rows => 12, :class => 'form-control' - %span.help-block - = render :partial => "shared/markdown_help" + .form-group + - if @post.forum || @forum + = label_tag :body, "What's up?", :class => 'control-label' + - else + = label_tag :body, "What's going on in your food garden?" + = f.text_area :body, :rows => 12, :class => 'form-control' + %span.help-block + = render :partial => "shared/markdown_help" - if @post.forum || @forum - forum = @post.forum || @forum diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml index 5e9270800..1b327cdcc 100644 --- a/app/views/seeds/_form.html.haml +++ b/app/views/seeds/_form.html.haml @@ -1,4 +1,4 @@ -= form_for(@seed, :html => {:class => "form-horizontal"}) do |f| += form_for(@seed, :html => {:class => "form-horizontal", :role => "form"}) do |f| - if @seed.errors.any? #error_explanation %h2= "#{pluralize(@seed.errors.count, "error")} prohibited this seed from being saved:" @@ -7,23 +7,33 @@ %li= msg .form-group - = f.label 'Crop:', :class => 'control-label' - .controls= collection_select(:seed, :crop_id, Crop.all, :id, :name, :selected => @seed.crop_id || @crop.id) + = f.label 'Crop:', :class => 'control-label col-md-2' + .col-md-8 + = collection_select(:seed, :crop_id, Crop.all, :id, :name, { :selected => @seed.crop_id || @crop.id }, { :class => 'form-control' }) .form-group - = f.label 'Quantity:', :class => 'control-label' - .controls - = f.number_field :quantity, :class => 'input-small' + = f.label 'Quantity:', :class => 'control-label col-md-2' + .col-md-2 + = f.number_field :quantity, :class => 'form-control' .form-group - = f.label 'Plant before:', :class => 'control-label' - .controls= f.text_field :plant_before, :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '', :class => 'add-datepicker' + = f.label 'Plant before:', :class => 'control-label col-md-2' + .col-md-2 + = f.text_field :plant_before, :class => 'add-datepicker form-control', :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : '' .form-group - = f.label 'Description:', :class => 'control-label' - .controls= f.text_area :description, :rows => 6 + = f.label 'Description:', :class => 'control-label col-md-2' + .col-md-8 + = f.text_area :description, :rows => 6, :class => 'form-control' .form-group - = f.label 'Will trade:', :class => 'control-label' - .controls - = f.select(:tradable_to, - options_for_select(Seed::TRADABLE_TO_VALUES, :selected => @seed.tradable_to || 'nowhere')) + .col-md-offset-2.col-md-8 + %span.help-block + Are you interested in trading or swapping seeds with other + #{ENV['GROWSTUFF_SITE_NAME']} members? If you + list your seeds as available for trade, other members can + contact you to request seeds. You can list any conditions or + other information in the description, above. + .form-group + = f.label 'Will trade:', :class => 'control-label col-md-2' + .col-md-8 + = f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, :class => 'form-control') %span.help_inline - if current_member.location.blank? Don't forget to @@ -34,11 +44,6 @@ =succeed "." do = link_to current_member.location, place_path(current_member.location) =link_to "Change your location.", edit_member_registration_path - %span.help-block - Are you interested in trading or swapping seeds with other - #{ENV['GROWSTUFF_SITE_NAME']} members? If you - list your seeds as available for trade, other members can - contact you to request seeds. You can list any conditions or - other information in the description, above. - .form-actions - = f.submit 'Save', :class => 'btn btn-primary' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', :class => 'btn btn-primary' From 561b7c45ac01f5cbee0d84f5309ff0ae8b06393e Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 11 Aug 2014 14:42:00 +1000 Subject: [PATCH 3/9] b3ify and improve design of edit profile page --- Gemfile | 2 +- Gemfile.lock | 14 +-- app/controllers/registrations_controller.rb | 27 ++-- .../devise/registrations/_edit_apps.html.haml | 26 ++++ .../registrations/_edit_email.html.haml | 31 +++++ .../registrations/_edit_password.html.haml | 22 ++++ .../registrations/_edit_profile.html.haml | 30 +++++ app/views/devise/registrations/edit.html.haml | 117 ++++-------------- config/initializers/devise.rb | 2 + spec/views/devise/registrations/edit_spec.rb | 17 --- 10 files changed, 160 insertions(+), 128 deletions(-) create mode 100644 app/views/devise/registrations/_edit_apps.html.haml create mode 100644 app/views/devise/registrations/_edit_email.html.haml create mode 100644 app/views/devise/registrations/_edit_password.html.haml create mode 100644 app/views/devise/registrations/_edit_profile.html.haml diff --git a/Gemfile b/Gemfile index 3c41ee688..20fd19aab 100644 --- a/Gemfile +++ b/Gemfile @@ -93,7 +93,7 @@ gem 'bluecloth' gem 'will_paginate', '~> 3.0' # user signup/login/etc -gem 'devise', '~> 3.0.0' +gem 'devise', '~> 3.2.0' # nicely formatted URLs gem 'friendly_id', '~> 4.0.10' diff --git a/Gemfile.lock b/Gemfile.lock index 2921a230f..5fa52738a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,8 +50,6 @@ GEM addressable (2.3.6) arel (3.0.3) bcrypt (3.1.7) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) better_errors (1.1.0) coderay (>= 1.0.0) erubis (>= 2.6.6) @@ -95,10 +93,11 @@ GEM debugger-ruby_core_source (~> 1.3.2) debugger-linecache (1.2.0) debugger-ruby_core_source (1.3.2) - devise (3.0.4) - bcrypt-ruby (~> 3.0) + devise (3.2.4) + bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) + thread_safe (~> 0.1) warden (~> 1.2.3) diff-lcs (1.1.3) docile (1.1.3) @@ -162,7 +161,7 @@ GEM memcachier (0.0.2) mime-types (1.25.1) mini_portile (0.5.3) - multi_json (1.9.3) + multi_json (1.10.1) multi_xml (0.5.5) newrelic_rpm (3.8.0.218) nokogiri (1.6.1) @@ -210,7 +209,7 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) raindrops (0.13.0) - rake (10.3.1) + rake (10.3.2) rdoc (3.12.2) json (~> 1.4) ref (1.0.5) @@ -248,6 +247,7 @@ GEM libv8 (~> 3.16.14.0) ref thor (0.19.1) + thread_safe (0.3.3) tilt (1.4.1) tins (1.1.0) treetop (1.4.15) @@ -287,7 +287,7 @@ DEPENDENCIES csv_shaper dalli debugger - devise (~> 3.0.0) + devise (~> 3.2.0) factory_girl_rails (~> 4.0) figaro flickraw diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 815457201..cbb300496 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -10,26 +10,37 @@ class RegistrationsController < Devise::RegistrationsController # we need this subclassed method so that Devise doesn't force people to # change their password every time they want to edit their settings. +# we also check that they give their current password to chang their password. # Code copied from # https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password def update - # required for settings form to submit when password is left blank - if params[:member][:password].blank? - params[:member].delete("password") - params[:member].delete("password_confirmation") - params[:member].delete("current_password") - end @member = Member.find(current_member.id) - if @member.update_attributes(params[:member]) + successfully_updated = if needs_password?(@member, params) + @member.update_with_password(devise_parameter_sanitizer.sanitize(:account_update)) + else + # remove the virtual current_password attribute + # update_without_password doesn't know how to ignore it + params[:member].delete(:current_password) + @member.update_without_password(devise_parameter_sanitizer.sanitize(:account_update)) + end + + if successfully_updated set_flash_message :notice, :updated - # Sign in the member bypassing validation in case his password changed + # Sign in the member bypassing validation in case their password changed sign_in @member, :bypass => true redirect_to edit_member_registration_path else render "edit" end + end end + +# check if we need the current password to update fields +def needs_password?(member, params) + params[:member][:password].present? || + params[:member][:password_confirmation].present? +end diff --git a/app/views/devise/registrations/_edit_apps.html.haml b/app/views/devise/registrations/_edit_apps.html.haml new file mode 100644 index 000000000..df5d17c88 --- /dev/null +++ b/app/views/devise/registrations/_edit_apps.html.haml @@ -0,0 +1,26 @@ += form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| + = devise_error_messages! + + .row + .col-md-12 + %p + = image_tag "twitter_32.png", :size => "32x32", :alt => 'Twitter logo' + - if @twitter_auth + You are connected to Twitter as + = succeed "." do + =link_to @twitter_auth.name, "http://twitter.com/#{@twitter_auth.name}" + = link_to "Disconnect", @twitter_auth, :confirm => "Are you sure you want to remove this connection?", :method => :delete, :class => "remove" + - else + =link_to 'Connect to Twitter', '/auth/twitter' + + .row + .col-md-12 + %p + = image_tag "flickr_32.png", :size => "32x32", :alt => 'Flickr logo' + - if @flickr_auth + You are connected to Flickr as + = succeed "." do + =link_to @flickr_auth.name, "http://flickr.com/photos/#{@flickr_auth.uid}" + = link_to "Disconnect", @flickr_auth, :confirm => "Are you sure you want to remove this connection?", :method => :delete, :class => "remove" + - else + =link_to 'Connect to Flickr', '/auth/flickr' diff --git a/app/views/devise/registrations/_edit_email.html.haml b/app/views/devise/registrations/_edit_email.html.haml new file mode 100644 index 000000000..61df13f91 --- /dev/null +++ b/app/views/devise/registrations/_edit_email.html.haml @@ -0,0 +1,31 @@ += form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| + = devise_error_messages! + + .form-group + = f.label :email, :class => 'control-label col-md-2' + .col-md-8 + = f.email_field :email, :class => 'form-control' + %span.help-block If you change your email address you will have to reconfirm. + + .form-group + .col-md-offset-2.col-md-8 + = f.check_box :show_email + Show email publicly on your profile page + + .form-group + .col-md-offset-2.col-md-8 + = f.check_box :send_notification_email + Receive emailed copies of Inbox notifications. + + .form-group + .col-md-offset-2.col-md-8 + = f.check_box :newsletter + Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter + .help-block + = render :partial => 'newsletter_blurb' + + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit "Save", :class => 'btn btn-primary' + + =f.hidden_field(:tos_agreement, :value => true) diff --git a/app/views/devise/registrations/_edit_password.html.haml b/app/views/devise/registrations/_edit_password.html.haml new file mode 100644 index 000000000..c70edc96f --- /dev/null +++ b/app/views/devise/registrations/_edit_password.html.haml @@ -0,0 +1,22 @@ += form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| + = devise_error_messages! + + .form-group + = f.label :current_password, :class => 'control-label col-md-2' + .col-md-4 + = f.password_field :current_password, :class => 'form-control' + + .form-group + = f.label :password, "New password", :class => 'control-label col-md-2' + .col-md-4 + = f.password_field :password, :autocomplete => "off", :class => 'form-control' + + .form-group + = f.label :password_confirmation, :class => 'control-label col-md-2' + .col-md-4= f.password_field :password_confirmation, :class => 'form-control' + + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit "Save", :class => 'btn btn-primary' + + =f.hidden_field(:tos_agreement, :value => true) diff --git a/app/views/devise/registrations/_edit_profile.html.haml b/app/views/devise/registrations/_edit_profile.html.haml new file mode 100644 index 000000000..fe33c6fdf --- /dev/null +++ b/app/views/devise/registrations/_edit_profile.html.haml @@ -0,0 +1,30 @@ += form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| + = devise_error_messages! + + .form-group + =f.label :location, 'Your location', :class => 'control-label col-md-2' + .col-md-8 + =f.text_field :location, :autocomplete => "off", :class => 'form-control' + %span.help-block This will be displayed on a map. You can be as detailed or vague as you like. + + .form-group + =f.label :bio, :class => 'control-label col-md-2' + .col-md-8 + =f.text_area :bio, :rows => 6, :class => 'form-control' + + .form-group + %label.control-label.col-md-2 + Profile picture + .col-md-8 + = render :partial => "members/avatar", :locals => { :member => @member } + %p + %br/ + To change your profile picture, visit + = succeed "." do + = link_to 'gravatar.com', "http://gravatar.com/" + + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit "Save", :class => 'btn btn-primary' + + =f.hidden_field(:tos_agreement, :value => true) diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index cb77568f4..85ba205d9 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -1,98 +1,25 @@ - content_for :title, "Settings for #{current_member.login_name}" -= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-horizontal' }) do |f| - = devise_error_messages! +%ul.nav.nav-tabs{:role => 'tablist'} + %li.active + %a{:href => '#profile', :role => 'tab', 'data-toggle' => 'tab'} + Profile + %li + %a{:href => '#email', :role => 'tab', 'data-toggle' => 'tab'} + Email + %li + %a{:href => '#apps', :role => 'tab', 'data-toggle' => 'tab'} + Apps + %li + %a{:href => '#password', :role => 'tab', 'data-toggle' => 'tab'} + Password - %h2 Email settings - - .form-group - = f.label :email, :class => 'control-label' - .controls - = f.email_field :email - %span.help-inline If you change your email address you will have to reconfirm. - - .form-group - .controls - = f.check_box :show_email - Show email publicly on your profile page - - .form-group - .controls - = f.check_box :send_notification_email - Receive emailed copies of Inbox notifications. - - .form-group - .controls - = f.check_box :newsletter - Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter - .help-inline - = render :partial => 'newsletter_blurb' - - %h2 Profile details - .form-group - %label.control-label - Profile picture - .controls - = render :partial => "members/avatar", :locals => { :member => @member } - %p - %br/ - To change your profile picture, visit - = succeed "." do - = link_to 'gravatar.com', "http://gravatar.com/" - - .form-group - =f.label :location, 'Your location', :class => 'control-label' - .controls - =f.text_field :location, :autocomplete => "off" - %span.help-inline This will be displayed on a map. You can be as detailed or vague as you like. - - .form-group - =f.label :bio, :class => 'control-label' - .controls - =f.text_area :bio, :rows => 6, :class => 'form-control' - - %h2 Linked accounts - - .form-group - .controls - %p - = image_tag "twitter_32.png", :size => "32x32", :alt => 'Twitter logo' - - if @twitter_auth - You are connected to Twitter as - = succeed "." do - =link_to @twitter_auth.name, "http://twitter.com/#{@twitter_auth.name}" - = link_to "Disconnect", @twitter_auth, :confirm => "Are you sure you want to remove this connection?", :method => :delete, :class => "remove" - - else - =link_to 'Connect to Twitter', '/auth/twitter' - %p - = image_tag "flickr_32.png", :size => "32x32", :alt => 'Flickr logo' - - if @flickr_auth - You are connected to Flickr as - = succeed "." do - =link_to @flickr_auth.name, "http://flickr.com/photos/#{@flickr_auth.uid}" - = link_to "Disconnect", @flickr_auth, :confirm => "Are you sure you want to remove this connection?", :method => :delete, :class => "remove" - - else - =link_to 'Connect to Flickr', '/auth/flickr' - - %h2 Change password - %p - %span.help-block Leave blank if you don't want to change your password. - - .form-group - = f.label :current_password, :class => 'control-label' - .controls - = f.password_field :current_password - - .form-group - = f.label :password, "New password", :class => 'control-label' - .controls - = f.password_field :password, :autocomplete => "off" - - .form-group - = f.label :password_confirmation, :class => 'control-label' - .controls= f.password_field :password_confirmation - - .form-actions - = f.submit "Save", :class => 'btn btn-primary' - - =f.hidden_field(:tos_agreement, :value => true) +.tab-content + .tab-pane.active#profile + = render :partial => 'edit_profile' + .tab-pane#email + = render :partial => 'edit_email' + .tab-pane#apps + = render :partial => 'edit_apps' + .tab-pane#password + = render :partial => 'edit_password' diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 0e332098c..eb51fab96 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -6,6 +6,8 @@ Devise.setup do |config| # note that it will be overwritten if you use your own mailer class with default "from" parameter. config.mailer_sender = "Growstuff " + config.secret_key = ENV['RAILS_SECRET_TOKEN'] + # Configure the class responsible to send e-mails. # config.mailer = "Devise::Mailer" diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index cfd18c6de..f9c48ec1a 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -23,10 +23,6 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do render end - it 'has a heading' do - assert_select "h2", "Email settings" - end - it 'has a checkbox for email notifications' do assert_select "input[id=member_send_notification_email][type=checkbox]" end @@ -41,10 +37,6 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do render end - it 'has a heading' do - assert_select "h2", "Profile details" - end - it 'shows show_email checkbox' do assert_select "input[id=member_show_email][type=checkbox]" end @@ -67,10 +59,6 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do end context 'other sites section' do - it 'has a heading' do - render - assert_select "h2", "Linked accounts" - end context 'not connected to twitter' do it 'has a link to connect' do @@ -114,11 +102,6 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do end - it 'should have a password section' do - render - assert_select "h2", "Change password" - end - end end From f02f2ae77ee974b82fcbcce334b5a51728a1ff9c Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 11 Aug 2014 14:49:05 +1000 Subject: [PATCH 4/9] b3ify the signup/signin pages --- app/views/devise/registrations/new.html.haml | 31 +++++++++++--------- app/views/devise/sessions/new.html.haml | 22 ++++++++------ 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index e9eb59bd5..268fc3e45 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -6,39 +6,42 @@ = devise_error_messages! .form-group - = f.label :login_name, :class => "control-label" - .controls - = f.text_field :login_name + = f.label :login_name, :class => "control-label col-md-2" + .col-md-8 + = f.text_field :login_name, :class => 'form-control' %span.help-inline This is the name that will show on the website. .form-group - = f.label :email, :class => "control-label" - .controls - = f.email_field :email + = f.label :email, :class => "control-label col-md-2" + .col-md-8 + = f.email_field :email, :class => 'form-control' %span.help-inline We'll use this address to contact you (we never spam!) .form-group - = f.label :password, :class => "control-label" - .controls= f.password_field :password + = f.label :password, :class => "control-label col-md-2" + .col-md-8= f.password_field :password, :class => 'form-control' .form-group - = f.label :password_confirmation, :class => "control-label" - .controls= f.password_field :password_confirmation + = f.label :password_confirmation, :class => "control-label col-md-2" + .col-md-8= f.password_field :password_confirmation, :class => 'form-control' .form-group - .controls + .col-md-offset-2.col-md-8 = f.check_box :tos_agreement I agree to the = succeed "." do = link_to 'Terms of Service', url_for(:action => 'tos', :controller => '/policy') .form-group - .controls + .col-md-offset-2.col-md-8 = f.check_box :newsletter, :checked => true Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter .help-inline = render :partial => 'newsletter_blurb' - .form-actions + .form-group + .form-actions.col-md-offset-2.col-md-8 = f.submit "Sign up", :class => 'btn btn-primary' -= render "devise/shared/links" + .form-group + .col-md-offset-2.col-md-8 + = render "devise/shared/links" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index bb3b0b8ff..51d7b6845 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -4,21 +4,25 @@ = devise_error_messages! .form-group - = f.label :login, :class => "control-label" - .controls= f.text_field :login + = f.label :login, :class => "control-label col-md-2" + .col-md-8 + = f.text_field :login, :class => 'form-control' .form-group - = f.label :password, :class => "control-label" - .controls= f.password_field :password + = f.label :password, :class => "control-label col-md-2" + .col-md-8 + = f.password_field :password, :class => 'form-control' - if devise_mapping.rememberable? .form-group - .controls + .col-md-8.col-md-offset-2 = f.check_box :remember_me Remember me - .form-actions - = f.submit "Sign in", :class => 'btn btn-primary' + .form-group + .form-actions.col-md-8.col-md-offset-2 + = f.submit "Sign in", :class => 'btn btn-primary' - -= render "devise/shared/links" + .form-group + .col-md-8.col-md-offset-2 + = render "devise/shared/links" From 86699073199d09105ed3e2f9b50c97e675200011 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 11 Aug 2014 14:55:43 +1000 Subject: [PATCH 5/9] add secret key to travis config (needed for devise update) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7746d903e..4b0fc1c55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- language: ruby -env: GROWSTUFF_SITE_NAME="Growstuff (travis)" +env: GROWSTUFF_SITE_NAME="Growstuff (travis)" RAILS_SECRET_KEY='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' bundler_args: --without development assets production staging rvm: - 2.1.1 From 25d19a25d3a4a36b07574f5188e1e83eb0edceaa Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 11 Aug 2014 15:00:46 +1000 Subject: [PATCH 6/9] err, make that secret token --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4b0fc1c55..825f9e960 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- language: ruby -env: GROWSTUFF_SITE_NAME="Growstuff (travis)" RAILS_SECRET_KEY='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' +env: GROWSTUFF_SITE_NAME="Growstuff (travis)" RAILS_SECRET_TOKEN='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' bundler_args: --without development assets production staging rvm: - 2.1.1 From 793eecfcb7539e584a2161746abd1cdbdb2e9e39 Mon Sep 17 00:00:00 2001 From: Skud Date: Fri, 22 Aug 2014 10:25:40 +1000 Subject: [PATCH 7/9] Fixed typo --- app/controllers/registrations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index cbb300496..50eccef0c 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -10,7 +10,7 @@ class RegistrationsController < Devise::RegistrationsController # we need this subclassed method so that Devise doesn't force people to # change their password every time they want to edit their settings. -# we also check that they give their current password to chang their password. +# we also check that they give their current password to change their password. # Code copied from # https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password From 501fda3fc9ae5d66e23143ce74fb8ba4bd97e55e Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 27 Aug 2014 19:02:06 +1000 Subject: [PATCH 8/9] b3ified a few of the lesser-used forms --- app/views/crops/_form.html.haml | 38 ++++++++++---------- app/views/forums/_form.html.haml | 22 +++++++----- app/views/gardens/_form.html.haml | 42 +++++++++++----------- app/views/scientific_names/_form.html.haml | 19 +++++----- 4 files changed, 64 insertions(+), 57 deletions(-) diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 8db5a5d8c..0c8fc8c45 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -1,4 +1,4 @@ -= form_for @crop, :html => {:class => 'form-horizontal'} do |f| += form_for @crop, :html => {:class => 'form-horizontal', :role => "form"} do |f| - if @crop.errors.any? #error_explanation %h3= "#{pluralize(@crop.errors.count, "error")} prohibited this crop from being saved:" @@ -13,31 +13,33 @@ on the Growstuff wiki. .form-group - = f.label :name, :class => 'control-label' - .controls - = f.text_field :name - %span.help-inline Name in US English; singular; capitalize proper nouns only. + = f.label :name, :class => 'control-label col-md-2' + .col-md-8 + = f.text_field :name, :class => 'form-control' + %span.help-block Name in US English; singular; capitalize proper nouns only. .form-group - = f.label :en_wikipedia_url, 'Wikipedia URL', :class => 'control-label' - .controls - = f.text_field :en_wikipedia_url - %span.help-inline Link to this crop's page on the English language Wikipedia. + = f.label :en_wikipedia_url, 'Wikipedia URL', :class => 'control-label col-md-2' + .col-md-8 + = f.text_field :en_wikipedia_url, :class => 'form-control' + %span.help-block Link to this crop's page on the English language Wikipedia. .form-group - = f.label :parent_id, 'Parent crop', :class => 'control-label' - .controls - = collection_select(:crop, :parent_id, Crop.all, :id, :name, {:include_blank => true}) - %span.help-inline Optional. For setting up crop hierarchies for varieties etc. + = f.label :parent_id, 'Parent crop', :class => 'control-label col-md-2' + .col-md-8 + = collection_select(:crop, :parent_id, Crop.all, :id, :name, {:include_blank => true}, :class => 'form-control') + %span.help-block Optional. For setting up crop hierarchies for varieties etc. %p %span.help-block You may enter up to 3 scientific names for a crop. Most crops will have only one. = f.fields_for :scientific_names do |sn| .form-group - = sn.label :scientific_name, "Scientific name", :class => 'control-label' - .controls - = sn.text_field :scientific_name + = sn.label :scientific_name, "Scientific name", :class => 'control-label col-md-2' + .col-md-8 + = sn.text_field :scientific_name, :class => 'form-control' + .col-md-2 - if sn.object && sn.object.persisted? %label.checkbox = sn.check_box :_destroy = sn.label :_destroy, "Delete" - .form-actions - = f.submit 'Save', :class => 'btn btn-primary' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', :class => 'btn btn-primary' diff --git a/app/views/forums/_form.html.haml b/app/views/forums/_form.html.haml index 503481187..8168f30cd 100644 --- a/app/views/forums/_form.html.haml +++ b/app/views/forums/_form.html.haml @@ -1,4 +1,4 @@ -= form_for @forum, :html => { :class => 'form-horizontal' } do |f| += form_for @forum, :html => { :class => 'form-horizontal', :role => "form" } do |f| - if @forum.errors.any? #error_explanation %h2= "#{pluralize(@forum.errors.count, "error")} prohibited this forum from being saved:" @@ -7,13 +7,17 @@ %li= msg .form-group - = f.label :name, :class => 'control-label' - .controls= f.text_field :name, :class => 'form-control' + = f.label :name, :class => 'control-label col-md-2' + .col-md-8 + = f.text_field :name, :class => 'form-control' .form-group - = f.label :description, :class => 'control-label' - .controls= f.text_area :description, :rows => 6, :class => 'form-control' + = f.label :description, :class => 'control-label col-md-2' + .col-md-8 + = f.text_area :description, :rows => 6, :class => 'form-control' .form-group - = f.label :owner_id, :class => 'control-label' - .controls= collection_select(:forum, :owner_id, Member.all, :id, :login_name) - .form-actions - = f.submit 'Save', :class => 'btn btn-primary' + = f.label :owner_id, :class => 'control-label col-md-2' + .col-md-8 + = collection_select(:forum, :owner_id, Member.all, :id, :login_name, {}, :class => 'form-control') + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', :class => 'btn btn-primary' diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml index 7a1c5e59e..6313762c4 100644 --- a/app/views/gardens/_form.html.haml +++ b/app/views/gardens/_form.html.haml @@ -1,4 +1,4 @@ -= form_for(@garden, :html => {:class => "form-horizontal"}) do |f| += form_for(@garden, :html => {:class => "form-horizontal", :role => "form"}) do |f| - if @garden.errors.any? #error_explanation %h2= "#{pluralize(@garden.errors.count, "error")} prohibited this garden from being saved:" @@ -7,19 +7,19 @@ %li= msg .form-group - = f.label :name, :class => 'control-label' - .controls - = f.text_field :name + = f.label :name, :class => 'control-label col-md-2' + .col-md-8 + = f.text_field :name, :class => 'form-control' .form-group - = f.label :description, :class => 'control-label' - .controls - = f.text_area :description, :rows => 6 + = f.label :description, :class => 'control-label col-md-2' + .col-md-8 + = f.text_area :description, :rows => 6, :class => 'form-control' .form-group - = f.label :location, :class => 'control-label' - .controls - = f.text_field :location, :value => @garden.location || current_member.location + = f.label :location, :class => 'control-label col-md-2' + .col-md-8 + = f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control' %span.help-block If you have a location set in your profile, it will be used when you create a new garden. @@ -29,18 +29,18 @@ =link_to "Change your location.", edit_member_registration_path .form-group - = f.label :area, :class => 'control-label' - .controls - = f.number_field :area, :class => 'input-small' - = f.select(:area_unit, Garden::AREA_UNITS_VALUES, {:include_blank => false}, :class => 'input-medium') + = f.label :area, :class => 'control-label col-md-2' + .col-md-2 + = f.number_field :area, :class => 'input-small form-control' + .col-md-2 + = f.select(:area_unit, Garden::AREA_UNITS_VALUES, {:include_blank => false}, :class => 'form-control') .form-group - = f.label 'Active? ', :class => 'control-label' - .controls + = f.label 'Active? ', :class => 'control-label col-md-2' + .col-md-8 = f.check_box :active - %span.help-inline - You can mark a garden as inactive if you no longer use it. + You can mark a garden as inactive if you no longer use it. - - .form-actions - = f.submit 'Save Garden', :class => 'btn btn-primary' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save Garden', :class => 'btn btn-primary' diff --git a/app/views/scientific_names/_form.html.haml b/app/views/scientific_names/_form.html.haml index 2ee348e4a..e8d08978a 100644 --- a/app/views/scientific_names/_form.html.haml +++ b/app/views/scientific_names/_form.html.haml @@ -1,4 +1,4 @@ -= form_for @scientific_name, :html => {:class => 'form-horizontal'} do |f| += form_for @scientific_name, :html => {:class => 'form-horizontal', :role => "form"} do |f| - if @scientific_name.errors.any? #error_explanation %h2= "#{pluralize(@scientific_name.errors.count, "error")} prohibited this scientific_name from being saved:" @@ -13,12 +13,13 @@ on the Growstuff wiki. .form-group - = f.label :crop_id, :class => 'control-label' - .controls - = collection_select(:scientific_name, :crop_id, Crop.all, :id, :name, :selected => @scientific_name.crop_id || @crop.id) + = f.label :crop_id, :class => 'control-label col-md-2' + .col-md-8 + = collection_select(:scientific_name, :crop_id, Crop.all, :id, :name, { :selected => @scientific_name.crop_id || @crop.id }, :class => 'form-control') .form-group - = f.label :scientific_name, :class => 'control-label' - .controls - = f.text_field :scientific_name - .form-actions - = f.submit 'Save', :class => 'btn btn-primary' + = f.label :scientific_name, :class => 'control-label col-md-2' + .col-md-8 + = f.text_field :scientific_name, :class => 'form-control' + .form-group + .form-actions.col-md-offset-2.col-md-8 + = f.submit 'Save', :class => 'btn btn-primary' From e5b15fae1aa4f5c17c0171b296e4d9165503da64 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 27 Aug 2014 19:02:49 +1000 Subject: [PATCH 9/9] got rid of ugly scaffolding 'back' links --- app/views/forums/edit.html.haml | 4 ---- app/views/forums/new.html.haml | 2 -- app/views/gardens/new.html.haml | 2 -- 3 files changed, 8 deletions(-) diff --git a/app/views/forums/edit.html.haml b/app/views/forums/edit.html.haml index f334a2092..c23c87878 100644 --- a/app/views/forums/edit.html.haml +++ b/app/views/forums/edit.html.haml @@ -1,7 +1,3 @@ - content_for :title, "Editing forum" = render 'form' - -= link_to 'Show', @forum -\| -= link_to 'Back', forums_path diff --git a/app/views/forums/new.html.haml b/app/views/forums/new.html.haml index 59e6ef782..b570c218f 100644 --- a/app/views/forums/new.html.haml +++ b/app/views/forums/new.html.haml @@ -1,5 +1,3 @@ - content_for :title, "New Forum" = render 'form' - -= link_to 'Back', forums_path diff --git a/app/views/gardens/new.html.haml b/app/views/gardens/new.html.haml index 7d7b7ce19..3e7ee5f67 100644 --- a/app/views/gardens/new.html.haml +++ b/app/views/gardens/new.html.haml @@ -1,5 +1,3 @@ %h1 New garden = render 'form' - -= link_to 'Back', gardens_path