From 2db7bf638bc30b624ede83d1e6a55895cdbe3111 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Mon, 9 Feb 2015 20:41:28 +1100 Subject: [PATCH 01/10] improve copy for new request email --- app/controllers/crops_controller.rb | 2 +- app/mailers/notifier.rb | 2 +- app/views/notifier/new_crop_request.html.haml | 23 ++++++++++++++++--- db/schema.rb | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 19f55d7ef..2c64f5cc8 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -123,7 +123,7 @@ class CropsController < ApplicationController respond_to do |format| if @crop.save - if current_member.has_role? :crop_wrangler + unless current_member.has_role? :crop_wrangler Role.crop_wranglers.each do |w| Notifier.new_crop_request(w, @crop).deliver! end diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb index 88c5f50f5..53bae3092 100644 --- a/app/mailers/notifier.rb +++ b/app/mailers/notifier.rb @@ -24,7 +24,7 @@ class Notifier < ActionMailer::Base def new_crop_request(member, request) @member, @request = member, request - mail(:to => @member.email, :subject => "New crop request") + mail(:to => @member.email, :subject => "#{@request.requester.login_name} has requested #{@request.name} as a new crop") end def crop_request_approved(member, crop) diff --git a/app/views/notifier/new_crop_request.html.haml b/app/views/notifier/new_crop_request.html.haml index 2fc16df7d..26b63f8ff 100644 --- a/app/views/notifier/new_crop_request.html.haml +++ b/app/views/notifier/new_crop_request.html.haml @@ -1,7 +1,24 @@ - site_name = ENV['GROWSTUFF_SITE_NAME'] + %p Hello #{@member.login_name}, -%p - A new crop has been requested. View, edit, approve or reject the request: +%p + #{@request.requester.login_name} has requested a new crop on #{site_name}. - = link_to "Request for #{@request}", crop_url(@request) +%ul + %li Name: #{@request.name} + %li Wikipedia URL: #{@request.en_wikipedia_url.present? ? @request.en_wikipedia_url : "not specified"} + +%p + As a crop wrangler, you can #{link_to "approve or reject this request", edit_crop_url(@request)}. + +%p + Or, discuss this and other crop wrangling issues in our #{link_to "crop wrangling forum", "http://talk.growstuff.org/c/crop-wrangling"}. + +%p + Thanks for your help! + +%p + The Growstuff (staging) team + %br/ + =link_to root_url, root_url \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index ebafd6fa2..4d3f407b9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -285,6 +285,7 @@ ActiveRecord::Schema.define(version: 20150201064502) do t.datetime "updated_at" t.string "slug" t.integer "forum_id" + t.integer "parent_id" end add_index "posts", ["created_at", "author_id"], name: "index_posts_on_created_at_and_author_id", using: :btree From 319fc12ebb31cc4d03162fbaee5e9f91f5316572 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Mon, 9 Feb 2015 21:13:25 +1100 Subject: [PATCH 02/10] add crop must be approved validation --- app/models/harvest.rb | 2 ++ app/models/planting.rb | 2 ++ app/models/seed.rb | 2 ++ app/validators/approved_validator.rb | 7 +++++++ app/views/crops/show.html.haml | 19 ++++++++++--------- 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 app/validators/approved_validator.rb diff --git a/app/models/harvest.rb b/app/models/harvest.rb index edd16ee55..4339a30fa 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -20,6 +20,8 @@ class Harvest < ActiveRecord::Base default_scope { order('created_at DESC') } + validates :crop, :approved => true + validates :crop, :presence => {:message => "must be present and exist in our database"} validates :quantity, diff --git a/app/models/planting.rb b/app/models/planting.rb index 592ef1681..aa3287bf9 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -30,6 +30,8 @@ class Planting < ActiveRecord::Base default_scope { order("created_at desc") } + validates :crop, :approved => true + validates :crop_id, :presence => {:message => "must be present and exist in our database"} validates :quantity, diff --git a/app/models/seed.rb b/app/models/seed.rb index cae7402d9..9fa005907 100644 --- a/app/models/seed.rb +++ b/app/models/seed.rb @@ -7,6 +7,8 @@ class Seed < ActiveRecord::Base default_scope { order("created_at desc") } + validates :crop, :approved => true + validates :crop, :presence => {:message => "must be present and exist in our database"} validates :quantity, :numericality => { diff --git a/app/validators/approved_validator.rb b/app/validators/approved_validator.rb new file mode 100644 index 000000000..513bc25bd --- /dev/null +++ b/app/validators/approved_validator.rb @@ -0,0 +1,7 @@ +class ApprovedValidator < ActiveModel::EachValidator + def validate_each(record, attribute, value) + unless value.approved? + record.errors[attribute] << (options[:message] || 'must be approved') + end + end +end diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 7e8c94d9f..e623d6bf4 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -2,7 +2,7 @@ - content_for :subtitle, @crop.default_scientific_name - if @crop.pending? - .alert.alert-warning + .alert.alert-danger %b This crop is currently pending approval. %p This crop was requested by #{@crop.requester} on #{@crop.created_at}. - unless @crop.request_notes.blank? @@ -10,18 +10,19 @@ Request notes: #{@crop.request_notes} - if @crop.rejected? - .alert.alert-warning + .alert.alert-danger %b This crop was rejected for the following reason: #{@crop.reason_for_rejection}. -- content_for :buttonbar do - - if can? :create, Planting - = link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-default' +- if @crop.approved? + - content_for :buttonbar do + - if can? :create, Planting + = link_to "Plant this", new_planting_path(:crop_id => @crop.id), :class => 'btn btn-default' - - if can? :create, Harvest - = link_to "Harvest this", new_harvest_path(:crop_id => @crop.id), :class => 'btn btn-default' + - if can? :create, Harvest + = link_to "Harvest this", new_harvest_path(:crop_id => @crop.id), :class => 'btn btn-default' - - if can? :create, Seed - = link_to 'Add seeds to stash', new_seed_path(:params => { :crop_id => @crop.id }), :class => 'btn btn-default' + - if can? :create, Seed + = link_to 'Add seeds to stash', new_seed_path(:params => { :crop_id => @crop.id }), :class => 'btn btn-default' .row From 0dbc2e1964f9cf3eb4889e80a1bcdd82357ae11a Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Mon, 9 Feb 2015 21:52:52 +1100 Subject: [PATCH 03/10] prevent users from seeing sci names of crops unless approved --- app/models/ability.rb | 5 +++++ app/views/crops/wrangle.html.haml | 22 +++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index ff5fe4994..f78fdfcbf 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -25,6 +25,11 @@ class Ability # are wranglers or admins cannot :read, Crop can :read, Crop, :approval_status => "approved" + # scientific names should only be viewable if associated crop is approved + cannot :read, ScientificName + can :read, ScientificName do |sn| + sn.crop.approved? + end if member # members can see even rejected or pending crops if they requested it diff --git a/app/views/crops/wrangle.html.haml b/app/views/crops/wrangle.html.haml index a8576b543..549a737a1 100644 --- a/app/views/crops/wrangle.html.haml +++ b/app/views/crops/wrangle.html.haml @@ -18,7 +18,7 @@ .tabbable %ul.nav.nav-tabs %li{:class => @approval_status.blank? ? 'active' : ''} - = link_to "Recendly added", wrangle_crops_path + = link_to "Recently added", wrangle_crops_path %li{:class => @approval_status == "pending" ? 'active' : ''} = link_to "Pending approval", wrangle_crops_path(:approval_status => "pending") %li{:class => @approval_status == "rejected" ? 'active' : ''} @@ -42,13 +42,11 @@ %th System name %th English Wikipedia URL %th Scientific names - %th - - if @approval_status == "pending" - Requested by - - elsif @approval_status == "rejected" - Rejected by - - else - Added by + %th Requested by + - if @approval_status == "rejected" + %th Rejected by + - if @approval_status != "rejected" && @approval_status != "pending" + %th Added by %th When - @crops.each do |c| %tr @@ -58,11 +56,9 @@ - c.scientific_names.each do |s| = link_to s.scientific_name, s %br/ - %td - - if @approval_status == "pending" - = link_to c.requester, c.requester - - else - = link_to c.creator, c.creator + %td= c.requester.present? ? (link_to c.requester, c.requester) : "N/A" + - unless @approval_status == "pending" + %td= c.creator.present? ? (link_to c.creator, c.creator) : "N/A" %td = distance_of_time_in_words(c.created_at, Time.zone.now) ago. From cbb4f9d7ac0c2e8668aff8792c9440605478520a Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Mon, 9 Feb 2015 22:17:32 +1100 Subject: [PATCH 04/10] add rejection notes --- app/controllers/crops_controller.rb | 6 +++++- app/models/crop.rb | 18 ++++++++++++++++++ app/views/crops/_form.html.haml | 9 +++++++++ app/views/crops/show.html.haml | 4 ++-- ...50209105410_add_rejection_notes_to_crops.rb | 5 +++++ db/schema.rb | 3 ++- 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20150209105410_add_rejection_notes_to_crops.rb diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 2c64f5cc8..9fd302669 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -105,6 +105,10 @@ class CropsController < ApplicationController # GET /crops/1/edit def edit @crop = Crop.find(params[:id]) + + (3 - @crop.scientific_names.length).times do + @crop.scientific_names.build + end end # POST /crops @@ -179,6 +183,6 @@ class CropsController < ApplicationController private def crop_params - params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :approval_status, :request_notes, :reason_for_rejection, :scientific_names_attributes => [:scientific_name, :_destroy, :id]) + params.require(:crop).permit(:en_wikipedia_url, :name, :parent_id, :creator_id, :approval_status, :request_notes, :reason_for_rejection, :rejection_notes, :scientific_names_attributes => [:scientific_name, :_destroy, :id]) end end diff --git a/app/models/crop.rb b/app/models/crop.rb index 905af8562..f11d78567 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -43,6 +43,10 @@ class Crop < ActiveRecord::Base ## This validation addresses a race condition validate :approval_status_cannot_be_changed_again + validate :must_be_rejected_if_rejected_reasons_present + + validate :must_have_meaningful_reason_for_rejection + #################################### # Elastic search configuration include Elasticsearch::Model @@ -324,4 +328,18 @@ class Crop < ActiveRecord::Base end end + def must_be_rejected_if_rejected_reasons_present + unless rejected? + if reason_for_rejection.present? || rejection_notes.present? + errors.add(:approval_status, "must be rejected if a reason for rejection is present") + end + end + end + + def must_have_meaningful_reason_for_rejection + if reason_for_rejection == "other" && rejection_notes.blank? + errors.add(:rejection_notes, "must be added if the reason for rejection is \"other\"") + end + end + end diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 9b2ee7a51..6a2d9f562 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -56,6 +56,8 @@ = sn.check_box :_destroy = sn.label :_destroy, "Delete" + %hr / + - unless @crop.new_record? .form-group = f.label :approval_status, 'Approval Status', :class=> 'control-label col-md-2' @@ -66,6 +68,13 @@ = f.label :reason_for_rejection, 'Reason for rejection', :class => 'control-label col-md-2' .col-md-8 = f.select(:reason_for_rejection, @crop.reasons_for_rejection, {:include_blank => true}, {:class => 'form-control'}) + %p + %span.help-block + Please provide additional notes why this crop request was rejected if the above reasons do not apply. + + .form-group + = f.label :rejection_notes, 'Rejection Notes', :class => 'control-label col-md-2' + .col-md-8= f.text_area :rejection_notes, :rows => 6, :class => 'form-control' - else %p diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index e623d6bf4..bda1804d2 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -4,14 +4,14 @@ - if @crop.pending? .alert.alert-danger %b This crop is currently pending approval. - %p This crop was requested by #{@crop.requester} on #{@crop.created_at}. + %p This crop was requested by #{@crop.requester} #{time_ago_in_words(@crop.created_at)} ago. - unless @crop.request_notes.blank? %p Request notes: #{@crop.request_notes} - if @crop.rejected? .alert.alert-danger - %b This crop was rejected for the following reason: #{@crop.reason_for_rejection}. + %b This crop was rejected for the following reason: #{@crop.reason_for_rejection == "other" ? @crop.rejection_notes : @crop.reason_for_rejection}. - if @crop.approved? - content_for :buttonbar do diff --git a/db/migrate/20150209105410_add_rejection_notes_to_crops.rb b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb new file mode 100644 index 000000000..59239fd55 --- /dev/null +++ b/db/migrate/20150209105410_add_rejection_notes_to_crops.rb @@ -0,0 +1,5 @@ +class AddRejectionNotesToCrops < ActiveRecord::Migration + def change + add_column :crops, :rejection_notes, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 4d3f407b9..aca632ccf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150201064502) do +ActiveRecord::Schema.define(version: 20150209105410) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -74,6 +74,7 @@ ActiveRecord::Schema.define(version: 20150201064502) do t.string "approval_status", default: "approved" t.text "reason_for_rejection" t.text "request_notes" + t.text "rejection_notes" end add_index "crops", ["name"], name: "index_crops_on_name", using: :btree From 2697fea24982c0b824db3139d7cc9062c3d0ee36 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Mon, 9 Feb 2015 22:41:35 +1100 Subject: [PATCH 05/10] tests back to green --- app/validators/approved_validator.rb | 2 +- app/views/crops/_form.html.haml | 2 -- spec/features/crops/request_new_crop_spec.rb | 1 + spec/mailers/notifier_spec.rb | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/validators/approved_validator.rb b/app/validators/approved_validator.rb index 513bc25bd..4016058aa 100644 --- a/app/validators/approved_validator.rb +++ b/app/validators/approved_validator.rb @@ -1,6 +1,6 @@ class ApprovedValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) - unless value.approved? + unless record.crop.try(:approved?) record.errors[attribute] << (options[:message] || 'must be approved') end end diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml index 6a2d9f562..e7be7cd62 100644 --- a/app/views/crops/_form.html.haml +++ b/app/views/crops/_form.html.haml @@ -56,8 +56,6 @@ = sn.check_box :_destroy = sn.label :_destroy, "Delete" - %hr / - - unless @crop.new_record? .form-group = f.label :approval_status, 'Approval Status', :class=> 'control-label col-md-2' diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb index 66e996d66..0a1cac2a7 100644 --- a/spec/features/crops/request_new_crop_spec.rb +++ b/spec/features/crops/request_new_crop_spec.rb @@ -5,6 +5,7 @@ feature "Requesting a new crop" do context "As a regular member" do let(:member) { FactoryGirl.create(:member) } + let!(:wrangler) { FactoryGirl.create(:crop_wrangling_member) } before { login_as member } diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 4ad7bd53c..ce552f99b 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -52,7 +52,7 @@ describe Notifier do let(:mail) { Notifier.new_crop_request(member, crop) } it 'sets the subject correctly' do - mail.subject.should == "New crop request" + mail.subject.should == "#{crop.requester.login_name} has requested Ultra berry as a new crop" end it 'comes from noreply@growstuff.org' do From 07f7572b13352203eefe9aad4b32abc0529e5bc3 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Tue, 10 Feb 2015 18:33:54 +1100 Subject: [PATCH 06/10] extract email signature into partial --- app/views/notifier/_signature.html.haml | 4 ++++ app/views/notifier/crop_request_approved.html.haml | 3 +++ app/views/notifier/crop_request_rejected.html.haml | 4 +++- app/views/notifier/new_crop_request.html.haml | 5 +---- app/views/notifier/notify.html.haml | 5 +---- app/views/notifier/planting_reminder.html.haml | 5 +---- 6 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 app/views/notifier/_signature.html.haml diff --git a/app/views/notifier/_signature.html.haml b/app/views/notifier/_signature.html.haml new file mode 100644 index 000000000..30101610d --- /dev/null +++ b/app/views/notifier/_signature.html.haml @@ -0,0 +1,4 @@ +%p + The #{site_name} team. + %br/ + =link_to root_url, root_url diff --git a/app/views/notifier/crop_request_approved.html.haml b/app/views/notifier/crop_request_approved.html.haml index 5fe184f1a..5fea20246 100644 --- a/app/views/notifier/crop_request_approved.html.haml +++ b/app/views/notifier/crop_request_approved.html.haml @@ -11,3 +11,6 @@ = link_to "Harvest #{@crop.name}", new_harvest_url(crop_id: @crop.id) %li = link_to "Stash seeds for #{@crop.name}", new_seed_url(crop_id: @crop.id) + += render :partial => 'signature' + diff --git a/app/views/notifier/crop_request_rejected.html.haml b/app/views/notifier/crop_request_rejected.html.haml index 315f7036d..2d14b04d8 100644 --- a/app/views/notifier/crop_request_rejected.html.haml +++ b/app/views/notifier/crop_request_rejected.html.haml @@ -4,4 +4,6 @@ %p Your request for the new crop: #{link_to @crop.name, crop_url(@crop)} has been rejected for the following reason. - = @crop.reason_for_rejection \ No newline at end of file + = @crop.reason_for_rejection + += render :partial => 'signature' diff --git a/app/views/notifier/new_crop_request.html.haml b/app/views/notifier/new_crop_request.html.haml index 26b63f8ff..c794e7ece 100644 --- a/app/views/notifier/new_crop_request.html.haml +++ b/app/views/notifier/new_crop_request.html.haml @@ -18,7 +18,4 @@ %p Thanks for your help! -%p - The Growstuff (staging) team - %br/ - =link_to root_url, root_url \ No newline at end of file += render :partial => 'signature' diff --git a/app/views/notifier/notify.html.haml b/app/views/notifier/notify.html.haml index b6e962fb3..ed9cf32f2 100644 --- a/app/views/notifier/notify.html.haml +++ b/app/views/notifier/notify.html.haml @@ -20,7 +20,4 @@ %br/ = link_to "Turn off these notifications", edit_member_registration_url -%p - The #{site_name} team. - %br/ - =link_to root_url, root_url += render :partial => 'signature' \ No newline at end of file diff --git a/app/views/notifier/planting_reminder.html.haml b/app/views/notifier/planting_reminder.html.haml index 7edf063b5..4dea05123 100644 --- a/app/views/notifier/planting_reminder.html.haml +++ b/app/views/notifier/planting_reminder.html.haml @@ -59,10 +59,7 @@ %h2 See you soon on #{site_name}! -%p - The #{site_name} team. - %br/ - =link_to root_url, root_url += render :partial => 'signature' %hr/ %p From b81e0342545dc7ee1639c3b40761f611857838ba Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Tue, 10 Feb 2015 18:38:32 +1100 Subject: [PATCH 07/10] tweak permissions for alternate names just like sci names --- app/models/ability.rb | 5 +++++ app/models/planting.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index f78fdfcbf..1997ddf49 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -30,6 +30,11 @@ class Ability can :read, ScientificName do |sn| sn.crop.approved? end + # ... same for alternate names + cannot :read, AlternateName + can :read, AlternateName do |an| + an.crop.approved? + end if member # members can see even rejected or pending crops if they requested it diff --git a/app/models/planting.rb b/app/models/planting.rb index aa3287bf9..958ba625f 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -32,7 +32,7 @@ class Planting < ActiveRecord::Base validates :crop, :approved => true - validates :crop_id, :presence => {:message => "must be present and exist in our database"} + validates :crop, :presence => {:message => "must be present and exist in our database"} validates :quantity, :numericality => { From c61f7b8e72ca045f88f0a129f2a546d90a06f448 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Tue, 10 Feb 2015 18:52:24 +1100 Subject: [PATCH 08/10] pass locals into signature partial properly --- app/views/notifier/crop_request_approved.html.haml | 2 +- app/views/notifier/crop_request_rejected.html.haml | 2 +- app/views/notifier/new_crop_request.html.haml | 2 +- app/views/notifier/notify.html.haml | 2 +- app/views/notifier/planting_reminder.html.haml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/notifier/crop_request_approved.html.haml b/app/views/notifier/crop_request_approved.html.haml index 5fea20246..95a1da688 100644 --- a/app/views/notifier/crop_request_approved.html.haml +++ b/app/views/notifier/crop_request_approved.html.haml @@ -12,5 +12,5 @@ %li = link_to "Stash seeds for #{@crop.name}", new_seed_url(crop_id: @crop.id) -= render :partial => 'signature' += render :partial => 'signature', :locals => { :site_name => site_name } diff --git a/app/views/notifier/crop_request_rejected.html.haml b/app/views/notifier/crop_request_rejected.html.haml index 2d14b04d8..578eb5bc5 100644 --- a/app/views/notifier/crop_request_rejected.html.haml +++ b/app/views/notifier/crop_request_rejected.html.haml @@ -6,4 +6,4 @@ = @crop.reason_for_rejection -= render :partial => 'signature' += render :partial => 'signature', :locals => { :site_name => site_name } \ No newline at end of file diff --git a/app/views/notifier/new_crop_request.html.haml b/app/views/notifier/new_crop_request.html.haml index c794e7ece..395ad2741 100644 --- a/app/views/notifier/new_crop_request.html.haml +++ b/app/views/notifier/new_crop_request.html.haml @@ -18,4 +18,4 @@ %p Thanks for your help! -= render :partial => 'signature' += render :partial => 'signature', :locals => { :site_name => site_name } \ No newline at end of file diff --git a/app/views/notifier/notify.html.haml b/app/views/notifier/notify.html.haml index ed9cf32f2..7260d84be 100644 --- a/app/views/notifier/notify.html.haml +++ b/app/views/notifier/notify.html.haml @@ -20,4 +20,4 @@ %br/ = link_to "Turn off these notifications", edit_member_registration_url -= render :partial => 'signature' \ No newline at end of file += render :partial => 'signature', :locals => { :site_name => site_name } \ No newline at end of file diff --git a/app/views/notifier/planting_reminder.html.haml b/app/views/notifier/planting_reminder.html.haml index 4dea05123..09cea8e15 100644 --- a/app/views/notifier/planting_reminder.html.haml +++ b/app/views/notifier/planting_reminder.html.haml @@ -59,7 +59,7 @@ %h2 See you soon on #{site_name}! -= render :partial => 'signature' += render :partial => 'signature', :locals => { :site_name => site_name } %hr/ %p From 623dbdd418d573adcaad1873cd29b409477be58e Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Tue, 10 Feb 2015 19:58:43 +1100 Subject: [PATCH 09/10] fix search deleting crops --- app/models/crop.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/crop.rb b/app/models/crop.rb index f11d78567..1f514f3ce 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -315,7 +315,7 @@ class Crop < ActiveRecord::Base ) return response.records.to_a else - where("name ILIKE ?", "%#{query}%") + where("name ILIKE ?", "%#{query}%").load end end From 2ab73d3df660d99c836783e0017579ecc752e624 Mon Sep 17 00:00:00 2001 From: Taylor Griffin Date: Tue, 10 Feb 2015 19:59:42 +1100 Subject: [PATCH 10/10] call site name from inside signature partial --- app/views/notifier/_signature.html.haml | 2 ++ app/views/notifier/crop_request_approved.html.haml | 2 +- app/views/notifier/crop_request_rejected.html.haml | 2 +- app/views/notifier/new_crop_request.html.haml | 2 +- app/views/notifier/notify.html.haml | 2 +- app/views/notifier/planting_reminder.html.haml | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/notifier/_signature.html.haml b/app/views/notifier/_signature.html.haml index 30101610d..14a7d47a7 100644 --- a/app/views/notifier/_signature.html.haml +++ b/app/views/notifier/_signature.html.haml @@ -1,3 +1,5 @@ +- site_name = ENV['GROWSTUFF_SITE_NAME'] + %p The #{site_name} team. %br/ diff --git a/app/views/notifier/crop_request_approved.html.haml b/app/views/notifier/crop_request_approved.html.haml index 95a1da688..5fea20246 100644 --- a/app/views/notifier/crop_request_approved.html.haml +++ b/app/views/notifier/crop_request_approved.html.haml @@ -12,5 +12,5 @@ %li = link_to "Stash seeds for #{@crop.name}", new_seed_url(crop_id: @crop.id) -= render :partial => 'signature', :locals => { :site_name => site_name } += render :partial => 'signature' diff --git a/app/views/notifier/crop_request_rejected.html.haml b/app/views/notifier/crop_request_rejected.html.haml index 578eb5bc5..c58e2546b 100644 --- a/app/views/notifier/crop_request_rejected.html.haml +++ b/app/views/notifier/crop_request_rejected.html.haml @@ -6,4 +6,4 @@ = @crop.reason_for_rejection -= render :partial => 'signature', :locals => { :site_name => site_name } \ No newline at end of file += render :partial => 'signature' \ No newline at end of file diff --git a/app/views/notifier/new_crop_request.html.haml b/app/views/notifier/new_crop_request.html.haml index 395ad2741..163c898f4 100644 --- a/app/views/notifier/new_crop_request.html.haml +++ b/app/views/notifier/new_crop_request.html.haml @@ -18,4 +18,4 @@ %p Thanks for your help! -= render :partial => 'signature', :locals => { :site_name => site_name } \ No newline at end of file += render :partial => 'signature' \ No newline at end of file diff --git a/app/views/notifier/notify.html.haml b/app/views/notifier/notify.html.haml index 7260d84be..ed9cf32f2 100644 --- a/app/views/notifier/notify.html.haml +++ b/app/views/notifier/notify.html.haml @@ -20,4 +20,4 @@ %br/ = link_to "Turn off these notifications", edit_member_registration_url -= render :partial => 'signature', :locals => { :site_name => site_name } \ No newline at end of file += render :partial => 'signature' \ No newline at end of file diff --git a/app/views/notifier/planting_reminder.html.haml b/app/views/notifier/planting_reminder.html.haml index 09cea8e15..4dea05123 100644 --- a/app/views/notifier/planting_reminder.html.haml +++ b/app/views/notifier/planting_reminder.html.haml @@ -59,7 +59,7 @@ %h2 See you soon on #{site_name}! -= render :partial => 'signature', :locals => { :site_name => site_name } += render :partial => 'signature' %hr/ %p