suggested changes that includes:

moving actions for custom domain in its own controller
use separate service class for custom domains
updated help text for custom domains
increased test coverage for custom domains
This commit is contained in:
shlok007 2017-08-19 13:57:09 +05:30
parent d2b5ec1770
commit bc17f210a6
14 changed files with 208 additions and 73 deletions

View file

@ -0,0 +1,33 @@
module Admin
class ConferenceDomainsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
def show
# To only allow organizers, organization admin and site administrators
authorize! :update, @conference
redirect_to admin_conference_conference_domains_edit_path(@conference.short_title) unless @conference.custom_domain.present?
end
def edit
authorize! :edit, @conference
end
def update
authorize! :update, @conference
@conference.assign_attributes(conference_params)
if @conference.save
redirect_to admin_conference_conference_domain_path(@conference.short_title),
notice: 'Attached new domain name to conference. This does not mean that the new domain should work. Please make sure you follow step 3 to point your domain to this hosted version'
else
redirect_to admin_conference_conference_domains_edit_path(@conference.short_title),
notice: 'Failed to add the new domain as custom domain to the conference'
end
end
private
def conference_params
params.require(:conference).permit(:custom_domain)
end
end
end

View file

@ -4,23 +4,6 @@ module Admin
load_resource :program, through: :conference, singleton: true, except: :index
load_resource :user, only: [:remove_user]
def custom_domain
redirect_to attach_custom_domain_admin_conference_path(@conference.short_title) unless @conference.custom_domain.present?
end
def attach_custom_domain; end
def update_domain
@conference.assign_attributes(conference_params)
if @conference.save
redirect_to custom_domain_admin_conference_path(id: @conference.short_title),
notice: 'Added new domain name to conference. This does not mean that the new domain should work. Please make sure you follow step 2 to point your domain to this hosted version'
else
redirect_to custom_domain_admin_conference_path(id: @conference.short_title),
notice: 'Failed to add the new domain as custom domain to the conference'
end
end
def index
# Redirect to new form if there is no conference
if Conference.count == 0