diff --git a/app.rb b/app.rb index 07204491..bbed199e 100644 --- a/app.rb +++ b/app.rb @@ -119,6 +119,12 @@ end post '/settings/create_child' do require_login + + if !current_site.plan_feature(:unlimited_site_creation) + flash[:error] = 'Cannot create a new site with your current plan, please become a supporter.' + redirect '/settings#sites' + end + site = Site.new site.parent_site_id = parent_site.id diff --git a/models/site.rb b/models/site.rb index fab067dc..43382e1f 100644 --- a/models/site.rb +++ b/models/site.rb @@ -920,9 +920,9 @@ class Site < Sequel::Model end def plan_type - return 'free' if values[:plan_type].nil? - return 'supporter' if values[:plan_type].match /^plan_/ - values[:plan_type] + return 'free' if owner.values[:plan_type].nil? + return 'supporter' if owner.values[:plan_type].match /^plan_/ + owner.values[:plan_type] end def latest_events(current_page=1, limit=10) diff --git a/tests/api_tests.rb b/tests/api_tests.rb index 16265269..16c8f421 100644 --- a/tests/api_tests.rb +++ b/tests/api_tests.rb @@ -251,5 +251,4 @@ end def res JSON.parse last_response.body, symbolize_names: true -end - +end \ No newline at end of file diff --git a/views/settings/account/sites.erb b/views/settings/account/sites.erb index 7345e916..39891aba 100644 --- a/views/settings/account/sites.erb +++ b/views/settings/account/sites.erb @@ -18,15 +18,19 @@
You can now create new sites that are linked to this account! All of your sites will share the free space you have available.
+<% if current_site.plan_feature(:unlimited_site_creation) %> +You can now create new sites that are linked to this account! All of your sites will share the free space you have available.
- \ No newline at end of file +Multiple site creation is only available for supporter accounts. Upgrade now!
+<% end %> \ No newline at end of file