diff --git a/app/controllers/admin/conferences_controller.rb b/app/controllers/admin/conferences_controller.rb index c4239394..65def838 100644 --- a/app/controllers/admin/conferences_controller.rb +++ b/app/controllers/admin/conferences_controller.rb @@ -6,6 +6,19 @@ module Admin def custom_domain; 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 @@ -213,7 +226,7 @@ module Admin :vpositions_attributes, :use_volunteers, :color, :sponsorship_levels_attributes, :sponsors_attributes, :targets, :targets_attributes, - :campaigns, :campaigns_attributes, :registration_limit, :organization_id, :ticket_layout) + :campaigns, :campaigns_attributes, :registration_limit, :organization_id, :ticket_layout, :custom_domain) end end end diff --git a/app/views/admin/conferences/attach_custom_domain.html.haml b/app/views/admin/conferences/attach_custom_domain.html.haml new file mode 100644 index 00000000..42d91bbc --- /dev/null +++ b/app/views/admin/conferences/attach_custom_domain.html.haml @@ -0,0 +1,41 @@ +.row + .col-md-12 + %h1 + Custom Domain + %p.text-muted + Point your own domain to #{@conference.title} +%hr +.row + .col-md-12 + %h2 + Step 1: + %strong + Unfortunately, we can't do this for you and you have to perform this step with the help your domain registrar! + %p + Pick a domain you want to host your conference on from a domain registrar or register it with a domain registrar. + %h2 + 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| + = f.input :custom_domain, label: false + = f.action :submit, button_html: { class: 'btn btn-primary', value: 'Attach this domain' } + %h2 + Step 3: + %strong + Unfortunately, we can't do this for you and you have to perform this step with the help your domain registrar! + %p + 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' + %li + = link_to 'Namecheap', 'https://www.namecheap.com/support/knowledgebase/article.aspx/9646/2237/how-can-i-set-up-a-cname-record-for-my-domain' + %li + = link_to 'BlueHost', 'https://my.bluehost.com/cgi/help/cname#creating_a_cname' + %li + = link_to '12-reg.co.uk', 'https://www.123-reg.co.uk/support/answers/Domains/Domain-Configuration/how-do-i-set-up-a-cname-record-on-my-domain-name-1198/' + %li + = link_to '1&1', 'https://help.1and1.com/domains-c36931/manage-domains-c79822/dns-c37586/enter-a-cname-for-your-subdomain-a643600.html' + .well.well-lg + It might take upto 24-48 hours depending upon your registrar to update your DNS Settings. diff --git a/app/views/admin/conferences/custom_domain.html.haml b/app/views/admin/conferences/custom_domain.html.haml index 7eb9d85a..17316550 100644 --- a/app/views/admin/conferences/custom_domain.html.haml +++ b/app/views/admin/conferences/custom_domain.html.haml @@ -20,9 +20,9 @@ = "" %td .btn-group - = link_to 'Edit', edit_admin_conference_path(@conference), + = link_to 'Edit', attach_custom_domain_admin_conference_path(@conference.short_title), method: :get, class: 'btn btn-primary' - = link_to 'Delete', admin_conference_path(@conference), + = link_to 'Delete', admin_conference_path(@conference.short_title), method: :delete, class: 'btn btn-danger' .row .col-md-9.text-right @@ -71,6 +71,5 @@ = link_to 'BlueHost', 'https://my.bluehost.com/cgi/help/cname#creating_a_cname' %li = link_to '12-reg.co.uk', 'https://www.123-reg.co.uk/support/answers/Domains/Domain-Configuration/how-do-i-set-up-a-cname-record-on-my-domain-name-1198/' - - - + %li + = link_to '1&1', 'https://help.1and1.com/domains-c36931/manage-domains-c79822/dns-c37586/enter-a-cname-for-your-subdomain-a643600.html' diff --git a/config/routes.rb b/config/routes.rb index 380d9d43..eca3f968 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,8 @@ Osem::Application.routes.draw do resources :conferences do member do get :custom_domain + get :attach_custom_domain + patch :update_domain end resource :contact, except: [:index, :new, :create, :show, :destroy] resources :schedules, only: [:index, :create, :show, :update, :destroy] diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 009e40ba..9019f250 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -135,6 +135,15 @@ describe Admin::ConferencesController do end end end + + describe 'GET #custom_domain', blah: true do + it 'render custom domain' do + get :custom_domain, id: conference.short_title + + expect(response).to render_template :custom_domain + expect(response).to be_success + end + end end shared_examples 'access as organization_admin' do