summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-09-09 14:52:31 -0700
committerjessib <jessib@riseup.net>2013-09-09 14:52:31 -0700
commitb8cf64edc4f7e77075b1931a13ce4c4cd7c21621 (patch)
treef90d63865f2adcd349f3219912606abf24a238ca
parente11c158a15d54aea0eaefe698e7466634bacf204 (diff)
First run at having admins cancel user subscriptions.
-rw-r--r--billing/app/controllers/billing_base_controller.rb2
-rw-r--r--billing/app/controllers/subscriptions_controller.rb2
-rw-r--r--billing/app/views/subscriptions/show.html.haml3
-rw-r--r--billing/config/routes.rb4
-rw-r--r--config/defaults.yml2
5 files changed, 6 insertions, 7 deletions
diff --git a/billing/app/controllers/billing_base_controller.rb b/billing/app/controllers/billing_base_controller.rb
index c250831..0453677 100644
--- a/billing/app/controllers/billing_base_controller.rb
+++ b/billing/app/controllers/billing_base_controller.rb
@@ -7,7 +7,7 @@ class BillingBaseController < ApplicationController
def assign_user
if params[:user_id]
@user = User.find(params[:user_id])
- elsif params[:action] == "confirm" or params[:action] == "destroy" # confirms and subscription deletes will come back with different ID set, so check for this first
+ elsif params[:action] == "confirm"# confirms will come back with different ID set, so check for this first
# This is only for cases where an admin cannot apply action for customer, but should be all confirms
@user = current_user
elsif params[:id]
diff --git a/billing/app/controllers/subscriptions_controller.rb b/billing/app/controllers/subscriptions_controller.rb
index 4047847..4b1851a 100644
--- a/billing/app/controllers/subscriptions_controller.rb
+++ b/billing/app/controllers/subscriptions_controller.rb
@@ -3,7 +3,7 @@ class SubscriptionsController < BillingBaseController
before_filter :fetch_subscription, :only => [:show, :destroy]
before_filter :confirm_no_active_subscription, :only => [:new, :create]
# for now, admins cannot create or destroy subscriptions for others:
- before_filter :confirm_self, :only => [:destroy, :new, :create]
+ before_filter :confirm_self, :only => [:new, :create]
def new
# don't show link to subscribe if they are already subscribed?
diff --git a/billing/app/views/subscriptions/show.html.haml b/billing/app/views/subscriptions/show.html.haml
index ebb7e0d..39f4d1a 100644
--- a/billing/app/views/subscriptions/show.html.haml
+++ b/billing/app/views/subscriptions/show.html.haml
@@ -3,5 +3,4 @@
Current
Subscription
= render :partial => "subscription_details", :locals => {:subscription => @subscription}
-- if @user == current_user
- = link_to t(:cancel_subscription), subscription_path(@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 @subscription.status == 'Active' # permission check or should that just be on show?
diff --git a/billing/config/routes.rb b/billing/config/routes.rb
index 8b7b5bf..e024f43 100644
--- a/billing/config/routes.rb
+++ b/billing/config/routes.rb
@@ -4,7 +4,7 @@ Rails.application.routes.draw do
match 'payments/confirm' => 'payments#confirm', :as => :confirm_payment
resources :users do
resources :payments, :only => [:index]
- resources :subscriptions, :only => [:index, :show]
+ resources :subscriptions, :only => [:index, :show, :destroy]
end
resources :customer, :only => [:new, :edit]
@@ -14,7 +14,7 @@ Rails.application.routes.draw do
match 'customer/show/:id' => 'customer#show', :as => :show_customer
match 'credit_card_info/confirm' => 'credit_card_info#confirm', :as => :confirm_credit_card_info
- resources :subscriptions, :only => [:new, :create, :update, :destroy] # index and show are within users path
+ resources :subscriptions, :only => [:new, :create, :update] # index, show & destroy are within users path
#match 'transactions/:product_id/new' => 'transactions#new', :as => :new_transaction
#match 'transactions/confirm/:product_id' => 'transactions#confirm', :as => :confirm_transaction
diff --git a/config/defaults.yml b/config/defaults.yml
index 8d81668..8c697d1 100644
--- a/config/defaults.yml
+++ b/config/defaults.yml
@@ -26,7 +26,7 @@ development:
admins: [blue, admin, admin2]
domain: example.org
secret_token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
- payment: []
+ payment: [billing]
test:
<<: *dev_ca