Class: Decidim::Posts::Permissions

Inherits:
DefaultPermissions
  • Object
show all
Defined in:
app/permissions/decidim/posts/permissions.rb

Instance Method Summary collapse

Instance Method Details

#permissionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/permissions/decidim/posts/permissions.rb', line 6

def permissions
  return permission_action unless user

  case permission_action.subject
  when :post
    case permission_action.action
    when :create
      allow! if can_create_posts?
    when :edit
      allow! if can_update_post?
    when :delete
      allow! if can_delete_post?
    when :read
      allow! if can_access?
    when :change_post_status
      allow! if change_post_status?
    end
  when :meeting
    case permission_action.action
    when :create
      allow! if can_create_posts?
    when :update
      allow! if can_update_meeting?
    when :withdraw
      allow! if can_withdraw_meeting?
    end
  when :reaction
    case permission_action.action
    when :create
      allow! if can_access?
    when :withdraw
      allow! if can_access?
    end
  end

  permission_action
end