gitlab-org--gitlab-foss/app/controllers/projects/pages_controller.rb

51 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-02-09 12:06:55 -05:00
class Projects::PagesController < Projects::ApplicationController
layout 'project_settings'
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]
# rubocop: disable CodeReuse/ActiveRecord
2016-02-09 12:06:55 -05:00
def show
@domains = @project.pages_domains.order(:domain)
2016-02-09 12:06:55 -05:00
end
# rubocop: enable CodeReuse/ActiveRecord
2016-02-09 12:06:55 -05:00
def destroy
2016-02-10 10:21:39 -05:00
project.remove_pages
project.pages_domains.destroy_all # rubocop: disable DestroyAll
2016-02-14 13:58:45 -05:00
respond_to do |format|
format.html do
redirect_to project_pages_path(@project),
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