Class: Ability

Inherits:
Object
  • Object
show all
Includes:
CanCan::Ability
Defined in:
app/models/ability.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Ability

Returns a new instance of Ability


3
4
5
6
7
8
# File 'app/models/ability.rb', line 3

def initialize(user)
  if user
    @user = user
    @user.roles.each { |role| send(role.name.downcase) }
  end
end

Instance Method Details

#adminObject


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'app/models/ability.rb', line 107

def admin
  standard
  
  can :destroy, AdoptionContact, organization: { id: @user.organization_id }
  can :export, AdoptionContact, organization: { id: @user.organization_id }
  can :bulk_action, AdoptionContact, organization: { id: @user.organization_id }

  can :destroy, FosterContact, organization: { id: @user.organization_id }
  can :export, FosterContact, organization: { id: @user.organization_id }
  can :bulk_action, FosterContact, organization: { id: @user.organization_id }
  
  can :destroy, Animal, organization: { id: @user.organization_id }
  can :export, Animal, organization: { id: @user.organization_id }
  can :bulk_action, Animal, organization: { id: @user.organization_id }
  
  can :destroy, AnimalColor, organization: { id: @user.organization_id }
  can :export, AnimalColor, organization: { id: @user.organization_id }
  can :bulk_action, AnimalColor, organization: { id: @user.organization_id }

  can :destroy, AnimalWeight, organization: { id: @user.organization_id }
  can :export, AnimalWeight, organization: { id: @user.organization_id }
  can :bulk_action, AnimalWeight, organization: { id: @user.organization_id }

  can :update, Organization, :id => @user.organization_id
  can :export, Organization, :id => @user.organization_id
  can :destroy, Organization, id: @user.organization_id

  can :destroy, RelinquishmentContact, organization: { id: @user.organization_id }
  can :export, RelinquishmentContact, organization: { id: @user.organization_id }
  can :bulk_action, RelinquishmentContact, organization: { id: @user.organization_id }

  can :destroy, Shelter, organization: { id: @user.organization_id }
  can :export, Shelter, organization: { id: @user.organization_id }
  can :bulk_action, Shelter, organization: { id: @user.organization_id }

  can :destroy, Species, organization: { id: @user.organization_id }
  can :export, Species, organization: { id: @user.organization_id }
  can :bulk_action, Species, organization: { id: @user.organization_id }

  can :create, User
  can :update, User, organization: { id: @user.organization_id }
  can :export, User, organization: { id: @user.organization_id }
  can :destroy, User, organization: { id: @user.organization_id }
  can :cancel, User, organization: { id: @user.organization_id }
  can :set_role, User, organization: { id: @user.organization_id }
  can :bulk_action, User, organization: { id: @user.organization_id }

  can :destroy, VetContact, organization: { id: @user.organization_id }
  can :export, VetContact, organization: { id: @user.organization_id }
  can :bulk_action, VetContact, organization: { id: @user.organization_id }

  can :destroy, VolunteerContact, organization: { id: @user.organization_id }
  can :export, VolunteerContact, organization: { id: @user.organization_id }
  can :bulk_action, VolunteerContact, organization: { id: @user.organization_id }
  
  can :destroy, Status, organization: { id: @user.organization_id }
  can :bulk_action, Status, organization: { id: @user.organization_id }
end

#standardObject


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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/models/ability.rb', line 10

def standard
  
  can :manage, :twitter_account

  can :read, AdoptAnimal, animal: { organization: { id: @user.organization_id } }
  can :create, AdoptAnimal, animal: { organization: { id: @user.organization_id } }
  can :destroy, AdoptAnimal, animal: { organization: { id: @user.organization_id } }

  can :read, AdoptionContact, organization: { id: @user.organization_id }
  can :create, AdoptionContact
  can :update, AdoptionContact, organization: { id: @user.organization_id }

  can :read, FosterAnimal, animal: { organization: { id: @user.organization_id } }
  can :create, FosterAnimal, animal: { organization: { id: @user.organization_id } }
  can :destroy, FosterAnimal, animal: { organization: { id: @user.organization_id } }

  can :read, FosterContact, organization: { id: @user.organization_id }
  can :create, FosterContact
  can :update, FosterContact, organization: { id: @user.organization_id }

  can :read, Animal, organization: { id: @user.organization_id }
  can :create, Animal
  can :update, Animal, organization: { id: @user.organization_id }
  can :duplicate, Animal, organization: { id: @user.organization_id }
  can :qr_code, Animal, organization: { id: @user.organization_id }
  can :cage_card, Animal, organization: { id: @user.organization_id }
  can :add_image, Animal, organization: { id: @user.organization_id }

  can :read, AnimalColor, organization: { id: @user.organization_id }
  can :create, AnimalColor
  can :update, AnimalColor, organization: { id: @user.organization_id }

  can :read, AnimalWeight, organization: { id: @user.organization_id }
  can :create, AnimalWeight
  can :update, AnimalWeight, organization: { id: @user.organization_id }
  
  can :read, Note, animal: { organization: { id: @user.organization_id } }
  can :create, Note, animal: { organization: { id: @user.organization_id } }
  can :update, Note, animal: { organization: { id: @user.organization_id } }
  can :destroy, Note, animal: { organization: { id: @user.organization_id } }
  
  # can :read, Document, documentable: { organization: { id: @user.organization_id } }
  can :read, Document, organization: { id: @user.organization_id }
  # can :create, Document, documentable: { organization: { id: @user.organization_id } }
  can :create, Document, organization_id: @user.organization_id
  # can :update, Document, documentable: { organization: { id: @user.organization_id } }
  can :update, Document, organization: { id: @user.organization_id }
  # can :destroy, Document, documentable: { organization: { id: @user.organization_id } }
  can :destroy, Document, organization: { id: @user.organization_id }

  can :read, Organization, :id => @user.organization_id

  can :read, RelinquishAnimal, animal: { organization: { id: @user.organization_id } }
  can :create, RelinquishAnimal, animal: { organization: { id: @user.organization_id } }
  can :destroy, RelinquishAnimal, animal: { organization: { id: @user.organization_id } }

  can :read, RelinquishmentContact, organization: { id: @user.organization_id }
  can :create, RelinquishmentContact
  can :update, RelinquishmentContact, organization: { id: @user.organization_id }

  can :read, Shelter, organization: { id: @user.organization_id }
  can :create, Shelter
  can :update, Shelter, organization: { id: @user.organization_id }

  can :read, Species, organization: { id: @user.organization_id }
  can :create, Species
  can :update, Species, organization: { id: @user.organization_id }

  # hack for one user who locked themselves out
  can :create, User
  can :read, User, organization: { id: @user.organization_id }
  can :update, User, :id => @user.id
  can :reset_token, User, :id => @user.id

  can :read, VetContact, organization: { id: @user.organization_id }
  can :create, VetContact
  can :update, VetContact, organization: { id: @user.organization_id }

  can :read, VolunteerContact, organization: { id: @user.organization_id }
  can :create, VolunteerContact
  can :update, VolunteerContact, organization: { id: @user.organization_id }

  can :read, Status, organization: { id: @user.organization_id }
  can :create, Status
  can :update, Status, organization: { id: @user.organization_id }
  can :export, Status, organization: { id: @user.organization_id }

  can :read, Shot, organization: { id: @user.organization_id }
  can :create, Shot
  can :update, Shot, organization: { id: @user.organization_id }
  can :destroy, Shot, organization: { id: @user.organization_id }
  
  can :read, AnimalSex
  can :read, SpayNeuter
  can :read, Biter
end

#super_adminObject


166
167
168
# File 'app/models/ability.rb', line 166

def super_admin
  can :manage, :all
end

#superadminObject


170
171
172
# File 'app/models/ability.rb', line 170

def superadmin
  can :manage, :all
end