Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Merge pull request #128 from vubo/signup
Browse files Browse the repository at this point in the history
Show all shifts except signed up
  • Loading branch information
tapaswenipathak committed Aug 17, 2015
2 parents c584c03 + 37f4d27 commit 0a16101
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions vms/shift/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,28 @@ def get_shifts_with_open_slots(j_id):
return shift_list


def get_shifts_with_open_slots_for_volunteer(j_id, v_id):
"""
Returns shifts with open slots
all except those for which the volunteer has signed up.
"""
shift_list_by_date = get_shifts_ordered_by_date(j_id)
shift_list = []

for shift in shift_list_by_date:
slots_remaining = get_shift_slots_remaining(shift.id)
if slots_remaining > 0 and not is_signed_up(v_id, shift.id):
shift_map = {}
shift_map["id"] = shift.id
shift_map["date"] = shift.date
shift_map["start_time"] = shift.start_time
shift_map["end_time"] = shift.end_time
shift_map["slots_remaining"] = slots_remaining
shift_list.append(shift_map)

return shift_list


def get_unlogged_shifts_by_volunteer_id(v_id):

# get shifts that the volunteer signed up for and
Expand Down
2 changes: 1 addition & 1 deletion vms/shift/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def list_shifts_sign_up(request, job_id, volunteer_id):
if job_id:
job = get_job_by_id(job_id)
if job:
shift_list = get_shifts_with_open_slots(job_id)
shift_list = get_shifts_with_open_slots_for_volunteer(job_id, volunteer_id)
return render(
request,
'shift/list_shifts_sign_up.html',
Expand Down

0 comments on commit 0a16101

Please sign in to comment.