# MIT License
# Copyright (c) 2019 MassChallenge, Inc.

from accelerator.models import MentorProgramOfficeHour
from impact.v1.helpers.model_helper import (
    ModelHelper,
    BOOLEAN_FIELD,
    OPTIONAL_INTEGER_FIELD,
    OPTIONAL_STRING_FIELD,
    PK_FIELD,
)

OFFFICE_HOUR_FIELDS = {
    "id": PK_FIELD,
    "title": OPTIONAL_STRING_FIELD,
    "location": OPTIONAL_STRING_FIELD,
    "timezone": OPTIONAL_STRING_FIELD,
    "start_date_time": OPTIONAL_STRING_FIELD,
    "end_date_time": OPTIONAL_STRING_FIELD,
    "mentor_id": OPTIONAL_INTEGER_FIELD,
    "mentor_name": OPTIONAL_STRING_FIELD,
    "mentor_email": OPTIONAL_STRING_FIELD,
    "finalist_id": OPTIONAL_INTEGER_FIELD,
    "finalist_name": OPTIONAL_STRING_FIELD,
    "finalist_email": OPTIONAL_STRING_FIELD,
    "is_open": BOOLEAN_FIELD,
}


class MentorProgramOfficeHourHelper(ModelHelper):
    model = MentorProgramOfficeHour

    @classmethod
    def fields(cls):
        return OFFFICE_HOUR_FIELDS

    @property
    def title(self):
        return str(self.subject)

    @property
    def location(self):
        return self.field_element("location", "name")

    @property
    def timezone(self):
        return self.field_element("location", "timezone")

    @property
    def mentor_id(self):
        return self.field_element("mentor", "id")

    @property
    def mentor_name(self):
        return self.subject.mentor.full_name()

    @property
    def mentor_email(self):
        return self.field_element("mentor", "email")

    @property
    def finalist_id(self):
        return self.field_element("finalist", "id")

    @property
    def finalist_name(self):
        return self.subject.finalist.full_name()

    @property
    def finalist_email(self):
        return self.field_element("finalist", "email")

    @property
    def is_open(self):
        return self.subject.is_open()

@@ -793,16 +793,212 @@
 _FIELD,%0A
+    %22topics%22: OPTIONAL_STRING_FIELD,%0A    %22description%22: OPTIONAL_STRING_FIELD,%0A    %22street_address%22: OPTIONAL_STRING_FIELD,%0A    %22city%22: OPTIONAL_STRING_FIELD,%0A    %22state%22: OPTIONAL_STRING_FIELD,%0A%0A
 %7D%0A%0A%0Aclas
@@ -1312,24 +1312,313 @@
 %22, %22name%22)%0A%0A
+    @property%0A    def street_address(self):%0A        return self.field_element(%22location%22, %22street_address%22)%0A%0A    @property%0A    def city(self):%0A        return self.field_element(%22location%22, %22city%22)%0A%0A    @property%0A    def state(self):%0A        return self.field_element(%22location%22, %22state%22)%0A%0A
     @propert
@@ -2293,32 +2293,32 @@
  is_open(self):%0A
-
         return s
@@ -2339,8 +2339,162 @@
 _open()%0A
+%0A    @property%0A    def topics(self):%0A        return self.subject.topics%0A%0A    @property%0A    def description(self):%0A        return self.subject.description%0A

Add helper fields