<commit_before>from rest_framework import generics, permissions as drf_permissions
from rest_framework.exceptions import NotFound

from modularodm import Q
from framework.auth.core import User
from framework.auth.oauth_scopes import CoreScopes

from website.models import NodeLog
from api.logs.permissions import (
    ContributorOrPublicForLogs
)

from api.base.filters import ODMFilterMixin
from api.base import permissions as base_permissions
from api.users.serializers import UserSerializer
from api.logs.serializers import NodeLogSerializer
from api.base.views import JSONAPIBaseView


class LogMixin(object):
    """
    Mixin with convenience method get_log
    """

    def get_log(self):
        log = NodeLog.load(self.kwargs.get('log_id'))
        if not log:
            raise NotFound(
                detail='No log matching that log_id could be found.'
            )

        self.check_object_permissions(self.request, log)
        return log


class NodeLogDetail(JSONAPIBaseView, generics.RetrieveAPIView, LogMixin):
    """Details about a given Node Log. *Read-only*.

     On the front end, logs show record and show actions done on the OSF. The complete list of loggable actions (in the format {identifier}: {description}) is as follows:

    * 'project_created': A Node is created
    * 'project_registered': A Node is registered
    * 'project_deleted': A Node is deleted
    * 'created_from': A Node is created using an existing Node as a template
    * 'pointer_created': A Pointer is created
    * 'pointer_forked': A Pointer is forked
    * 'pointer_removed': A Pointer is removed
    * 'node_removed': A component is deleted
    * 'node_forked': A Node is forked (_deprecated_)
    ---
    * 'made_public': A Node is made public
    * 'made_private': A Node is made private
    * 'tag_added': A tag is added to a Node
    * 'tag_removed': A tag is removed from a Node
    * 'edit_title': A Node's title is changed
    * 'edit_description': A Node's description is changed
    * 'updated_fields': One or more of a Node's fields are changed
    * 'external_ids_added': An external identifier is added to a Node (e.g. DOI, ARK)
    ---<commit_msg>Remove (__deprecated__) from field.<commit_after>from rest_framework import generics, permissions as drf_permissions
from rest_framework.exceptions import NotFound

from modularodm import Q
from framework.auth.core import User
from framework.auth.oauth_scopes import CoreScopes

from website.models import NodeLog
from api.logs.permissions import (
    ContributorOrPublicForLogs
)

from api.base.filters import ODMFilterMixin
from api.base import permissions as base_permissions
from api.users.serializers import UserSerializer
from api.logs.serializers import NodeLogSerializer
from api.base.views import JSONAPIBaseView


class LogMixin(object):
    """
    Mixin with convenience method get_log
    """

    def get_log(self):
        log = NodeLog.load(self.kwargs.get('log_id'))
        if not log:
            raise NotFound(
                detail='No log matching that log_id could be found.'
            )

        self.check_object_permissions(self.request, log)
        return log


class NodeLogDetail(JSONAPIBaseView, generics.RetrieveAPIView, LogMixin):
    """Details about a given Node Log. *Read-only*.

     On the front end, logs show record and show actions done on the OSF. The complete list of loggable actions (in the format {identifier}: {description}) is as follows:

    * 'project_created': A Node is created
    * 'project_registered': A Node is registered
    * 'project_deleted': A Node is deleted
    * 'created_from': A Node is created using an existing Node as a template
    * 'pointer_created': A Pointer is created
    * 'pointer_forked': A Pointer is forked
    * 'pointer_removed': A Pointer is removed
    * 'node_removed': A component is deleted
    * 'node_forked': A Node is forked
    ---
    * 'made_public': A Node is made public
    * 'made_private': A Node is made private
    * 'tag_added': A tag is added to a Node
    * 'tag_removed': A tag is removed from a Node
    * 'edit_title': A Node's title is changed
    * 'edit_description': A Node's description is changed
    * 'updated_fields': One or more of a Node's fields are changed
    * 'external_ids_added': An external identifier is added to a Node (e.g. DOI, ARK)
    ---
{'fraction_non_alphanumeric': 0.07607446564008274, 'fraction_numerical': 0.0, 'mean_word_length': 3.48659793814433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '574114', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1214, 'n_words': 472}