Skip to content

Commit

Permalink
Merge branch 'master' into stable/1.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhenry committed Nov 19, 2013
2 parents 8692a67 + 79b83bc commit 6ecd6e0
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 24 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ Install the Heroku config plugin if you don't already have it installed
$ heroku plugins:install git://github.com/ddollar/heroku-config.git
```

Push the configuration to Heroku
Push the configuration to Heroku.
NOTE: If you have already written config vars to Heroku, they will not be overwritten unless you pass the `--overwrite` flag as well.

```
$ heroku config:push
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/admin.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ Crowdhoster.admin =
t = h + ':' + ("0" + d.getMinutes()).slice(-2) + ' am'
$('#campaign_expiration_date').val($.datepicker.formatDate('mm/dd/yy',d) + ' ' + t)

if $('#campaign_expiration_date').length
$('#campaign_expiration_date')[0].defaultValue = $('#campaign_expiration_date').val()

$('input#campaign_collect_additional_info').on "change", ->
$('.additional_info_input').slideToggle()

Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
//= require theme
//= require validate
//= require event_tracking
//= require unsaved_changes.js
17 changes: 17 additions & 0 deletions app/assets/javascripts/unsaved_changes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var unsavedChangesChecker = function() {
var warn;
$('form').find(':input').each(function( i, el ) {
if (el.value != el.defaultValue) {
warn = true;
}
});
if (warn) {
return "Your campaign changes have not been saved.";
}
}

$(function() {
if ($('#admin_website_form, #admin_campaign_form').length) {
$(window).bind('beforeunload', unsavedChangesChecker);
}
});
8 changes: 5 additions & 3 deletions app/assets/javascripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $( document ).ready(function() {

// custom handler to call named function ""
submitHandler: function (form) {
$(window).unbind('beforeunload', unsavedChangesChecker);
Crowdhoster.admin.submitWebsiteForm(form);
},

Expand Down Expand Up @@ -51,6 +52,7 @@ $( document ).ready(function() {

// custom handler to call named function ""
submitHandler: function (form) {
$(window).unbind('beforeunload', unsavedChangesChecker);
Crowdhoster.admin.submitCampaignForm(form);
},

Expand Down Expand Up @@ -249,7 +251,7 @@ $( document ).ready(function() {
},
email: {
required: "Please enter your email address.",
email: "Hmm. That doesnt look like a valid email."
email: "Hmm. That doesn't look like a valid email."
},
additional_info: {
required: "We need this additional information to complete your contribution."
Expand All @@ -271,8 +273,8 @@ $( document ).ready(function() {
},
card_number: {
required: "We need your card number to charge it",
minlength: "Hmm. That doesnt look valid just yet.",
creditcard: "Hmm. That doesnt look valid just yet."
minlength: "Hmm. That doesn't look valid just yet.",
creditcard: "Hmm. That doesn't look valid just yet."
},
security_code: {
required: "Your security code is required. Fill 'er in!",
Expand Down
10 changes: 9 additions & 1 deletion app/assets/stylesheets/admin.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,22 @@

#admin_bank_setup {
.main_content {
width: 560px;
width: 900px;
float: left;
}

fieldset {
margin-bottom: 30px;
}

.account_numbers {
border-bottom: 1px solid gray;
}

.more_info {
padding-top: 10px;
}

.form-row .field {
float: left;
margin-right: 20px;
Expand Down
9 changes: 8 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ def check_init
# Put user back on admin area
redirect_to admin_website_url, :flash => { :success => "Nice! Your app is now initialized." }
else
redirect_to new_user_registration_url, :flash => { :error => "App is not initialized" }
redirect_to new_user_registration_url, :flash => { :error => "Please create an account below to initialize the app." }
end
end
end

def calculate_processing_fee(amount_cents)
amount_cents *= Rails.configuration.processing_fee_percentage.to_f / 100
amount_cents += Rails.configuration.processing_fee_flat_cents
return amount_cents.ceil
end

end
4 changes: 2 additions & 2 deletions app/controllers/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def checkout_payment
return
end

@fee = (@campaign.apply_processing_fee)? ((@amount * (Rails.configuration.processing_fee.to_f/100))*100).ceil/100.0 : 0
@fee = (@campaign.apply_processing_fee)? calculate_processing_fee(@amount * 100)/100.0 : 0
@total = @amount + @fee

end
Expand All @@ -69,7 +69,7 @@ def checkout_confirmation

#calculate amount and fee in cents
amount = (params[:amount].to_f*100).ceil
fee = (amount * (Rails.configuration.processing_fee.to_f/100)).ceil
fee = calculate_processing_fee(amount)
quantity = params[:quantity].to_i

#Shipping Info
Expand Down
10 changes: 8 additions & 2 deletions app/views/admin/admin_bank_setup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
<% if @bank['is_default'] %>

<h4>Your banking information's all set up!</h4>
<p>Routing Number: ****<%= @bank['bank_code_last_four'] %></p>
<p>Account Number: ****<%= @bank['account_number_last_four'] %></p>
<div class="account_numbers">
<p>Routing Number: ****<%= @bank['bank_code_last_four'] %></p>
<p>Account Number: ****<%= @bank['account_number_last_four'] %></p>
</div>
<div class="more_info">
<p>Campaign funds are transferred automatically to your account within 2 business days of campaign expiration. </p>
<p>Need to change your bank account? <a href="mailto:[email protected]?subject=Please reset my bank account info&body=Hi! I'd like to change my bank account. Please reset it for the Crowdhoster site named:">Send us an email</a>.</p>
</div>

<% else %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/campaigns/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</div>

<div class="field clearfix">
<p class="explanation">This passes the <%= Rails.configuration.processing_fee %>% processing fee onto your contributors, adding the fee amount to their contribution amount when they check out. If you do not select this option, the processing fee will be deducted from the amount raised before being disbursed to your bank account.</p>
<p class="explanation">This passes the <%= Rails.configuration.processing_fee_percentage %>% + <%= Rails.configuration.processing_fee_flat_cents %>¢ per-transaction processing fee onto your contributors, adding the fee amount to their contribution amount when they check out. If you do not select this option, the processing fee will be deducted from the amount raised before being disbursed to your bank account.</p>
<label>Pass Credit Card Processing Fee to Contributors?</label>
<%= f.check_box :apply_processing_fee %>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/views/layouts/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
<li>
<a href="<%= url_for admin_website_path %>"><i class="icon-edit icon-white"></i> Edit homepage</a>
</li>
<li>
<a href="<%= url_for new_admin_campaign_path %>"><i class="icon-plus icon-white"></i> New Campaign</a>
</li>
<% end %>

<% if request.fullpath.include? 'admin' %>
<li>
<a href="<%= url_for root_path %>"><i class="icon-chevron-left icon-white"></i> Back to website</a>
</li>
<li>
<a href="<%= url_for new_admin_campaign_path %>"><i class="icon-plus icon-white"></i> New Campaign</a>
</li>
<% end %>

<% if params[:controller] == 'campaigns' %>
Expand Down
20 changes: 10 additions & 10 deletions app/views/theme/views/homepage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@
<% end %>

<p class="numbers pull-left">
<% if campaign.goal_type == 'dollars' %>
<strong>$<%= campaign.raised_amount.ceil %></strong><br/>
<%= campaign.progress_text %>
<% else %>
<strong><%= campaign.orders %></strong><br/>
<%= campaign.contributor_reference.pluralize(campaign.orders) %>
<% end %>
</p>

<p class="numbers pull-right" style="text-align:right">
<% if campaign.expired? %>
<strong>No</strong><br/>days left!
<% else %>
Expand All @@ -57,16 +67,6 @@
<% end %>
</p>

<p class="numbers pull-right" style="text-align:right">
<% if campaign.goal_type == 'dollars' %>
<strong>$<%= campaign.raised_amount.ceil %></strong><br/>
<%= campaign.progress_text %>
<% else %>
<strong><%= campaign.orders %></strong><br/>
<%= campaign.contributor_reference.pluralize(campaign.orders) %>
<% end %>
</p>

</a>
<% end %>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Application < Rails::Application
:password => ENV['MAILGUN_PASSWORD']
}

config.processing_fee = 2.9
config.processing_fee_percentage = 2.9
config.processing_fee_flat_cents = 30

end
end
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,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/processor-setup', to: 'admin#admin_processor_setup', as: :admin_processor_setup
match '/admin/bank-setup', to: 'admin#admin_bank_setup', as: :admin_bank_setup
match '/admin/notification-setup', to: 'admin#admin_notification_setup', as: :admin_notification_setup
match '/admin/notification-setup', to: 'admin#admin_notification_setup', as: :admin_notification_setup
match '/ajax/verify', to: 'admin#ajax_verify', as: :ajax_verify

# CAMPAIGNS
Expand Down

0 comments on commit 6ecd6e0

Please sign in to comment.