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
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #13
This commit is contained in:
commit
b45d911382
|
@ -1,4 +1,3 @@
|
|||
require "granite"
|
||||
require "granite/adapter/pg"
|
||||
|
||||
require "./db/*"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue