"""This module contains default settings for Ashley application."""

from django.conf import settings
from draftjs_exporter.defaults import BLOCK_MAP as DEFAULT_BLOCK_MAP
from draftjs_exporter.defaults import STYLE_MAP as DEFAULT_STYLE_MAP
from draftjs_exporter.dom import DOM

from ashley.editor.decorators import emoji, link

_FORUM_BASE_PERMISSIONS = [
    "can_see_forum",
    "can_read_forum",
    "can_start_new_topics",
    "can_reply_to_topics",
    "can_edit_own_posts",
    "can_post_without_approval",
    "can_vote_in_polls",
]

_FORUM_ADMIN_PERMISSIONS = _FORUM_BASE_PERMISSIONS + [
    "can_post_announcements",
    "can_post_stickies",
    "can_delete_own_posts",
    "can_create_polls",
    "can_lock_topics",
    "can_edit_posts",
    "can_delete_posts",
    "can_approve_posts",
    "can_reply_to_locked_topics",
]

DEFAULT_FORUM_BASE_PERMISSIONS = getattr(
    settings, "ASHLEY_DEFAULT_FORUM_BASE_PERMISSIONS", _FORUM_BASE_PERMISSIONS
)

DEFAULT_FORUM_ROLES_PERMISSIONS = getattr(
    settings,
    "ASHLEY_DEFAULT_FORUM_ROLES_PERMISSIONS",
    {
        "administrator": _FORUM_ADMIN_PERMISSIONS,
        "instructor": _FORUM_ADMIN_PERMISSIONS,
    },
)


DEFAULT_DRAFTJS_EXPORTER_CONFIG = {
    "entity_decorators": {"LINK": link, "emoji": emoji},
    "composite_decorators": [],
    "block_map": DEFAULT_BLOCK_MAP,
    "style_map": DEFAULT_STYLE_MAP,
    "engine": DOM.STRING,
}

DRAFTJS_EXPORTER_CONFIG = {
    **DEFAULT_DRAFTJS_EXPORTER_CONFIG,
    **getattr(settings, "ASHLEY_DRAFTJS_EXPORTER_CONFIG", {}),
}
