Merge branch 'remove_tiers' into debtcollective/master
This commit is contained in:
commit
be93f67f8f
14 changed files with 487 additions and 1066 deletions
|
@ -124,16 +124,6 @@ class ApplicationController < ActionController::Base
|
|||
QueryRoles.user_has_role?(current_user.id, role_names, host_id)
|
||||
end
|
||||
|
||||
def current_plan_tier(npo_id = nil)
|
||||
return 0 if !npo_id && !administered_nonprofit
|
||||
|
||||
npo_id ||= administered_nonprofit.id
|
||||
return 2 if current_role?(:super_admin)
|
||||
|
||||
key = "plan_tier_user_#{current_user_id}_nonprofit_#{npo_id}"
|
||||
administered_nonprofit ? QueryBillingSubscriptions.plan_tier(npo_id) : 0
|
||||
end
|
||||
|
||||
def administered_nonprofit
|
||||
return nil unless current_user
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ module Nonprofits
|
|||
include Controllers::NonprofitHelper
|
||||
|
||||
before_action :authenticate_nonprofit_user!, except: %i[new create]
|
||||
# before_action(except: [:create, :mailchimp_landing]){authenticate_min_nonprofit_plan(2)}
|
||||
|
||||
# get /nonprofit/:nonprofit_id/supporters
|
||||
def index
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%>
|
||||
<!-- partial common/onboarding_modals -->
|
||||
|
||||
<%= render 'billing_subscriptions/new_modal' %>
|
||||
|
||||
<%= render 'nonprofits/new_modal' unless current_role?(:nonprofit_associate) || current_role?(:nonprofit_admin) %>
|
||||
|
||||
<div class='modal skinny' id='onboardSignUpModal'>
|
||||
<%= render 'common/modal_header', title: "Sign Up" %>
|
||||
|
||||
<div class='modal-body'>
|
||||
<div class='u-marginBottom--15 u-centered'>
|
||||
<h6>Welcome aboard!</h6>
|
||||
<%= render 'components/selected_tier' %>
|
||||
<hr>
|
||||
</div>
|
||||
<form class='u-width--300 u-margin--auto'>
|
||||
<!--= on 'submit' (cache_new_admin form_object) -->
|
||||
|
||||
<%= render 'users/signup_fields' %>
|
||||
<%= render 'components/forms/submit_button',
|
||||
button_text: 'Sign Up',
|
||||
loading_text: 'Thinking...',
|
||||
scope: 'new_admin' %>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='modal skinny' id='onboardLoginModal'>
|
||||
<%= render 'common/modal_header', title: 'Login' %>
|
||||
<div class='modal-body u-centered'>
|
||||
<section class='u-margin--auto u-width--300'>
|
||||
<%= render 'users/email_login_form' %>
|
||||
<hr>
|
||||
<p class='u-bold'><a href='<%= new_password_path(:user) %>'>Forgot your password?</a></p>
|
||||
<%= render 'users/login_footer', :action => "open-modal=onboardSignUpModal" %>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- end partial common/onboarding_modals -->
|
|
@ -7,7 +7,6 @@ var app = {
|
|||
, current_admin: <%= !!(current_user && current_role?(:super_admin)) %>
|
||||
, nonprofit: <%= @nonprofit ? raw(@nonprofit.to_json) : 'undefined' %>
|
||||
, nonprofit_id : <%= @nonprofit ? @nonprofit.id : 'undefined' %>
|
||||
, current_plan_tier: <%= @nonprofit ? current_plan_tier(@nonprofit.id) : 'undefined' %>
|
||||
, user: <%= current_user ? raw(current_user.to_json) : 'undefined' %>
|
||||
, user_id: <%= current_user ? current_user.id : 'undefined' %>
|
||||
, profile: <%= current_user ? raw(current_user.profile.to_json) : 'undefined' %>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<% end %>
|
||||
</button>
|
||||
|
||||
<% if current_plan_tier >= 1 && current_nonprofit_user? %>
|
||||
<% if current_nonprofit_user? %>
|
||||
<button class='button--jumbo u-width--full' open-modal='newEvent' data-when-confirmed if-branded='background-color, dark'>
|
||||
Create an Event
|
||||
</button>
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<% content_for :javascripts do %>
|
||||
<script>
|
||||
app.referer_url = "<%= @referer %>"
|
||||
app.nonprofit.plan_tier = <%= QueryBillingSubscriptions.plan_tier(@nonprofit.id) %>
|
||||
app.campaign = <%= raw (@campaign || {}).to_json %>
|
||||
app.currency_symbol = "<%= @nonprofit.currency_symbol %>"
|
||||
app.utmParams = {
|
||||
|
|
|
@ -15,14 +15,6 @@ module.exports = appl
|
|||
appl.is_loading = function() {appl.def('loading', true)}
|
||||
appl.not_loading = function() {appl.def('loading', false)}
|
||||
appl.not_loading()
|
||||
|
||||
// Define the current payment plan tier for a signed-in nonprofit
|
||||
appl.def('current_plan_tier', app.current_plan_tier)
|
||||
|
||||
appl.def("is_at_least_plan", function(tier) {
|
||||
return app.current_plan_tier >= tier
|
||||
})
|
||||
|
||||
// Open a modal given by its modal id (uses the modal div's 'id' attribute)
|
||||
appl.def('open_modal', function(modalId) {
|
||||
$('.modal').removeClass('inView')
|
||||
|
|
|
@ -72,14 +72,14 @@ function setGiftOptionParams(campaign_id, gift_id) {
|
|||
|
||||
var state = donate.init(params$)
|
||||
var container = document.querySelector('.js-donateForm')
|
||||
if(app.nonprofit.plan_tier > 0) {
|
||||
$(".donationWizard").trigger("render:pre");
|
||||
var event = new CustomEvent('render:pre');
|
||||
container.parentNode.dispatchEvent(event);
|
||||
render({patch, view: donate.view, state, container})
|
||||
jQuery(function($){
|
||||
$(".donationWizard").trigger("render:post").addClass("displayed-updated");
|
||||
});
|
||||
|
||||
$(".donationWizard").trigger("render:pre");
|
||||
var event = new CustomEvent('render:pre');
|
||||
container.parentNode.dispatchEvent(event);
|
||||
render({patch, view: donate.view, state, container})
|
||||
jQuery(function($){
|
||||
$(".donationWizard").trigger("render:post").addClass("displayed-updated");
|
||||
});
|
||||
// event = new CustomEvent('render:post');
|
||||
// container.parentNode.dispatchEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ const fontRow = R.curry((state, key, font) =>
|
|||
)
|
||||
|
||||
const form = state => {
|
||||
var tier = state.nonprofit.tier
|
||||
var btn = button({ buttonText: 'Save Branding' , loading$: state.loading$ })
|
||||
|
||||
return h('form.branding-form', {
|
||||
|
|
5
db/migrate/20191105200033_remove_billing_plan_tiers.rb
Normal file
5
db/migrate/20191105200033_remove_billing_plan_tiers.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RemoveBillingPlanTiers < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :billing_plans, :tier
|
||||
end
|
||||
end
|
1416
db/structure.sql
1416
db/structure.sql
File diff suppressed because it is too large
Load diff
|
@ -12,12 +12,6 @@ module Controllers::NonprofitHelper
|
|||
block_with_sign_in 'Please sign in' unless current_nonprofit_admin?
|
||||
end
|
||||
|
||||
def authenticate_min_nonprofit_plan(plan_tier)
|
||||
unless current_nonprofit_user? && current_plan_tier >= plan_tier
|
||||
block_with_sign_in 'Please sign in'
|
||||
end
|
||||
end
|
||||
|
||||
def current_nonprofit_user?
|
||||
return false if params[:preview]
|
||||
return false unless current_nonprofit_without_exception
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'qx'
|
||||
require 'active_support/core_ext'
|
||||
|
||||
module QueryBillingSubscriptions
|
||||
def self.plan_tier(np_id)
|
||||
sub = Qx.fetch(:billing_subscriptions, nonprofit_id: np_id).last
|
||||
return 2 if sub && sub['status'] != 'inactive'
|
||||
|
||||
0
|
||||
end
|
||||
end
|
|
@ -1,28 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
require 'rails_helper'
|
||||
require 'insert/insert_billing_subscriptions'
|
||||
require 'query/query_billing_subscriptions'
|
||||
|
||||
describe QueryBillingSubscriptions, pending: true do
|
||||
before(:each) do
|
||||
end
|
||||
|
||||
describe '.plan_tier' do
|
||||
it 'gives tier 0 if status=inactive' do
|
||||
Qx.update(:billing_subscriptions).set(status: 'inactive').where('id = $id', id: @sub['id']).execute
|
||||
expect(QueryBillingSubscriptions.plan_tier(3624)).to eq(0)
|
||||
raise
|
||||
end
|
||||
it 'gives tier 0 if no subscription' do
|
||||
expect(QueryBillingSubscriptions.plan_tier(666)).to eq(0)
|
||||
raise
|
||||
end
|
||||
it 'gives tier 2 if status=active' do
|
||||
Qx.update(:billing_subscriptions).set(status: 'active').where('id = $id', id: @sub['id']).execute
|
||||
expect(QueryBillingSubscriptions.plan_tier(3624)).to eq(2)
|
||||
raise
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue