From c53017dd6cef9ac7430171bb2392caebb0a6937e Mon Sep 17 00:00:00 2001 From: Matt LeBel Date: Thu, 5 Dec 2013 16:13:09 -0800 Subject: [PATCH 01/13] facebook like button now appears regardless of app id input --- app/views/admin/admin_website.html.erb | 11 +++++------ app/views/layouts/_facebook_metas.html.erb | 4 +--- app/views/layouts/_social_js.html.erb | 4 +--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/views/admin/admin_website.html.erb b/app/views/admin/admin_website.html.erb index c9863953..3779e858 100644 --- a/app/views/admin/admin_website.html.erb +++ b/app/views/admin/admin_website.html.erb @@ -65,12 +65,6 @@ <%= f.text_area :tweet_text, rows: 2 %> -
-

Include your Facebook app ID here to set up your social sharing buttons. Visit https://developers.facebook.com/apps to create an app for your site. The like button will NOT show up unless you provide this ID.

- - <%= f.text_field :facebook_app_id %> -
-

The title shown when your site is shared via Facebook. Leave this blank if you want to use your project name.

@@ -129,6 +123,11 @@ <%= f.check_box :indexable %>
+
+

If you're using a custom domain (eg: campaigns.YourSite.com), you'll need to include a custom Facebook app ID here. Visit https://developers.facebook.com/apps to create a free app for your site.

+ + <%= f.text_field :facebook_app_id %> +

Add your own CSS styles to fully customize the look and feel of your site.

diff --git a/app/views/layouts/_facebook_metas.html.erb b/app/views/layouts/_facebook_metas.html.erb index 6a810d61..971a26a9 100644 --- a/app/views/layouts/_facebook_metas.html.erb +++ b/app/views/layouts/_facebook_metas.html.erb @@ -1,8 +1,6 @@ -<% if !@settings.facebook_app_id.blank? %> - -<% end %> + <% params[:controller] == 'campaigns' ? c = @campaign : c = false %> diff --git a/app/views/layouts/_social_js.html.erb b/app/views/layouts/_social_js.html.erb index 97d85d47..5021741a 100644 --- a/app/views/layouts/_social_js.html.erb +++ b/app/views/layouts/_social_js.html.erb @@ -1,9 +1,8 @@ -<% if !@settings.facebook_app_id.blank? %>
-<% end %> " %>
From 347900340a5e4617b69b53a31dfe03441dd77073 Mon Sep 17 00:00:00 2001 From: Henry Liu Date: Tue, 17 Dec 2013 14:18:35 -0800 Subject: [PATCH 12/13] Strip whitespace from CC input field --- app/assets/javascripts/campaigns.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/campaigns.js.coffee b/app/assets/javascripts/campaigns.js.coffee index 6786eb27..6cd88c54 100644 --- a/app/assets/javascripts/campaigns.js.coffee +++ b/app/assets/javascripts/campaigns.js.coffee @@ -69,7 +69,7 @@ Crowdhoster.campaigns = $form = $(form) cardData = - number: $form.find('#card_number').val() + number: $form.find('#card_number').val().replace(/\s/g, "") expiration_month: $form.find('#expiration_month').val() expiration_year: $form.find('#expiration_year').val() security_code: $form.find('#security_code').val() From c612b21b275033fbeefb1e50acc27c410167acae Mon Sep 17 00:00:00 2001 From: Matt LeBel Date: Tue, 17 Dec 2013 19:32:10 -0800 Subject: [PATCH 13/13] added ability to update bank account --- app/controllers/admin_controller.rb | 60 +++++++++++++------ ...p.html.erb => admin_bank_account.html.erb} | 6 +- .../admin/admin_processor_setup.html.erb | 2 +- config/routes.rb | 4 +- 4 files changed, 48 insertions(+), 24 deletions(-) rename app/views/admin/{admin_bank_setup.html.erb => admin_bank_account.html.erb} (91%) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 6f2bc70e..ed6f277a 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -2,7 +2,7 @@ class AdminController < ApplicationController layout "admin" before_filter :authenticate_user! before_filter :verify_admin - before_filter :set_ct_env, only: [:admin_bank_setup, :ajax_verify] + before_filter :set_ct_env, only: [:admin_bank_account, :create_admin_bank_account, :delete_admin_bank_account, :ajax_verify] def admin_website #Handle the form submission if request is PUT @@ -30,28 +30,33 @@ def admin_processor_setup end end - def admin_bank_setup - redirect_to admin_processor_setup_url, flash: { error: "Please set up your payment processor before providing your bank details" } and return unless @settings.payments_activated? + def create_admin_bank_account + if params[:ct_bank_id].blank? + flash = { :error => "Looks like you have JavaScript disabled. JavaScript is required for bank account setup." } + else + begin + bank = { + id: params[:ct_bank_id] + } + Crowdtilt.post('/users/' + @ct_admin_id + '/banks/default', {bank: bank}) + rescue => exception + flash = { :error => "An error occurred, please contact team@crowdhoster.com: #{exception.message}" } + else + flash = { :success => "Your bank account is all set up!" } + end + end + redirect_to admin_bank_account_url, :status => 303, :flash => flash + end + + def admin_bank_account + unless @settings.payments_activated? + redirect_to admin_processor_setup_url, flash: { error: "Please set up your payment processor before providing your bank details" } and return + end @bank = {} begin response = Crowdtilt.get('/users/' + @ct_admin_id + '/banks/default') rescue => exception # response threw an error, default bank may not be set up - if request.post? - if params[:ct_bank_id].blank? - flash.now[:error] = "An error occurred, please try again" and return - else - begin - bank = { - id: params[:ct_bank_id] - } - response = Crowdtilt.post('/users/' + @ct_admin_id + '/banks/default', {bank: bank}) - rescue => exception - flash.now[:error] = exception.message and return - else - @bank = response['bank'] - end - end - end + # do nothing else # response is good, check for default bank if response['bank'] # default bank is already set up @bank = response['bank'] @@ -61,6 +66,23 @@ def admin_bank_setup end end + def delete_admin_bank_account + begin + response = Crowdtilt.get('/users/' + @ct_admin_id + '/banks/default') + rescue => exception + flash = { :error => "No default bank account" } + else + begin + Crowdtilt.delete('/users/' + @ct_admin_id + '/banks/' + response['bank']['id']) + rescue => exception + flash = { :error => "An error occurred, please contact team@crowdhoster.com: #{exception.message}" } + else + flash = { :info => "Bank account deleted successfully" } + end + end + redirect_to admin_bank_account_url, :status => 303, :flash => flash + end + def ajax_verify if params[:name].blank? || params[:phone].blank? || params[:street_address].blank? || params[:postal_code].blank? || params[:dob].blank? render text: "error" and return #not all fields filled out diff --git a/app/views/admin/admin_bank_setup.html.erb b/app/views/admin/admin_bank_account.html.erb similarity index 91% rename from app/views/admin/admin_bank_setup.html.erb rename to app/views/admin/admin_bank_account.html.erb index 336d123f..84bdac96 100644 --- a/app/views/admin/admin_bank_setup.html.erb +++ b/app/views/admin/admin_bank_account.html.erb @@ -5,7 +5,7 @@
@@ -21,12 +21,12 @@

Campaign funds are transferred automatically to your account within 2 business days of campaign expiration.

-

Need to change your bank account? Send us an email.

+

Need to change your bank account? <%= link_to 'Delete bank account', delete_admin_bank_account_path, :confirm => 'Are you sure you want to delete this bank account?', :method => :delete %>

<% else %> - <%= form_tag(admin_bank_setup_path, method: "post", id: "admin_bank_form") %> + <%= form_tag(create_admin_bank_account_path, method: "post", id: "admin_bank_form") %>

Personal Information Using a business account?

diff --git a/app/views/admin/admin_processor_setup.html.erb b/app/views/admin/admin_processor_setup.html.erb index 790b5b7c..eddff725 100644 --- a/app/views/admin/admin_processor_setup.html.erb +++ b/app/views/admin/admin_processor_setup.html.erb @@ -5,7 +5,7 @@
diff --git a/config/routes.rb b/config/routes.rb index 8fc311a3..04279ad0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,7 +20,9 @@ match '/admin/campaigns/:id/copy', to: 'admin/campaigns#copy', as: :admin_campaigns_copy match '/admin/campaigns/:id/payments', to: 'admin/campaigns#payments', as: :admin_campaigns_payments match '/admin/processor-setup', to: 'admin#admin_processor_setup', as: :admin_processor_setup - match '/admin/bank-setup', to: 'admin#admin_bank_setup', as: :admin_bank_setup + post '/admin/bank-setup', to: 'admin#create_admin_bank_account', as: :create_admin_bank_account + get '/admin/bank-setup', to: 'admin#admin_bank_account', as: :admin_bank_account + delete '/admin/bank-setup', to: 'admin#delete_admin_bank_account', as: :delete_admin_bank_account match '/admin/notification-setup', to: 'admin#admin_notification_setup', as: :admin_notification_setup match '/ajax/verify', to: 'admin#ajax_verify', as: :ajax_verify