Class: Decidim::Feeds::Permissions

Inherits:
DefaultPermissions
  • Object
show all
Defined in:
app/permissions/decidim/feeds/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
# File 'app/permissions/decidim/feeds/permissions.rb', line 6

def permissions
  return permission_action unless user

  case permission_action.subject
  when :feed
    case permission_action.action
      when :read
        allow! if user.present?
      when :create
        allow! if user.present? # TODO: maybe add a max number of feeds per user
      when :update
        allow! if can_update?
      when :list
        allow! if user.present?
      end
  when :feed_list
    case permission_action.action
      when :read
        allow! if user.admin?
      end
  when :participatory_space
    case permission_action.action
      when :read
        allow! if user.present?
      end
  when :component
    case permission_action.action
      when :read
        allow! if user.present?
      end
  end

  permission_action
end