Added skif check to create vote
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Dominic Grimm 2022-01-20 21:44:04 +01:00
parent 74a644159c
commit 69c5d27034

View file

@ -136,8 +136,19 @@ module API
def create_vote(context : Context, input : VoteCreateInput) : Vote
context.student!
if input.teacher_ids.any? { |id| Db::Teacher.find(id).nil? }
raise "Teachers not found"
skif = context.external.as(Db::Student).skif
input.teacher_ids.each do |id|
teacher = Db::Teacher.find(id)
if teacher.nil?
raise "Teachers not found"
elsif teacher.skif != skif
if teacher.skif
raise "Teacher is SKIF, student is not"
else
raise "Teacher is not SKIF, student is"
end
end
end
student = context.external.not_nil!.as(Db::Student)