# Copyright (c) 2021, Xhive LLC
# For license information, please see license.txt


import json

import xhiveframework
from xhiveframework.model.document import Document


class InterviewRound(Document):
	pass


@xhiveframework.whitelist()
def create_interview(doc):
	if isinstance(doc, str):
		doc = json.loads(doc)
		doc = xhiveframework.get_doc(doc)

	interview = xhiveframework.new_doc("Interview")
	interview.interview_round = doc.name
	interview.designation = doc.designation

	if doc.interviewers:
		interview.interview_details = []
		for data in doc.interviewers:
			interview.append("interview_details", {"interviewer": data.user})
	return interview
