<commit_before>"""
Handle view-logic for the djangoapp
"""
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError
from rest_framework import serializers
from rest_framework.response import Response
from rest_framework.views import APIView

from openedx.core.lib.api.permissions import IsStaff
from openedx.core.lib.api.view_utils import view_auth_classes

from .models import DiscussionsConfiguration


PROVIDER_FEATURE_MAP = {
    'legacy': [
        'discussion-page',
        'embedded-course-sections',
        'wcag-2.1',
    ],
    'piazza': [
        'discussion-page',
        'lti',
    ],
}


@view_auth_classes()
class DiscussionsConfigurationView(APIView):
    """
    Handle configuration-related view-logic
    """
    permission_classes = (IsStaff,)

    class Serializer(serializers.BaseSerializer):
        """
        Serialize configuration responses
        """

        def create(self, validated_data):
            """
            Create and save a new instance
            """
            raise NotImplementedError

        def to_internal_value(self, data):
            """
            Transform the *incoming* primitive data into a native value.
            """
            raise NotImplementedError

        def to_representation(self, instance) -> dict:
            """
            Serialize data into a dictionary, to be used as a response
            """
            payload = {
                'context_key': str(instance.context_key),
                'enabled': instance.enabled,
                'features': {
                    'discussion-page',
                    'embedded-course-sections',
                    'lti',<commit_msg>refactor: Remove unused helper from discussions API<commit_after>"""
Handle view-logic for the djangoapp
"""
from opaque_keys.edx.keys import CourseKey
from opaque_keys import InvalidKeyError
from rest_framework import serializers
from rest_framework.response import Response
from rest_framework.views import APIView

from openedx.core.lib.api.permissions import IsStaff
from openedx.core.lib.api.view_utils import view_auth_classes

from .models import DiscussionsConfiguration


PROVIDER_FEATURE_MAP = {
    'legacy': [
        'discussion-page',
        'embedded-course-sections',
        'wcag-2.1',
    ],
    'piazza': [
        'discussion-page',
        'lti',
    ],
}


@view_auth_classes()
class DiscussionsConfigurationView(APIView):
    """
    Handle configuration-related view-logic
    """
    permission_classes = (IsStaff,)

    class Serializer(serializers.BaseSerializer):
        """
        Serialize configuration responses
        """

        def to_internal_value(self, data):
            """
            Transform the *incoming* primitive data into a native value.
            """
            raise NotImplementedError

        def to_representation(self, instance) -> dict:
            """
            Serialize data into a dictionary, to be used as a response
            """
            payload = {
                'context_key': str(instance.context_key),
                'enabled': instance.enabled,
                'features': {
                    'discussion-page',
                    'embedded-course-sections',
                    'lti',
{'fraction_non_alphanumeric': 0.0908256880733945, 'fraction_numerical': 0.0012232415902140672, 'mean_word_length': 2.1788143828960154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6071920', 'n_tokens_mistral': 875, 'n_tokens_neox': 822, 'n_words': 210}