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:
parent
0494f022d2
commit
7317fc1f9f
10 changed files with 100 additions and 79 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue