Commit 834b9a83 authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou
Browse files

without clients equivalent of need accompanying

parent 85831401
......@@ -47,6 +47,11 @@ class VolunteersController < ApplicationController
redirect_to volunteers_url, notice: t('volunteer_destroyed')
end
def without_clients
@q = Volunteer.without_clients.ransack(params[:q])
@without_clients = @q.result
end
private
def invite_volunteer_user
......
......@@ -42,6 +42,10 @@ class VolunteerPolicy < ApplicationPolicy
user.superadmin?
end
def without_clients?
user.superadmin?
end
private
def volunteers_owns_profile
......
.table-responsive
table.table.table-striped
thead
tr
th= sort_link @q, :contact_title
th= sort_link @q, :contact_last_name, t_attr(:full_name, Volunteer)
th= sort_link @q, :contact_city
th= sort_link @q, :contact_postal_code
th= sort_link @q, :contact_contact_emails_body
th= sort_link @q, :date_of_birth, t_attr(:birth_year, Volunteer)
th= sort_link @q, :language_skills_language, t_attr(:first_language, Volunteer)
th= t_attr(:languages, Volunteer)
th= sort_link @q, :education
th= sort_link @q, :profession
th= sort_link @q, :working_percent
th= sort_link @q, :expectations
th= sort_link @q, :interests
th= sort_link @q, :state
th colspan='4'
tbody
= render volunteers
......@@ -18,7 +18,8 @@ tr
= volunteer.registrar.full_name
- else
= t('volunteer_self_applicant')
td = link_to t_action(:show), volunteer
td = link_to t_model(Journal), { controller: 'journals', action: 'index', volunteer_id: volunteer.id }
td = link_to t_action(:edit), edit_volunteer_path(volunteer)
td = link_to t_action(:destroy), volunteer, confirm_deleting(volunteer)
- if params[:action] == 'index'
td = link_to t_action(:show), volunteer
td = link_to t_model(Journal), { controller: 'journals', action: 'index', volunteer_id: volunteer.id }
td = link_to t_action(:edit), edit_volunteer_path(volunteer)
td = link_to t_action(:destroy), volunteer, confirm_deleting(volunteer)
= render 'volunteer', volunteer: without_client
......@@ -5,27 +5,9 @@
.col-xs-6.col-md-4= form_navigation_btn :new, with_row: false
.col-xs-6.col-md-4.text-center= link_to t('volunteer_emails'), volunteer_emails_path, class: 'btn btn-default'
.col-xs-6.col-md-4.text-right= render 'state_select'
.table-responsive
table.table.table-striped
thead
tr
th= sort_link @q, :contact_title
th= sort_link @q, :contact_last_name, t_attr(:full_name, Volunteer)
th= sort_link @q, :contact_city
th= sort_link @q, :contact_postal_code
th= sort_link @q, :contact_contact_emails_body
th= sort_link @q, :date_of_birth, t_attr(:birth_year, Volunteer)
th= sort_link @q, :language_skills_language, t_attr(:first_language, Volunteer)
th= t_attr(:languages, Volunteer)
th= sort_link @q, :education
th= sort_link @q, :profession
th= sort_link @q, :working_percent
th= sort_link @q, :expectations
th= sort_link @q, :interests
th= sort_link @q, :state
th colspan='4'
tbody
= render @volunteers
= render 'columns', volunteers: @volunteers
= form_navigation_btn :new
- if policy(Volunteer).destroy?
= button_link t('without_clients'), without_clients_volunteers_url
.row
.col-xs-12
h1= t('without_clients')
= render 'columns', volunteers: @without_clients
......@@ -543,6 +543,7 @@ de:
tuesday: Dienstag
wednesday: Mittwoch
when: Zeit
without_clients: Ohne Klienten
working_days: Arbeitstage
your_region: In welcher Region können Sie sich Ihren Einsatz vorstellen?
add_journal_entry: Journal Eintrag verfassen
......
......@@ -387,6 +387,7 @@ en:
tuesday: Tuesday
wednesday: Wednesday
when: Time
without_clients: Without clients
working_days: Working days
your_expectations: What do you expect from a person who would accompany you / your volunteer work?
your_region: In which region can you imagine your employment?
......
......@@ -16,6 +16,7 @@ Rails.application.routes.draw do
end
resources :departments
resources :volunteers do
get :without_clients, on: :collection
resources :journals
end
resources :volunteer_emails
......
......@@ -18,4 +18,17 @@ class VolunteerTest < ActiveSupport::TestCase
new_volunteer = Volunteer.new
assert new_volunteer.contact.present?
end
test 'volunteers without clients' do
result = Volunteer.without_clients
assert_equal [@volunteer], result.to_a
end
test 'a volunteer with an assignment should not show up in without assignment' do
@client = create :client
@volunteer.create_assignment!(client: @client)
result = Volunteer.without_clients
assert_equal [], result.to_a
>>>>>>> without clients equivalent of need accompanying
end
end
......@@ -30,4 +30,16 @@ class VolunteerPolicyTest < PolicyAssertions::Test
refute_permit @department_manager, Volunteer, 'index?'
refute_permit @social_worker, Volunteer, 'index?'
end
test 'Without clients: superadmin can see volunteers without clients' do
assert_permit @superadmin, Volunteer, 'without_clients?'
end
test 'Without clients: social worker cannot see volunteers without clients' do
refute_permit @social_worker, Volunteer, 'without_clients?'
end
test 'Without clients: department manager cannot see volunteers without clients' do
refute_permit @department_manager, Volunteer, 'without_clients?'
end
end
Markdown is supported
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