'''Copyright 2018 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.'''

from app.models.bookings import Base
from qsystem import db


class Exam(Base):

    exam_id = db.Column(db.Integer, primary_key=True, autoincrement=True, nullable=False)
    booking_id = db.Column(db.Integer, db.ForeignKey("booking.booking_id", ondelete="set null"), nullable=True)
    exam_type_id = db.Column(db.Integer, db.ForeignKey("examtype.exam_type_id"), nullable=False)
    office_id = db.Column(db.Integer, db.ForeignKey("office.office_id"), nullable=False)
    event_id = db.Column(db.String(25), nullable=False)
    exam_name = db.Column(db.String(50), nullable=False)
    examinee_name = db.Column(db.String(50), nullable=True)
    expiry_date = db.Column(db.DateTime, nullable=True)
    notes = db.Column(db.String(400), nullable=True)
    exam_received_date = db.Column(db.DateTime, nullable=True)
    session_number = db.Column(db.Integer, nullable=True)
    number_of_students = db.Column(db.Integer, nullable=True)
    exam_method = db.Column(db.String(15), nullable=False)
    deleted_date = db.Column(db.String(50), nullable=True)
    exam_returned_ind = db.Column(db.Integer, nullable=False, default=0)
    exam_returned_tracking_number = db.Column(db.String(50), nullable=True)
    offsite_location = db.Column(db.String(50), nullable=True)


    booking = db.relationship("Booking")
    exam_type = db.relationship("ExamType")
    office = db.relationship("Office")

    def __repr__(self):
        return '<Exam Name: (name={self.exam_name!r})>'.format(self=self)

    def __init__(self, **kwargs):
        super(Exam, self).__init__(**kwargs)

[((21, 14, 21, 89), 'qsystem.db.Column', 'db.Column', (), '', False, 'from qsystem import db\n'), ((28, 18, 28, 55), 'qsystem.db.Column', 'db.Column', (), '', False, 'from qsystem import db\n'), ((30, 25, 30, 62), 'qsystem.db.Column', 'db.Column', (), '', False, 'from qsystem import db\n'), ((31, 21, 31, 57), 'qsystem.db.Column', 'db.Column', (), '', False, 'from qsystem import db\n'), ((32, 25, 32, 61), 'qsystem.db.Column', 'db.Column', (), '', False, 'from qsystem import db\n'), ((35, 24, 35, 72), 'qsystem.db.Column', 'db.Column', (), '', False, 'from qsystem import db\n'), ((40, 14, 40, 40), 'qsystem.db.relationship', 'db.relationship', ({(40, 30, 40, 39): '"""Booking"""'}, {}), "('Booking')", False, 'from qsystem import db\n'), ((41, 16, 41, 43), 'qsystem.db.relationship', 'db.relationship', ({(41, 32, 41, 42): '"""ExamType"""'}, {}), "('ExamType')", False, 'from qsystem import db\n'), ((42, 13, 42, 38), 'qsystem.db.relationship', 'db.relationship', ({(42, 29, 42, 37): '"""Office"""'}, {}), "('Office')", False, 'from qsystem import db\n'), ((22, 39, 22, 95), 'qsystem.db.ForeignKey', 'db.ForeignKey', (), '', False, 'from qsystem import db\n'), ((23, 41, 23, 79), 'qsystem.db.ForeignKey', 'db.ForeignKey', ({(23, 55, 23, 78): '"""examtype.exam_type_id"""'}, {}), "('examtype.exam_type_id')", False, 'from qsystem import db\n'), ((24, 38, 24, 71), 'qsystem.db.ForeignKey', 'db.ForeignKey', ({(24, 52, 24, 70): '"""office.office_id"""'}, {}), "('office.office_id')", False, 'from qsystem import db\n'), ((25, 25, 25, 38), 'qsystem.db.String', 'db.String', ({(25, 35, 25, 37): '25'}, {}), '(25)', False, 'from qsystem import db\n'), ((26, 26, 26, 39), 'qsystem.db.String', 'db.String', ({(26, 36, 26, 38): '50'}, {}), '(50)', False, 'from qsystem import db\n'), ((27, 30, 27, 43), 'qsystem.db.String', 'db.String', ({(27, 40, 27, 42): '50'}, {}), '(50)', False, 'from qsystem import db\n'), ((29, 22, 29, 36), 'qsystem.db.String', 'db.String', ({(29, 32, 29, 35): '400'}, {}), '(400)', False, 'from qsystem import db\n'), ((33, 28, 33, 41), 'qsystem.db.String', 'db.String', ({(33, 38, 33, 40): '15'}, {}), '(15)', False, 'from qsystem import db\n'), ((34, 29, 34, 42), 'qsystem.db.String', 'db.String', ({(34, 39, 34, 41): '50'}, {}), '(50)', False, 'from qsystem import db\n'), ((36, 46, 36, 59), 'qsystem.db.String', 'db.String', ({(36, 56, 36, 58): '50'}, {}), '(50)', False, 'from qsystem import db\n'), ((37, 33, 37, 46), 'qsystem.db.String', 'db.String', ({(37, 43, 37, 45): '50'}, {}), '(50)', False, 'from qsystem import db\n')]