Read about our upcoming Code of Conduct on this issue

pages_controller.rb 1.08 KB
Newer Older
1
2
3
class Projects::PagesController < Projects::ApplicationController
  layout 'project_settings'

4
  before_action :require_pages_enabled!
Kamil Trzcinski's avatar
Kamil Trzcinski committed
5
6
  before_action :authorize_read_pages!, only: [:show]
  before_action :authorize_update_pages!, except: [:show]
7

8
  def show
9
    @domains = @project.pages_domains.order(:domain)
10
11
  end

12
  def destroy
Kamil Trzcinski's avatar
Kamil Trzcinski committed
13
14
    project.remove_pages
    project.pages_domains.destroy_all
Kamil Trzcinski's avatar
Kamil Trzcinski committed
15
16
17

    respond_to do |format|
      format.html  do
18
        redirect_to project_pages_path(@project),
19
20
                    status: 302,
                    notice: 'Pages were removed'
Kamil Trzcinski's avatar
Kamil Trzcinski committed
21
22
      end
    end
Kamil Trzcinski's avatar
Kamil Trzcinski committed
23
  end
Rob Watson's avatar
Rob Watson committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

  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
46
end