from plone.app.contenttypes.interfaces import IEvent
from plone.app.textfield import RichText as RichTextField
from plone.app.vocabularies.catalog import CatalogSource
from plone.autoform.interfaces import IFormFieldProvider
from plone.namedfile.field import NamedBlobFile
from plone.namedfile.field import NamedBlobImage
from ploneintranet.calendar.content import ICentralCalendar
from ploneintranet.core import _
from ploneintranet.userprofile.content.userprofile import IUserProfile
from z3c.relationfield.schema import RelationChoice
from z3c.relationfield.schema import RelationList
from zope import schema
from zope.interface import provider


@provider(IFormFieldProvider)
class IPloneIntranetEvent(IEvent):
    """Additional fields for PloneIntranet events"""

    info = RichTextField(
        title=_("label_info", default="Information"),
        description="",
        required=False,
    )

    image = NamedBlobImage(title=_("Poster image"), description="", required=False)

    video = NamedBlobFile(title=_("Promotion video"), description="", required=False)

    spaces = schema.List(title=_("Spaces"), required=False, defaultFactory=list)

    agenda_items = schema.List(
        title="Agenda Items",
        description="Items associated with this event",
        required=False,
        defaultFactory=list,
    )

    organizer = schema.TextLine(
        title="Organizer",
        description="The user id of the event organizer",
        required=False,
    )

    invitees = schema.TextLine(
        title="Invitees",
        description="Members who are invited to the event",
        required=False,
    )

    shared_calendar = RelationChoice(
        title="Sharing via another calendar",
        default=None,
        source=CatalogSource(object_provides=[ICentralCalendar.__identifier__]),
        required=False,
    )

    participants_yes = RelationList(
        title="Members who will attend",
        defaultFactory=list,
        value_type=RelationChoice(
            source=CatalogSource(object_provides=[IUserProfile.__identifier__])
        ),
        required=False,
    )

    participants_maybe = RelationList(
        title="Members who will attend",
        defaultFactory=list,
        value_type=RelationChoice(
            source=CatalogSource(object_provides=[IUserProfile.__identifier__])
        ),
        required=False,
    )

    participants_no = RelationList(
        title="Members who will attend",
        defaultFactory=list,
        value_type=RelationChoice(
            source=CatalogSource(object_provides=[IUserProfile.__identifier__])
        ),
        required=False,
    )
