Merge pull request 'SKIF students vote SKIF teachers' (#13) from skif-students-vote-skif-teachers into main
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #13
This commit is contained in:
Dominic Grimm 2022-01-20 20:48:10 +00:00
commit b45d911382
2 changed files with 13 additions and 3 deletions

View file

@ -1,4 +1,3 @@
require "granite"
require "granite/adapter/pg"
require "./db/*"

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)