Changed views and routes

used sigular resource for routes
added destroy action in custom domains
made instructions in 'edit/new' and 'show' visually similar
added new action and view for custom domain
This commit is contained in:
shlok007 2017-09-03 15:56:06 +05:30
parent 0494f022d2
commit 7317fc1f9f
10 changed files with 100 additions and 79 deletions

View file

@ -22,7 +22,7 @@ linters:
- "app/views/admin/comments/_posted_comments.html.haml"
- "app/views/admin/comments/_unread_comments.html.haml"
- "app/views/admin/commercials/index.html.haml"
- "app/views/admin/conference_domains/edit.haml"
- "app/views/admin/conference_domains/_form.haml"
- "app/views/admin/conference_domains/show.haml"
- "app/views/admin/conferences/_campaigns.html.haml"
- "app/views/admin/conferences/_doughnut_chart.html.haml"

View file

@ -1,26 +1,43 @@
module Admin
class ConferenceDomainsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_resource :conference, find_by: :short_title
def new
# To only allow organizers, organization admin and site administrators
authorize! :update, @conference
end
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?
redirect_to new_admin_conference_domain_path(@conference.short_title) unless @conference.custom_domain.present?
end
def edit
authorize! :edit, @conference
authorize! :update, @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),
redirect_to admin_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'
redirect_to edit_admin_conference_domain_path(@conference.short_title),
error: 'Failed to add the new domain as custom domain to the conference'
end
end
def destroy
authorize! :update, @conference
@conference.custom_domain = nil
if @conference.save
redirect_to new_admin_conference_domain_path(@conference.short_title),
notice: 'Custom domain successfully removed from conference'
else
redirect_to admin_conference_domain_path(@conference.short_title),
error: 'Failed o remove custom domain from the conference'
end
end

View file

@ -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: admin_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
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 registrars 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 doesnt, 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.

View file

@ -1,41 +1 @@
.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: 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
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 registrars 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 doesnt, 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.
= render 'form', conference: @conference

View file

@ -0,0 +1 @@
= render 'form', conference: @conference

View file

@ -31,9 +31,9 @@
feature disabled
%td
.btn-group
= link_to 'Edit', admin_conference_conference_domains_edit_path(@conference.short_title),
= link_to 'Edit', edit_admin_conference_domain_path(@conference.short_title),
method: :get, class: 'btn btn-primary'
= link_to 'Delete', admin_conference_path(@conference.short_title),
= link_to 'Delete', admin_conference_domain_path(@conference.short_title),
method: :delete, class: 'btn btn-danger'
.row
.col-md-9.text-right
@ -66,25 +66,30 @@
%i
three
steps:
%ol
%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
Attach your existing domain to your conference by adding it in the new/edit domain name page of your conference. That domain name will point to the splashpage of your conference after completion of all steps.
%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 registrars 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 doesnt, you probably should get in touch with your domain registrar and ask him how to register a CNAME record in their platform.
%ul
%li
Pick a domain you want to host your conference on from a domain registrar or register it with a domain registrar.
= link_to 'GoDaddy', 'https://in.godaddy.com/help/add-a-cname-record-19236'
%li
Add your own domain name to OSEM
= link_to 'here', admin_conference_conference_domains_edit_path(@conference.short_title)
= 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
The last step is adding a CNAME record in your registrars 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 doesnt, 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'
= 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'

View file

@ -29,7 +29,7 @@
Dashboard
- if can? :edit, @conference
%li
= link_to(admin_conference_conference_domain_path(@conference.short_title)) do
= link_to(admin_conference_domain_path(@conference.short_title)) do
%span.fa.fa-link
Custom domain
- if can? :show, @conference

View file

@ -32,10 +32,7 @@ Osem::Application.routes.draw do
end
resources :comments, only: [:index]
resources :conferences do
get 'conference_domains/edit' => 'conference_domains#edit'
get 'conference_domain' => 'conference_domains#show'
patch 'conference_domain' => 'conference_domains#update'
resource :domain, controller: 'conference_domains'
resource :contact, except: [:index, :new, :create, :show, :destroy]
resources :schedules, only: [:index, :create, :show, :update, :destroy]
resources :event_schedules, only: [:create, :update, :destroy]

View file

@ -11,7 +11,7 @@ describe Admin::ConferenceDomainsController do
describe 'GET #show' do
it 'redirects to edit if custom domain is not present' do
get :show, conference_id: conference.short_title
expect(response).to redirect_to(admin_conference_conference_domains_edit_path)
expect(response).to redirect_to(edit_admin_conference_domain_path)
end
it 'renders correct template if custom domain is present' do

View file

@ -15,7 +15,7 @@ feature Conference do
shared_examples 'successfully adds, update or show custom domain' do
scenario 'adds or update custom domain of a conference', feature: true, js: true do
visit admin_conference_conference_domains_edit_path(conference.short_title)
visit edit_admin_conference_domain_path(conference.short_title)
fill_in 'conference_custom_domain', with: 'newdomain.conf'
click_button 'Attach this domain'
@ -25,7 +25,7 @@ feature Conference do
end
scenario 'show custom domain of a conference', feature: true, js: true do
visit admin_conference_conference_domain_path(conference.short_title)
visit admin_conference_domain_path(conference.short_title)
expect(page).to have_text('mydomain.conf')
end
@ -33,13 +33,13 @@ feature Conference do
shared_examples 'does not add, update or show custom domain' do
scenario 'does not add or update custom domain', feature: true, js: true do
visit admin_conference_conference_domains_edit_path(conference.short_title)
visit edit_admin_conference_domain_path(conference.short_title)
expect(flash).to eq 'You are not authorized to access this page.'
end
scenario 'does not show custom domain of a conference', feature: true, js: true do
visit admin_conference_conference_domain_path(conference.short_title)
visit admin_conference_domain_path(conference.short_title)
expect(flash).to eq 'You are not authorized to access this page.'
end