Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
6e8d75f1
Commit
6e8d75f1
authored
Aug 23, 2017
by
Chrysanthi Lagodimou
Browse files
policies
parent
c5cc0b40
Changes
8
Hide whitespace changes
Inline
Side-by-side
app/policies/application_policy.rb
View file @
6e8d75f1
...
...
@@ -40,7 +40,7 @@ class ApplicationPolicy
end
def
volunteer_related?
record
.
volunteer
.
user_id
==
user
.
id
volunteer?
&&
record
.
volunteer
.
user_id
==
user
.
id
end
def
superadmin_or_record_owner?
...
...
@@ -60,7 +60,7 @@ class ApplicationPolicy
end
def
superadmin_or_volunteer_related?
superadmin?
||
volunteer?
&&
volunteer_related?
superadmin?
||
volunteer_related?
end
alias_method
:index?
,
:deny_all!
...
...
app/policies/hour_policy.rb
View file @
6e8d75f1
...
...
@@ -7,9 +7,9 @@ class HourPolicy < ApplicationPolicy
alias_method
:index?
,
:superadmin?
alias_method
:show?
,
:superadmin_or_volunteer_related?
alias_method
:new?
,
:
superadmin_or_
volunteer_related?
alias_method
:edit?
,
:
superadmin_or_
volunteer_related?
alias_method
:create?
,
:
superadmin_or_
volunteer_related?
alias_method
:update?
,
:
superadmin_or_
volunteer_related?
alias_method
:destroy?
,
:
superadmin
?
alias_method
:new?
,
:volunteer_related?
alias_method
:edit?
,
:volunteer_related?
alias_method
:create?
,
:volunteer_related?
alias_method
:update?
,
:volunteer_related?
alias_method
:destroy?
,
:
volunteer_related
?
end
app/views/application/_index_actions.html.slim
View file @
6e8d75f1
td
=
link_to
t_action
(
:show
),
subject
-
unless
controller_name
==
'hours'
td
=
link_to
t_action
(
:print
),
{
controller:
controller_name
,
action: :show
,
id:
subject
.
id
,
print:
'true'
},
target:
'_blank'
td
=
link_to
t_action
(
:print
),
{
controller:
controller_name
,
action: :show
,
id:
subject
.
id
,
print:
'true'
},
target:
'_blank'
-
if
[
'clients'
,
'volunteers'
].
include?
controller_name
td
=
link_to
t_model
(
Journal
),
{
controller:
'journals'
,
action:
'index'
,
"
#{
controller_name
.
singularize
}
_id"
:
subject
.
id
}
-
if
policy
(
subject
.
class
).
index?
...
...
app/views/hours/_hours_block.html.slim
View file @
6e8d75f1
...
...
@@ -3,7 +3,8 @@
table
.table.table-striped
thead
tr
th
=
t_model
(
Volunteer
)
-
if
policy
(
Hour
).
index?
th
=
t_model
(
Volunteer
)
th
=
t_model
(
Client
)
th
=
t_attr
(
:meeting_date
,
Hour
)
th
=
t_attr
(
:duration
,
Hour
)
...
...
@@ -13,3 +14,6 @@
tbody
=
render
hours
-
if
current_user
.
volunteer?
=
button_link
t_title
(
:new
,
Hour
),
new_hour_url
(
volunteer_id:
current_user
.
volunteer
.
id
)
app/views/hours/index.html.slim
View file @
6e8d75f1
...
...
@@ -3,5 +3,3 @@
h1
=
t_title
=
render
'hours_block'
,
hours:
@hours
=
form_navigation_btn
:new
app/views/hours/show.html.slim
View file @
6e8d75f1
...
...
@@ -3,9 +3,10 @@
.table-responsive
table
.table.table-no-border-top
tbody
tr
td
=
t_model
(
Volunteer
)
td
=
@hour
.
assignment
.
volunteer
.
contact
.
full_name
-
if
policy
(
Hour
).
index?
tr
td
=
t_model
(
Volunteer
)
td
=
@hour
.
assignment
.
volunteer
.
contact
.
full_name
tr
td
=
t_model
(
Client
)
td
=
@hour
.
assignment
.
client
.
contact
.
full_name
...
...
@@ -22,8 +23,8 @@
td
=
t_attr
(
:comments
)
td
=
@hour
.
comments
=
form_navigation_btn
:edit
-
if
policy
(
Hour
).
index?
=
form_navigation_btn
:back
-
else
=
form_navigation_btn
:edit
=
button_link
t_action
(
:back
),
volunteer_hours_volunteer_path
(
@hour
.
volunteer
)
app/views/volunteers/index.html.slim
View file @
6e8d75f1
...
...
@@ -5,6 +5,7 @@ nav.navbar.section-navigation
li
=
button_link
t_title
(
:new
),
new_volunteer_path
,
'success'
,
dimension:
'sm'
-
if
policy
(
Volunteer
).
destroy?
li
=
button_link
t
(
'seeking_clients'
),
seeking_clients_volunteers_url
,
dimension:
'sm'
li
=
button_link
t_title
(
:index
,
Hour
),
hours_path
,
dimension:
'sm'
li
|
li
=
button_link
t_model
(
VolunteerEmail
),
volunteer_emails_path
,
dimension:
'sm'
...
...
app/views/volunteers/show.html.slim
View file @
6e8d75f1
...
...
@@ -11,10 +11,10 @@
.col-xs-12.col-md-4
=
button_link
t_title
(
:new
,
Assignment
),
new_assignment_path
(
volunteer_id:
@volunteer
)
-
if
@volunteer
.
assignments
.
any?
.col-xs-12.col-md-4
=
button_link
t_title
(
:new
,
Hour
),
new_hour_url
(
volunteer_id:
@volunteer
)
.col-xs-12.col-md-4
=
button_link
t_title
(
:index
,
Hour
),
volunteer_hours_volunteer_path
(
@volunteer
)
.col-xs-12.col-md-4
=
button_link
t_title
(
:new
,
Hour
),
new_hour_url
(
volunteer_id:
@volunteer
)
-
if
policy
(
Volunteer
).
checklist?
h3
=
t
(
'checklist'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment