]> git.openstreetmap.org Git - rails.git/blob - app/controllers/acls_controller.rb
Merge remote-tracking branch 'upstream/pull/7375'
[rails.git] / app / controllers / acls_controller.rb
1 # frozen_string_literal: true
2
3 class AclsController < ApplicationController
4   include PaginationMethods
5
6   layout :site_layout
7
8   before_action :authorize_web
9   before_action :set_locale
10
11   authorize_resource
12
13   before_action :check_database_readable
14   before_action :check_database_writable, :except => [:index]
15   before_action :set_acl, :only => [:edit, :update, :destroy]
16
17   def index
18     @params = params.permit(:before, :after)
19     @acls = get_page_items(Acl.all)
20   end
21
22   def new
23     @acl = Acl.new
24   end
25
26   def edit; end
27
28   def create
29     @acl = Acl.new(acl_params)
30
31     if @acl.save
32       redirect_to acls_path, :notice => t(".success")
33     else
34       render :new, :status => :unprocessable_content
35     end
36   end
37
38   def update
39     if @acl.update(acl_params)
40       redirect_to acls_path, :notice => t(".success"), :status => :see_other
41     else
42       render :edit, :status => :unprocessable_content
43     end
44   end
45
46   def destroy
47     @acl.destroy
48     redirect_to acls_path, :notice => t(".success"), :status => :see_other
49   end
50
51   private
52
53   def set_acl
54     @acl = Acl.find(params.expect(:id))
55   end
56
57   def acl_params
58     params.expect(:acl => [:address, :domain, :mx, :k, :v])
59   end
60 end