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:
parent
d2b5ec1770
commit
bc17f210a6
14 changed files with 208 additions and 73 deletions
33
app/controllers/admin/conference_domains_controller.rb
Normal file
33
app/controllers/admin/conference_domains_controller.rb
Normal 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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class AdminAbility
|
|||
track_ids = Track.joins(:program).where('programs.conference_id IN (?)', conf_ids).pluck(:id)
|
||||
|
||||
can :manage, Resource, conference_id: conf_ids
|
||||
can [:read, :update, :destroy, :custom_domin], Conference, id: conf_ids
|
||||
can [:read, :update, :destroy], Conference, id: conf_ids
|
||||
can :manage, Splashpage, conference_id: conf_ids
|
||||
can :manage, Contact, conference_id: conf_ids
|
||||
can :manage, EmailSettings, conference_id: conf_ids
|
||||
|
|
|
|||
|
|
@ -92,28 +92,6 @@ class Conference < ActiveRecord::Base
|
|||
user.present? && registrations.where(user_id: user.id).count > 0
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if domain correctly points to the hosted version
|
||||
# This feature is enabled only if ENV['OSEM_HOSTNAME'] is present
|
||||
#
|
||||
# ====Returns
|
||||
# * +true+ -> If the custom domain has a CNAME record for the hosted version
|
||||
# * +false+ -> If the custom domain does not have a CNAME record for the hosted version
|
||||
def check_custom_domain
|
||||
require 'resolv'
|
||||
|
||||
unless ENV['OSEM_HOSTNAME'].nil?
|
||||
cname_record = Resolv::DNS.new.getresources(custom_domain, Resolv::DNS::Resource::IN::CNAME)
|
||||
if cname_record.present?
|
||||
return ENV['OSEM_HOSTNAME'] == Resolv::DNS.new.getresources(custom_domain, Resolv::DNS::Resource::IN::CNAME).first.name.to_s
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
'--feature disabled--'
|
||||
end
|
||||
|
||||
##
|
||||
# Delete all EventSchedules that are not in the hours range
|
||||
# After the conference has been successfully updated
|
||||
|
|
|
|||
27
app/services/conference_domains_service.rb
Normal file
27
app/services/conference_domains_service.rb
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
class ConferenceDomainsService
|
||||
def initialize(params)
|
||||
@conference = params[:conference]
|
||||
end
|
||||
|
||||
##
|
||||
# Checks if domain correctly points to the hosted version
|
||||
# This feature is enabled only if ENV['OSEM_HOSTNAME'] is present
|
||||
#
|
||||
# ====Returns
|
||||
# * +true+ -> If the custom domain has a CNAME record for the hosted version
|
||||
# * +false+ -> If the custom domain does not have a CNAME record for the hosted version
|
||||
def check_custom_domain
|
||||
require 'resolv'
|
||||
|
||||
unless ENV['OSEM_HOSTNAME'].nil?
|
||||
cname_record = Resolv::DNS.new.getresources(@conference.custom_domain, Resolv::DNS::Resource::IN::CNAME)
|
||||
if cname_record.present?
|
||||
return ENV['OSEM_HOSTNAME'] == Resolv::DNS.new.getresources(custom_domain, Resolv::DNS::Resource::IN::CNAME).first.name.to_s
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
'--feature disabled--'
|
||||
end
|
||||
end
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
Step 2:
|
||||
%p
|
||||
Enter your existing domain in the field below to point the domain to your conference splashpage.
|
||||
= semantic_form_for(@conference, url: update_domain_admin_conference_path(@conference.short_title)) do |f|
|
||||
= semantic_form_for(@conference, url: admin_conference_conference_domain_path(@conference.short_title)) do |f|
|
||||
= f.input :custom_domain, label: false
|
||||
= f.action :submit, button_html: { class: 'btn btn-primary', value: 'Attach this domain' }
|
||||
%h2
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
%td
|
||||
= @conference.custom_domain
|
||||
%td
|
||||
- ck_domain = @conference.check_custom_domain
|
||||
- ck_domain = ConferenceDomainsService.new(conference: @conference).check_custom_domain
|
||||
- if ck_domain == true
|
||||
%span.glyphicon.glyphicon-ok
|
||||
- elsif ck_domain == false
|
||||
|
|
@ -27,14 +27,14 @@
|
|||
= ck_domain
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', attach_custom_domain_admin_conference_path(@conference.short_title),
|
||||
= link_to 'Edit', admin_conference_conference_domains_edit_path(@conference.short_title),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
= link_to 'Delete', admin_conference_path(@conference.short_title),
|
||||
method: :delete, class: 'btn btn-danger'
|
||||
.row
|
||||
.col-md-9.text-right
|
||||
= link_to '#status-help', class: 'btn btn-default', "data-toggle"=>"collapse" do
|
||||
Help?
|
||||
Need Help?
|
||||
.row
|
||||
.col-md-12
|
||||
.collapse#status-help
|
||||
|
|
@ -42,7 +42,7 @@
|
|||
Instructions to add your own domain
|
||||
%hr
|
||||
%p
|
||||
When you created the conference, the conference splash page is available in the following domain:
|
||||
Normally, your conference's splash page is available at:
|
||||
%strong
|
||||
osem.io/conferences/#{@conference.short_title}
|
||||
%p
|
||||
|
|
@ -66,9 +66,13 @@
|
|||
%li
|
||||
Pick a domain you want to host your conference on from a domain registrar or register it with a domain registrar.
|
||||
%li
|
||||
Add your own domain name to OSEM ( link to conference/custom_domain#create ) and select the conference it should belong to.
|
||||
Add your own domain name to OSEM
|
||||
= link_to 'here', admin_conference_conference_domains_edit_path(id: @conference.short_title)
|
||||
%li
|
||||
The last step is adding a CNAME record in your registrar’s DNS Settings. Different registrars have different ways of adding a CNAME record. The following guides would help you setup a CNAME record depending upon the registrar of your domain. If it doesn’t, you probably should get in touch with your domain registrar and ask him how to register a CNAME record in their platform.
|
||||
The last step is adding a CNAME record in your registrar’s DNS Settings.
|
||||
Different registrars have different ways of adding a CNAME record.
|
||||
The following guides would help you setup a CNAME record depending upon the registrar of your domain.
|
||||
If it doesn’t, you probably should get in touch with your domain registrar and ask him how to register a CNAME record in their platform.
|
||||
%ul
|
||||
%li
|
||||
= link_to 'GoDaddy', 'https://in.godaddy.com/help/add-a-cname-record-19236'
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
Dashboard
|
||||
- if can? :edit, @conference
|
||||
%li
|
||||
= link_to(custom_domain_admin_conference_path(@conference.short_title)) do
|
||||
= link_to(admin_conference_conference_domain_path(@conference.short_title)) do
|
||||
%span.fa.fa-link
|
||||
Custom domain
|
||||
- if can? :show, @conference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue