Skip to content

Commit

Permalink
added first version of a new function to check adult status at a cert…
Browse files Browse the repository at this point in the history
…ain date.
  • Loading branch information
CloevVeller committed Dec 9, 2024
1 parent 7a59268 commit 827126d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/members/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def participant_limit_check?
end

def participant_alcohol_check?
@activity.is_alcoholic? && @member.underage?
@activity.is_alcoholic? && @member.underage_at?(@activity.start)
end

# [PATCH] /activities/:id/participants
Expand Down
5 changes: 5 additions & 0 deletions app/models/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ def underage?
!adult?
end

def underage_at?(event_date)
return birth_date.blank? ||
((18.years.ago + (event_date - Date.today)) < birth_date)
end

def master?
educations.any? do |education|
education.status == 'active' && Study.find(education.study_id).masters
Expand Down

0 comments on commit 827126d

Please sign in to comment.