Commit 35a63a90 authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou
Browse files

add seeking clients? instance method

parent 47f48efd
......@@ -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
......
......@@ -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
......
......@@ -2,7 +2,7 @@
.col-xs-12
h1= @volunteer.contact.full_name
- if Volunteer.seeking_clients.include?(@volunteer)
- if @volunteer.seeking_clients?
.row
.col-xs-12
= button_link t_title(:new, Assignment), new_assignment_path(volunteer_id: @volunteer)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment