diff options
| author | jessib <jessib@riseup.net> | 2013-07-25 11:21:27 -0700 | 
|---|---|---|
| committer | jessib <jessib@riseup.net> | 2013-07-25 11:21:27 -0700 | 
| commit | 3578c13abd86d15ca6310bf5652f4855a8daa1a8 (patch) | |
| tree | 6c703e82ded7692f50c740f0ae1a9454adbed256 | |
| parent | 16128d6eb8bb8c7e467c263c3c4f79cf9869ed31 (diff) | |
Have navigation link to new customer form if user is not already a braintree customer.
| -rw-r--r-- | app/views/layouts/_navigation.html.haml | 2 | ||||
| -rw-r--r-- | billing/app/controllers/customer_controller.rb | 2 | ||||
| -rw-r--r-- | billing/app/helpers/billing_helper.rb | 8 | ||||
| -rw-r--r-- | users/app/views/overviews/show.html.haml | 2 | 
4 files changed, 11 insertions, 3 deletions
diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 1411c6a..cd37ffa 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -3,5 +3,5 @@    = link_to_navigation t(:account_settings), edit_user_path(@user), :active => controller?(:users)    = link_to_navigation t(:email_settings), edit_user_email_settings_path(@user), :active => controller?(:email_settings)    = link_to_navigation t(:support_tickets), auto_tickets_path, :active => controller?(:tickets) -  = link_to_navigation t(:billing_settings), show_customer_path(@user), :active => controller?(:customer, :payments, :subscriptions, :credit_card_info) +  = link_to_navigation t(:billing_settings), show_or_new_customer_link(@user), :active => controller?(:customer, :payments, :subscriptions, :credit_card_info)    = link_to_navigation t(:logout), logout_path, :method => :delete diff --git a/billing/app/controllers/customer_controller.rb b/billing/app/controllers/customer_controller.rb index c6cabe6..14ea8a7 100644 --- a/billing/app/controllers/customer_controller.rb +++ b/billing/app/controllers/customer_controller.rb @@ -4,7 +4,7 @@ class CustomerController < BillingBaseController      customer.with_braintree_data!      @default_cc = customer.default_credit_card #TODO not actually right way      @active_subscription = customer.subscriptions -    @transactions =  Braintree::Customer.find(customer.braintree_customer_id).transactions #TODO not actually right way +    @transactions = customer.braintree_customer.transactions    end    def new diff --git a/billing/app/helpers/billing_helper.rb b/billing/app/helpers/billing_helper.rb index f91d9c9..7ec9285 100644 --- a/billing/app/helpers/billing_helper.rb +++ b/billing/app/helpers/billing_helper.rb @@ -9,4 +9,12 @@ module BillingHelper      form_for object, options, &block    end +  def show_or_new_customer_link(user) +    if (customer = Customer.find_by_user_id(user.id)) and customer.has_payment_info? +      show_customer_path(user) +    else +      new_customer_path +    end +  end +  end diff --git a/users/app/views/overviews/show.html.haml b/users/app/views/overviews/show.html.haml index 4084b1f..c6b079d 100644 --- a/users/app/views/overviews/show.html.haml +++ b/users/app/views/overviews/show.html.haml @@ -19,4 +19,4 @@      %li= icon('user') + link_to(t(:overview_account), edit_user_path(@user))      %li= icon('envelope') + link_to(t(:overview_email), edit_user_email_settings_path(@user))      %li= icon('question-sign') + link_to(t(:overview_tickets), user_tickets_path(@user)) -    %li= icon('shopping-cart') + link_to(t(:overview_billing), show_customer_path(@user)) +    %li= icon('shopping-cart') + link_to(t(:overview_billing), show_or_new_customer_link(@user))  | 
