from rest_framework import generics, status
from rest_framework.response import Response

from common.views import APIKeyAuthentication, DashboardTokenAuthentication

from .import_article import importArticle
from .serializers import ImportArticleRequestSerializer

from .article_of_the_day.article_of_the_day_views import (
    ArticleOfTheDayMobileView,
    ArticleOfTheDayListDashboardView,
    ArticleOfTheDayDetailDashboardView,
)

from .app_actions.app_actions_views import (
    AppActionsListDashboardView,
    AppActionsDetailDashboardView,
    AppActionsRelatedAppFeaturesListDashboardView,
    AppActionsRelatedAppFeaturesDetailDashboardView,
    AppActionsActionButtonsListDashboardView,
    AppActionsActionButtonsDetailDashboardView,
    AppActionsActionButtonsLanguageListDashboardView,
    AppActionsActionButtonsLanguageDetailDashboardView,
    AppActionsRelatedContentListDashboardView,
    AppActionsRelatedContentDetailDashboardView,
    AppActionsRelatedContentLanguageListDashboardView,
    AppActionsRelatedContentLanguageDetailDashboardView,
)

from .checklist.checklist_views import (
    ChecklistListDashboardView,
    ChecklistDetailDashboardView,
    ChecklistLanguageListDashboardView,
    ChecklistLanguageDetailDashboardView,
    ChecklistItemsListDashboardView,
    ChecklistItemsDetailDashboardView,
    ChecklistItemsLanguageListDashboardView,
    ChecklistItemsLanguageDetailDashboardView,
)

from .content_information.content_information_views import (
    ContentInformationListMobileView,
    ContentInformationDetailMobileView,
    ContentInformationListDashboardView,
    ContentInformationDetailDashboardView,
    ContentInformationLanguageListDashboardView,
    ContentInformationLanguageDetailDashboardView,
    TargetAudienceListDashboardView,
    TargetAudienceDetailDashboardView,
    ContentObjectiveListDashboardView,
    ContentObjectiveDetailDashboardView,
)

from .content_safety.content_safety_views import (
    ContentSafetyListDashboardView,
    ContentSafetyDetailDashboardView,
    ContentSafetyLanguageListDashboardView,
    ContentSafetyLanguageDetailDashboardView,
    ContentSafetyWarningSignsListDashboardView,
    ContentSafetyWarningSignsDetailDashboardView,
    ContentSafetyWarningSignsLanguageListDashboardView,
    ContentSafetyWarningSignsLanguageDetailDashboardView,
    ContentSafetyAdditionalNotesListDashboardView,
    ContentSafetyAdditionalNotesDetailDashboardView,
    ContentSafetyAdditionalNotesLanguageListDashboardView,
    ContentSafetyAdditionalNotesLanguageDetailDashboardView,
)

from .education_content.education_content_views import (
    EducationContentListDashboardView,
    EducationContentDetailDashboardView,
    EducationContentSocialMediaListDashboardView,
    EducationContentSocialMediaDetailDashboardView,
    EducationContentSocialMediaLanguageListDashboardView,
    EducationContentSocialMediaLanguageDetailDashboardView,
    EducationContentSocialMediaImageTextListDashboardView,
    EducationContentSocialMediaImageTextDetailDashboardView,
    EducationContentSocialMediaImageTextLanguageListDashboardView,
    EducationContentSocialMediaImageTextLanguageDetailDashboardView,
    EducationContentSocialMediaHashtagsListDashboardView,
    EducationContentSocialMediaHashtagsDetailDashboardView,
    EducationContentSocialMediaHashtagsLanguageListDashboardView,
    EducationContentSocialMediaHashtagsLanguageDetailDashboardView,
    EducationContentAppContentListDashboardView,
    EducationContentAppContentDetailDashboardView,
    EducationContentAppContentLanguageListDashboardView,
    EducationContentAppContentLanguageDetailDashboardView,
    EducationContentAppContentWhatYouShouldKnowListDashboardView,
    EducationContentAppContentWhatYouShouldKnowDetailDashboardView,
    EducationContentAppContentWhatYouShouldKnowLanguageListDashboardView,
    EducationContentAppContentWhatYouShouldKnowLanguageDetailDashboardView,
)

from .interactive_content.interactive_content_views import (
    InteractiveContentListDashboardView,
    InteractiveContentDetailDashboardView,
    InteractiveContentSocialMediaListDashboardView,
    InteractiveContentSocialMediaDetailDashboardView,
    InteractiveContentSocialMediaLanguageListDashboardView,
    InteractiveContentSocialMediaLanguageDetailDashboardView,
    InteractiveContentSocialMediaOptionsListDashboardView,
    InteractiveContentSocialMediaOptionsDetailDashboardView,
    InteractiveContentSocialMediaOptionsLanguageListDashboardView,
    InteractiveContentSocialMediaOptionsLanguageDetailDashboardView,
    InteractiveContentSocialMediaHashtagsListDashboardView,
    InteractiveContentSocialMediaHashtagsDetailDashboardView,
    InteractiveContentSocialMediaHashtagsLanguageListDashboardView,
    InteractiveContentSocialMediaHashtagsLanguageDetailDashboardView,
    InteractiveContentAppContentListDashboardView,
    InteractiveContentAppContentDetailDashboardView,
    InteractiveContentAppContentLanguageListDashboardView,
    InteractiveContentAppContentLanguageDetailDashboardView,
    InteractiveContentAppContentOptionsListDashboardView,
    InteractiveContentAppContentOptionsDetailDashboardView,
    InteractiveContentAppContentOptionsLanguageListDashboardView,
    InteractiveContentAppContentOptionsLanguageDetailDashboardView,
)

from .problem_solution_content.problem_solution_content_views import (
    ProblemSolutionContentListDashboardView,
    ProblemSolutionContentDetailDashboardView,
    ProblemSolutionContentSocialMediaListDashboardView,
    ProblemSolutionContentSocialMediaDetailDashboardView,
    ProblemSolutionContentSocialMediaLanguageListDashboardView,
    ProblemSolutionContentSocialMediaLanguageDetailDashboardView,
    ProblemSolutionContentSocialMediaImageTextListDashboardView,
    ProblemSolutionContentSocialMediaImageTextDetailDashboardView,
    ProblemSolutionContentSocialMediaImageTextLanguageListDashboardView,
    ProblemSolutionContentSocialMediaImageTextLanguageDetailDashboardView,
    ProblemSolutionContentSocialMediaHashtagsListDashboardView,
    ProblemSolutionContentSocialMediaHashtagsDetailDashboardView,
    ProblemSolutionContentSocialMediaHashtagsLanguageListDashboardView,
    ProblemSolutionContentSocialMediaHashtagsLanguageDetailDashboardView,
    ProblemSolutionContentAppContentListDashboardView,
    ProblemSolutionContentAppContentDetailDashboardView,
    ProblemSolutionContentAppContentLanguageListDashboardView,
    ProblemSolutionContentAppContentLanguageDetailDashboardView,
    ProblemSolutionContentAppContentPossibleCausesListDashboardView,
    ProblemSolutionContentAppContentPossibleCausesDetailDashboardView,
    ProblemSolutionContentAppContentPossibleCausesLanguageListDashboardView,
    ProblemSolutionContentAppContentPossibleCausesLanguageDetailDashboardView,
    ProblemSolutionContentAppContentRecommendedSolutionsListDashboardView,
    ProblemSolutionContentAppContentRecommendedSolutionsDetailDashboardView,
    ProblemSolutionContentAppContentRecommendedSolutionsLanguageListDashboardView,
    ProblemSolutionContentAppContentRecommendedSolutionsLanguageDetailDashboardView,
)

from .relatable_content.relatable_content_views import (
    RelatableContentListDashboardView,
    RelatableContentDetailDashboardView,
    RelatableContentSocialMediaListDashboardView,
    RelatableContentSocialMediaDetailDashboardView,
    RelatableContentSocialMediaLanguageListDashboardView,
    RelatableContentSocialMediaLanguageDetailDashboardView,
    RelatableContentSocialMediaHashtagsListDashboardView,
    RelatableContentSocialMediaHashtagsDetailDashboardView,
    RelatableContentSocialMediaHashtagsLanguageListDashboardView,
    RelatableContentSocialMediaHashtagsLanguageDetailDashboardView,
    RelatableContentAppContentListDashboardView,
    RelatableContentAppContentDetailDashboardView,
    RelatableContentAppContentLanguageListDashboardView,
    RelatableContentAppContentLanguageDetailDashboardView,
)

from .story_content.story_content_views import (
    StoryContentListDashboardView,
    StoryContentDetailDashboardView,
    StoryContentSocialMediaListDashboardView,
    StoryContentSocialMediaDetailDashboardView,
    StoryContentSocialMediaLanguageListDashboardView,
    StoryContentSocialMediaLanguageDetailDashboardView,
    StoryContentSocialMediaHashtagsListDashboardView,
    StoryContentSocialMediaHashtagsDetailDashboardView,
    StoryContentSocialMediaHashtagsLanguageListDashboardView,
    StoryContentSocialMediaHashtagsLanguageDetailDashboardView,
    StoryContentAppContentListDashboardView,
    StoryContentAppContentDetailDashboardView,
    StoryContentAppContentLanguageListDashboardView,
    StoryContentAppContentLanguageDetailDashboardView,
)

from .tip_quote.tip_quote_views import (
    TipQuoteListDashboardView,
    TipQuoteDetailDashboardView,
    TipQuoteLanguageListDashboardView,
    TipQuoteLanguageDetailDashboardView,
)


class ImportArticleDashboardView(generics.GenericAPIView):
    authentication_classes = [APIKeyAuthentication, DashboardTokenAuthentication]
    serializer_class = ImportArticleRequestSerializer
    queryset = []

    def post(self, request, *args, **kwargs):
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        article, created = importArticle(serializer.validated_data)
        return Response(
            {
                "id": article.id,
                "keyName": article.keyName,
                "isCreated": created,
                "message": "Article created." if created else "Article updated.",
            },
            status=status.HTTP_201_CREATED if created else status.HTTP_200_OK,
        )
