mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
use subscription service for canceling subscriptions
This commit is contained in:
parent
61ab016bfb
commit
02ac1ff696
@ -1,6 +1,6 @@
|
||||
class AdminController < ApplicationController
|
||||
layout 'admin'
|
||||
layout 'application', only: [:unsubscribe]
|
||||
layout 'application', only: [:unsubscribe, :perform_unsubscribe]
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_action :require_admin_access
|
||||
@ -45,7 +45,9 @@ class AdminController < ApplicationController
|
||||
emails = params[:emails].split(/[\r|\n]+/)
|
||||
@users = User.where(email: emails)
|
||||
@users.update_all(selected_billing_plan_id: 1)
|
||||
Subscription.where(user_id: @users.pluck(:id)).where('end_date > ?', DateTime.current).update_all(end_date: DateTime.current)
|
||||
@users.each do |user|
|
||||
SubscriptionService.cancel_all_existing_subscriptions(user)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@ -27,3 +27,5 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= link_to 'Unsubscribe more users', mass_unsubscribe_path, class: 'btn white black-text' %>
|
||||
|
||||
@ -168,7 +168,7 @@ Rails.application.routes.draw do
|
||||
get '/content_type/:type', to: 'admin#content_type', as: :admin_content_type
|
||||
get '/attributes', to: 'admin#attributes', as: :admin_attributes
|
||||
get '/masquerade/:user_id', to: 'admin#masquerade', as: :masquerade
|
||||
get '/unsubscribe', to: 'admin#unsubscribe'
|
||||
get '/unsubscribe', to: 'admin#unsubscribe', as: :mass_unsubscribe
|
||||
post '/perform_unsubscribe', to: 'admin#perform_unsubscribe', as: :perform_unsubscribe
|
||||
end
|
||||
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user