Merge pull request 'Only vote when all teachers registered' (#94) from only-vote-when-teachers-registered 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: mentorenwahl/mentorenwahl#94
This commit is contained in:
commit
434106ca26
|
@ -143,6 +143,11 @@ module Backend
|
|||
def create_vote(context : Context, input : VoteCreateInput) : Vote
|
||||
context.student!
|
||||
|
||||
raise "Not enough teachers" if input.teacher_ids.empty?
|
||||
teacher_role_count = Db::User.where(role: Db::UserRole::Teacher.to_s).count.run.as(Int64)
|
||||
raise "Teachers not registered" if teacher_role_count != Db::Teacher.count ||
|
||||
teacher_role_count.zero?
|
||||
|
||||
skif = context.external.as(Db::Student).skif
|
||||
input.teacher_ids.each do |id|
|
||||
teacher = Db::Teacher.find(id)
|
||||
|
|
Loading…
Reference in a new issue