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
35a63a90
Commit
35a63a90
authored
Jul 20, 2017
by
Chrysanthi Lagodimou
Browse files
add seeking clients? instance method
parent
47f48efd
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/volunteers_controller.rb
View file @
35a63a90
...
...
@@ -48,7 +48,7 @@ class VolunteersController < ApplicationController
end
def
seeking_clients
@q
=
Volunteer
.
seeking_clients
.
ransack
(
params
[
:q
])
@q
=
Volunteer
.
where
(
state:
Volunteer
::
SEEKING_CLIENTS
)
.
ransack
(
params
[
:q
])
@seeking_clients
=
@q
.
result
end
...
...
app/models/volunteer.rb
View file @
35a63a90
...
...
@@ -31,6 +31,7 @@ class Volunteer < ApplicationRecord
STATES_FOR_REVIEWED
=
[
CONTACTED
,
ACTIVE
,
ACCEPTED
,
ACTIVE_FURTHER
,
REJECTED
,
RESIGNED
,
INACTIVE
].
freeze
SEEKING_CLIENTS
=
[
ACCEPTED
,
ACTIVE_FURTHER
,
INACTIVE
].
freeze
STATES
=
[
REGISTERED
]
+
STATES_FOR_REVIEWED
has_many
:assignments
...
...
@@ -98,7 +99,11 @@ class Volunteer < ApplicationRecord
end
def
self
.
seeking_clients
Volunteer
.
where
(
state:
[
Volunteer
::
ACCEPTED
,
Volunteer
::
ACTIVE_FURTHER
,
Volunteer
::
INACTIVE
])
Volunteer
.
where
(
state:
SEEKING_CLIENTS
)
end
def
seeking_clients?
SEEKING_CLIENTS
.
include?
(
state
)
end
private
...
...
app/views/volunteers/show.html.slim
View file @
35a63a90
...
...
@@ -2,7 +2,7 @@
.col-xs-12
h1
=
@volunteer
.
contact
.
full_name
-
if
V
olunteer
.
seeking_clients
.
include?
(
@volunteer
)
-
if
@v
olunteer
.
seeking_clients
?
.row
.col-xs-12
=
button_link
t_title
(
:new
,
Assignment
),
new_assignment_path
(
volunteer_id:
@volunteer
)
...
...
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