2018-09-26 03:45:43 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-09 17:06:55 +00:00
|
|
|
class Projects::PagesController < Projects::ApplicationController
|
|
|
|
layout 'project_settings'
|
|
|
|
|
2017-04-07 03:27:35 +00:00
|
|
|
before_action :require_pages_enabled!
|
2016-02-19 14:11:26 +00:00
|
|
|
before_action :authorize_read_pages!, only: [:show]
|
2019-02-25 11:43:19 +00:00
|
|
|
before_action :authorize_update_pages!, except: [:show, :destroy]
|
|
|
|
before_action :authorize_remove_pages!, only: [:destroy]
|
2016-02-10 14:06:31 +00:00
|
|
|
|
2020-10-08 18:08:32 +00:00
|
|
|
feature_category :pages
|
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-02-09 17:06:55 +00:00
|
|
|
def show
|
2020-04-14 21:09:52 +00:00
|
|
|
@domains = @project.pages_domains.order(:domain).present(current_user: current_user)
|
2016-02-09 17:06:55 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-02-09 17:06:55 +00:00
|
|
|
|
2016-02-10 14:06:31 +00:00
|
|
|
def destroy
|
2019-12-09 09:08:00 +00:00
|
|
|
::Pages::DeleteService.new(@project, current_user).execute
|
2016-02-14 18:58:45 +00:00
|
|
|
|
|
|
|
respond_to do |format|
|
2019-01-16 12:09:29 +00:00
|
|
|
format.html do
|
2017-06-29 17:06:35 +00:00
|
|
|
redirect_to project_pages_path(@project),
|
2019-11-17 12:06:19 +00:00
|
|
|
status: :found,
|
2020-08-26 00:10:31 +00:00
|
|
|
notice: 'Pages were scheduled for removal'
|
2016-02-14 18:58:45 +00:00
|
|
|
end
|
|
|
|
end
|
2016-02-10 15:21:39 +00:00
|
|
|
end
|
2018-01-03 08:07:03 +00: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
|
2019-12-20 09:24:38 +00:00
|
|
|
flash[:alert] = result[:message]
|
2018-01-03 08:07:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to project_pages_path(@project)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def project_params
|
2019-12-20 09:24:38 +00:00
|
|
|
params.require(:project).permit(project_params_attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_params_attributes
|
|
|
|
%i[pages_https_only]
|
2018-01-03 08:07:03 +00:00
|
|
|
end
|
2016-02-09 17:06:55 +00:00
|
|
|
end
|
2019-12-20 09:24:38 +00:00
|
|
|
|
|
|
|
Projects::PagesController.prepend_if_ee('EE::Projects::PagesController')
|