When registering a new enterprise, if user is signed in, owns a hub and is not making a producer, the new enterprise becomes a hub

This commit is contained in:
Rohan Mitchell
2015-03-27 14:05:58 +11:00
parent d471368412
commit 0ed1eeffd6
2 changed files with 16 additions and 1 deletions

View File

@@ -63,7 +63,9 @@ module Api
end
def override_sells
params[:enterprise][:sells] = 'unspecified'
has_hub = current_api_user.enterprises.is_hub.any?
new_enterprise_is_producer = !!params[:enterprise][:is_primary_producer]
params[:enterprise][:sells] = (has_hub && !new_enterprise_is_producer) ? 'any' : 'unspecified'
end
def override_visible