2016-02-09 12:06:55 -05:00
|
|
|
class Projects::PagesController < Projects::ApplicationController
|
|
|
|
layout 'project_settings'
|
|
|
|
|
2017-04-06 23:27:35 -04:00
|
|
|
before_action :require_pages_enabled!
|
2016-02-19 09:11:26 -05:00
|
|
|
before_action :authorize_read_pages!, only: [:show]
|
|
|
|
before_action :authorize_update_pages!, except: [:show]
|
2016-02-10 09:06:31 -05:00
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-02-09 12:06:55 -05:00
|
|
|
def show
|
2016-02-14 15:22:44 -05:00
|
|
|
@domains = @project.pages_domains.order(:domain)
|
2016-02-09 12:06:55 -05:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-02-09 12:06:55 -05:00
|
|
|
|
2016-02-10 09:06:31 -05:00
|
|
|
def destroy
|
2016-02-10 10:21:39 -05:00
|
|
|
project.remove_pages
|
2018-08-16 08:46:40 -04:00
|
|
|
project.pages_domains.destroy_all # rubocop: disable DestroyAll
|
2016-02-14 13:58:45 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to project_pages_path(@project),
|
2017-06-06 18:45:16 -04:00
|
|
|
status: 302,
|
|
|
|
notice: 'Pages were removed'
|
2016-02-14 13:58:45 -05:00
|
|
|
end
|
|
|
|
end
|
2016-02-10 10:21:39 -05:00
|
|
|
end
|
2018-01-03 03:07:03 -05:00
|
|
|
|
|
|
|
def update
|
|
|
|
result = Projects::UpdateService.new(@project, current_user, project_params).execute
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
if result[:status] == :success
|
|
|
|
flash[:notice] = 'Your changes have been saved'
|
|
|
|
else
|
|
|
|
flash[:alert] = 'Something went wrong on our end'
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to project_pages_path(@project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_params
|
|
|
|
params.require(:project).permit(:pages_https_only)
|
|
|
|
end
|
2016-02-09 12:06:55 -05:00
|
|
|
end
|