]> git.openstreetmap.org Git - rails.git/blob - app/abilities/ability.rb
Fix styling of nested lists in rich text
[rails.git] / app / abilities / ability.rb
1 # frozen_string_literal: true
2
3 class Ability
4   include CanCan::Ability
5
6   def initialize(user)
7     can [:relation, :relation_history, :way, :way_history, :node, :node_history, :changeset, :note, :new_note], :browse
8     can [:index, :feed, :read, :download, :query], Changeset
9     can :index, ChangesetComment
10     can :search, :direction
11     can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :preview, :copyright, :key, :id], :site
12     can [:index, :rss, :show, :comments], DiaryEntry
13     can [:finish, :embed], :export
14     can [:search, :search_latlon, :search_ca_postcode, :search_osm_nominatim,
15          :search_geonames, :search_osm_nominatim_reverse, :search_geonames_reverse], :geocoder
16     can [:index, :create, :comment, :feed, :show, :search, :mine], Note
17     can [:index, :show], Redaction
18     can [:search_all, :search_nodes, :search_ways, :search_relations], :search
19     can [:trackpoints], :swf
20     can [:index, :show, :data, :georss, :picture, :icon], Trace
21     can [:terms, :api_users, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :api_read, :auth_success, :auth_failure], User
22     can [:index, :show, :blocks_on, :blocks_by], UserBlock
23
24     if user
25       can :welcome, :site
26       can [:index, :new, :create, :show, :edit, :update, :destroy], ClientApplication
27       can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
28       can [:new, :create, :reply, :show, :inbox, :outbox, :mark, :destroy], Message
29       can [:close, :reopen], Note
30       can [:new, :create], Report
31       can [:mine, :new, :create, :edit, :update, :delete, :api_create, :api_read, :api_update, :api_delete, :api_data], Trace
32       can [:account, :go_public, :make_friend, :remove_friend, :api_details, :api_gpx_files], User
33       can [:read, :read_one, :update, :update_one, :delete_one], UserPreference
34
35       if user.terms_agreed? || !REQUIRE_TERMS_AGREED
36         can [:create, :update, :upload, :close, :subscribe, :unsubscribe, :expand_bbox], Changeset
37         can :create, ChangesetComment
38       end
39
40       if user.moderator?
41         can [:destroy, :restore], ChangesetComment
42         can [:index, :show, :resolve, :ignore, :reopen], Issue
43         can :create, IssueComment
44         can :destroy, Note
45         can [:new, :create, :edit, :update, :destroy], Redaction
46         can [:new, :edit, :create, :update, :revoke], UserBlock
47       end
48
49       if user.administrator?
50         can [:hide, :hidecomment], [DiaryEntry, DiaryComment]
51         can [:index, :show, :resolve, :ignore, :reopen], Issue
52         can :create, IssueComment
53         can [:set_status, :delete, :index], User
54         can [:grant, :revoke], UserRole
55       end
56     end
57
58     # Define abilities for the passed in user here. For example:
59     #
60     #   user ||= User.new # guest user (not logged in)
61     #   if user.admin?
62     #     can :manage, :all
63     #   else
64     #     can :read, :all
65     #   end
66     #
67     # The first argument to `can` is the action you are giving the user
68     # permission to do.
69     # If you pass :manage it will apply to every action. Other common actions
70     # here are :read, :create, :update and :destroy.
71     #
72     # The second argument is the resource the user can perform the action on.
73     # If you pass :all it will apply to every resource. Otherwise pass a Ruby
74     # class of the resource.
75     #
76     # The third argument is an optional hash of conditions to further filter the
77     # objects.
78     # For example, here the user can only update published articles.
79     #
80     #   can :update, Article, :published => true
81     #
82     # See the wiki for details:
83     # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
84   end
85 end