from wagtail.core import blocks
from wagtail.snippets.blocks import SnippetChooserBlock

from assignments.models import Assignment
from core.constants import DEFAULT_RICH_TEXT_FEATURES, INSTRUMENTS_RICH_TEXT_FEATURES
from surveys.models import Survey


# link_block
class LinkBlock(blocks.StructBlock):
    class Meta:
        icon = 'link'

    text = blocks.TextBlock()
    url = blocks.URLBlock()


# 'text_block' 'solution'
class TextBlock(blocks.StructBlock):
    class Meta:
        icon = 'doc-full'

    text = blocks.RichTextBlock(features=DEFAULT_RICH_TEXT_FEATURES)


# 'basic_knowledge'
class BasicKnowledgeBlock(blocks.StructBlock):
    class Meta:
        icon = 'placeholder'
        label = 'Instrument'

    description = blocks.RichTextBlock(required=False)
    basic_knowledge = blocks.PageChooserBlock(required=True, target_model='basicknowledge.BasicKnowledge')


# 'image_url'
class ImageUrlBlock(blocks.StructBlock):
    class Meta:
        icon = 'image'

    title = blocks.TextBlock()
    url = blocks.URLBlock()


# 'assignment'
class AssignmentBlock(blocks.StructBlock):
    class Meta:
        icon = 'download'

    assignment_id = SnippetChooserBlock(Assignment)


# 'survey'
class SurveyBlock(blocks.StructBlock):
    class Meta:
        icon = 'form'

    survey_id = SnippetChooserBlock(Survey)


# 'video_block'
class VideoBlock(blocks.StructBlock):
    class Meta:
        icon = 'media'

    url = blocks.URLBlock()


# 'document_block'
class DocumentBlock(blocks.StructBlock):
    class Meta:
        icon = 'doc-full'

    url = blocks.URLBlock()


class InfogramBlock(blocks.StructBlock):
    id = blocks.TextBlock()
    title = blocks.TextBlock()


class GeniallyBlock(blocks.StructBlock):
    id = blocks.TextBlock()


class ThinglinkBlock(blocks.StructBlock):
    id = blocks.TextBlock()


class SectionTitleBlock(blocks.StructBlock):
    text = blocks.TextBlock()


class SubtitleBlock(blocks.StructBlock):
    text = blocks.TextBlock()


class InstrumentTextBlock(blocks.StructBlock):
    class Meta:
        icon = 'doc-full'

    text = blocks.RichTextBlock(features=INSTRUMENTS_RICH_TEXT_FEATURES)


class ModuleRoomSlugBlock(blocks.StructBlock):
    class Meta:
        icon = 'link'

    title = blocks.TextBlock()


class InstructionBlock(blocks.StructBlock):
    class Meta:
        icon = 'help'

    url = blocks.URLBlock()
    text = blocks.TextBlock(required=False)

# 'text_block' 'task' 'basic_knowledge' 'student_entry' 'image_block'
#
# url = blocks.URLBlock()
# document = DocumentChooserBlock()
