From 0fe1678cd37c8e917cb28eed9eb28777d3a92283 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 1 Oct 2013 13:56:59 -0700 Subject: Allow admins to view past-due subscriptions. --- billing/app/views/billing_admin/show.html.haml | 17 +++++++++++++++++ .../views/subscriptions/_subscription_details.html.haml | 11 ++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 billing/app/views/billing_admin/show.html.haml (limited to 'billing/app/views') diff --git a/billing/app/views/billing_admin/show.html.haml b/billing/app/views/billing_admin/show.html.haml new file mode 100644 index 0000000..78843e5 --- /dev/null +++ b/billing/app/views/billing_admin/show.html.haml @@ -0,0 +1,17 @@ +- # todo: move into helper, as following 2 are pretty much identical +%legend= t(:more_than_90_days_past_due) +- if @past_due_atleast_90_days.empty? + = t(:none) +- else + - @past_due_atleast_90_days.each do |past_due_subscription| + = render :partial => "subscriptions/subscription_details", :locals => {:subscription => past_due_subscription, :show_user => user_for_subscription(past_due_subscription)} + +%legend= t(:all_past_due) +- if @all_past_due.empty? + = t(:none) +- else + - @all_past_due.each do |past_due_subscription| + = render :partial => "subscriptions/subscription_details", :locals => {:subscription => past_due_subscription, :show_user => user_for_subscription(past_due_subscription)} + +%legend= t(:your_settings) += link_to 'view own billing settings', show_or_new_customer_link(current_user) \ No newline at end of file diff --git a/billing/app/views/subscriptions/_subscription_details.html.haml b/billing/app/views/subscriptions/_subscription_details.html.haml index 6eda7ca..27b00c7 100644 --- a/billing/app/views/subscriptions/_subscription_details.html.haml +++ b/billing/app/views/subscriptions/_subscription_details.html.haml @@ -1,7 +1,16 @@ %p + - if local_assigns[:show_user] + User: + = link_to show_user.login, user_overview_path(show_user) + ID: = link_to subscription.id, user_subscription_path(@user, subscription.id) Balance: - = number_to_currency(subscription.balance) + - subscription_balance_currency = number_to_currency(subscription.balance) + - if subscription.balance > 0 + %font{:color => "red"} + = subscription_balance_currency + - else + = subscription_balance_currency Bill on: = subscription.billing_day_of_month Start date: -- cgit v1.2.3 From e4d422142fb2db2153916bed5826651e8418b7a0 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 3 Oct 2013 12:06:57 -0700 Subject: Some refactoring of displayed of past-due subscriptions. --- billing/app/views/billing_admin/show.html.haml | 14 +++----------- .../views/subscriptions/_subscription_details.html.haml | 9 +++------ 2 files changed, 6 insertions(+), 17 deletions(-) (limited to 'billing/app/views') diff --git a/billing/app/views/billing_admin/show.html.haml b/billing/app/views/billing_admin/show.html.haml index 78843e5..a275a5e 100644 --- a/billing/app/views/billing_admin/show.html.haml +++ b/billing/app/views/billing_admin/show.html.haml @@ -1,17 +1,9 @@ -- # todo: move into helper, as following 2 are pretty much identical +- # todo: move into helper, as following 2 are pretty much identical (show_set_user_subscriptions is started) %legend= t(:more_than_90_days_past_due) -- if @past_due_atleast_90_days.empty? - = t(:none) -- else - - @past_due_atleast_90_days.each do |past_due_subscription| - = render :partial => "subscriptions/subscription_details", :locals => {:subscription => past_due_subscription, :show_user => user_for_subscription(past_due_subscription)} += show_set_user_subscriptions(@past_due_atleast_90_days) %legend= t(:all_past_due) -- if @all_past_due.empty? - = t(:none) -- else - - @all_past_due.each do |past_due_subscription| - = render :partial => "subscriptions/subscription_details", :locals => {:subscription => past_due_subscription, :show_user => user_for_subscription(past_due_subscription)} += show_set_user_subscriptions(@all_past_due) %legend= t(:your_settings) = link_to 'view own billing settings', show_or_new_customer_link(current_user) \ No newline at end of file diff --git a/billing/app/views/subscriptions/_subscription_details.html.haml b/billing/app/views/subscriptions/_subscription_details.html.haml index 27b00c7..fcf4bc4 100644 --- a/billing/app/views/subscriptions/_subscription_details.html.haml +++ b/billing/app/views/subscriptions/_subscription_details.html.haml @@ -5,12 +5,9 @@ ID: = link_to subscription.id, user_subscription_path(@user, subscription.id) Balance: - - subscription_balance_currency = number_to_currency(subscription.balance) - - if subscription.balance > 0 - %font{:color => "red"} - = subscription_balance_currency - - else - = subscription_balance_currency + - color = (subscription.balance > 0) ? "red" : "" + %font{:color => color} + = number_to_currency(subscription.balance) Bill on: = subscription.billing_day_of_month Start date: -- cgit v1.2.3 From 72af3e2efd8e0c8c399f0765da8bc6d1597fcb6b Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 3 Oct 2013 12:08:50 -0700 Subject: And removing comment.. --- billing/app/views/billing_admin/show.html.haml | 1 - 1 file changed, 1 deletion(-) (limited to 'billing/app/views') diff --git a/billing/app/views/billing_admin/show.html.haml b/billing/app/views/billing_admin/show.html.haml index a275a5e..3881dc7 100644 --- a/billing/app/views/billing_admin/show.html.haml +++ b/billing/app/views/billing_admin/show.html.haml @@ -1,4 +1,3 @@ -- # todo: move into helper, as following 2 are pretty much identical (show_set_user_subscriptions is started) %legend= t(:more_than_90_days_past_due) = show_set_user_subscriptions(@past_due_atleast_90_days) -- cgit v1.2.3 From 8b378d916caeaf7fd4b1da2aea45eab4b0ccbb39 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 8 Oct 2013 10:44:50 -0700 Subject: Minor tweaks. --- billing/app/views/subscriptions/_subscription_details.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'billing/app/views') diff --git a/billing/app/views/subscriptions/_subscription_details.html.haml b/billing/app/views/subscriptions/_subscription_details.html.haml index fcf4bc4..3a06c20 100644 --- a/billing/app/views/subscriptions/_subscription_details.html.haml +++ b/billing/app/views/subscriptions/_subscription_details.html.haml @@ -17,7 +17,7 @@ Plan: = subscription.plan_id Price: - = subscription.price + = number_to_currency(subscription.price) - color = (subscription.status == 'Active') ? "green" : "red" Status: %font{:color => color} -- cgit v1.2.3 From 4e471f6b35c012d2825f6be19e24ecd5fef8d636 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 8 Oct 2013 14:33:02 -0700 Subject: Consider pending & past due subscriptions as 'active' in the sense that they should prevent one from adding a new subscription. --- billing/app/views/customer/show.html.haml | 2 +- billing/app/views/subscriptions/index.html.haml | 8 ++++---- billing/app/views/subscriptions/show.html.haml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'billing/app/views') diff --git a/billing/app/views/customer/show.html.haml b/billing/app/views/customer/show.html.haml index 243bd3b..562dc4b 100644 --- a/billing/app/views/customer/show.html.haml +++ b/billing/app/views/customer/show.html.haml @@ -18,7 +18,7 @@ = render :partial => "subscriptions/subscription_details", :locals => {:subscription => @active_subscription} - else %p - = t(:no_active_subscription) + = t(:no_relevant_subscription) - if current_user == @user %p .form-actions diff --git a/billing/app/views/subscriptions/index.html.haml b/billing/app/views/subscriptions/index.html.haml index 87771e5..3d4e8fd 100644 --- a/billing/app/views/subscriptions/index.html.haml +++ b/billing/app/views/subscriptions/index.html.haml @@ -1,8 +1,8 @@ %h2=t :all_subscriptions -- active = false +- pending_active_pastdue = false - @subscriptions.each do |s| - - if s.status == 'Active' - - active = true + - if ['Pending', 'Active','Past Due'].include? s.status + - pending_active_pastdue = true = render :partial => "subscription_details", :locals => {:subscription => s} -- if !active and @user == current_user +- if !pending_active_pastdue and @user == current_user = link_to 'subscribe to plan', new_subscription_path, :class => :btn \ No newline at end of file diff --git a/billing/app/views/subscriptions/show.html.haml b/billing/app/views/subscriptions/show.html.haml index 39f4d1a..b258e47 100644 --- a/billing/app/views/subscriptions/show.html.haml +++ b/billing/app/views/subscriptions/show.html.haml @@ -3,4 +3,4 @@ Current Subscription = render :partial => "subscription_details", :locals => {:subscription => @subscription} -= link_to t(:cancel_subscription), user_subscription_path(@user, @subscription.id), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn btn-danger' if @subscription.status == 'Active' # permission check or should that just be on show? += link_to t(:cancel_subscription), user_subscription_path(@user, @subscription.id), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn btn-danger' if ['Active', 'Pending'].include? @subscription.status # permission check or should that just be on show? # should you be able to cancel pending subscription? -- cgit v1.2.3 From 51f93fc87c9cadbe52877ddc3e7c5fd07866b397 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 10 Oct 2013 11:35:26 -0700 Subject: Admins can cancel pastdue subscriptions, but users cannot cancel their own pastdue subscription, as then admins won't be able to search for them. --- billing/app/views/subscriptions/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'billing/app/views') diff --git a/billing/app/views/subscriptions/show.html.haml b/billing/app/views/subscriptions/show.html.haml index b258e47..f4d644a 100644 --- a/billing/app/views/subscriptions/show.html.haml +++ b/billing/app/views/subscriptions/show.html.haml @@ -3,4 +3,4 @@ Current Subscription = render :partial => "subscription_details", :locals => {:subscription => @subscription} -= link_to t(:cancel_subscription), user_subscription_path(@user, @subscription.id), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn btn-danger' if ['Active', 'Pending'].include? @subscription.status # permission check or should that just be on show? # should you be able to cancel pending subscription? += link_to t(:cancel_subscription), user_subscription_path(@user, @subscription.id), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn btn-danger' if ['Active', 'Pending'].include? @subscription.status or admin? # permission check or should that just be on show? # should you be able to cancel pending subscription? -- cgit v1.2.3 From 92cb054d53aaac6864a6a805d9cdd3919f4a38bc Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 17 Oct 2013 13:58:54 -0700 Subject: Some cleanup of code to deal with past due subscriptions. --- billing/app/views/billing_admin/show.html.haml | 5 ++--- billing/app/views/subscriptions/_subscription_details.html.haml | 3 ++- billing/app/views/subscriptions/show.html.haml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'billing/app/views') diff --git a/billing/app/views/billing_admin/show.html.haml b/billing/app/views/billing_admin/show.html.haml index 3881dc7..0382cf0 100644 --- a/billing/app/views/billing_admin/show.html.haml +++ b/billing/app/views/billing_admin/show.html.haml @@ -1,8 +1,7 @@ %legend= t(:more_than_90_days_past_due) -= show_set_user_subscriptions(@past_due_atleast_90_days) - += render(:partial => "subscriptions/subscription_details", :collection => @past_due_atleast_90_days, :as => 'subscription', :locals => {:show_user => true}) || t(:none) %legend= t(:all_past_due) -= show_set_user_subscriptions(@all_past_due) += render(:partial => "subscriptions/subscription_details", :collection => @all_past_due, :as => 'subscription', :locals => {:show_user => true}) || t(:none) %legend= t(:your_settings) = link_to 'view own billing settings', show_or_new_customer_link(current_user) \ No newline at end of file diff --git a/billing/app/views/subscriptions/_subscription_details.html.haml b/billing/app/views/subscriptions/_subscription_details.html.haml index 3a06c20..6145c95 100644 --- a/billing/app/views/subscriptions/_subscription_details.html.haml +++ b/billing/app/views/subscriptions/_subscription_details.html.haml @@ -1,7 +1,8 @@ %p - if local_assigns[:show_user] User: - = link_to show_user.login, user_overview_path(show_user) + - user_to_show = user_for_subscription(subscription) + = link_to user_to_show.login, user_overview_path(user_to_show) ID: = link_to subscription.id, user_subscription_path(@user, subscription.id) Balance: diff --git a/billing/app/views/subscriptions/show.html.haml b/billing/app/views/subscriptions/show.html.haml index f4d644a..2699db9 100644 --- a/billing/app/views/subscriptions/show.html.haml +++ b/billing/app/views/subscriptions/show.html.haml @@ -3,4 +3,4 @@ Current Subscription = render :partial => "subscription_details", :locals => {:subscription => @subscription} -= link_to t(:cancel_subscription), user_subscription_path(@user, @subscription.id), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn btn-danger' if ['Active', 'Pending'].include? @subscription.status or admin? # permission check or should that just be on show? # should you be able to cancel pending subscription? += link_to t(:cancel_subscription), user_subscription_path(@user, @subscription.id), :confirm => t(:are_you_sure), :method => :delete, :class => 'btn btn-danger' if allow_cancel_subscription(@subscription) -- cgit v1.2.3