<commit_before>from website.project.taxonomies import Subject

from rest_framework import generics, permissions as drf_permissions

from api.taxonomies.serializers import TaxonomySerializer
from api.base.views import JSONAPIBaseView
from modularodm import Q


class PlosTaxonomy(JSONAPIBaseView, generics.ListAPIView):
    '''[PLOS taxonomy of subjects](http://journals.plos.org/plosone/browse/) in flattened form. *Read-only*

    ##Taxonomy Attributes

        name           type                   description
        ----------------------------------------------------------------------------
        data           array of subjects      List of subjects

    Each subject is represented by an object with the following fields:

    * `id` - autogenerated id of subject
    * `text` - a string that is the subject itself
    * `parent_ids` - ids of parent subjects
    * `type` - in this case the string `'plos'`

    **Note:** Subjects are unique (e.g. there exists only one object in this list with `text='Biology and life sciences'`),
    but as per the structure of the PLOS taxonomy, subjects can exist in separate paths down the taxonomy and as such
    can have multiple parent subjects.

    Only the top three levels of the PLOS taxonomy are included.
    '''
    permission_classes = (
        drf_permissions.IsAuthenticatedOrReadOnly,
    )

    serializer_class = TaxonomySerializer<commit_msg>add scopes and permissions to endpoint<commit_after>from rest_framework import generics, permissions as drf_permissions

from modularodm import Q

from api.base.views import JSONAPIBaseView
from api.base import permissions as base_permissions
from api.taxonomies.serializers import TaxonomySerializer
from website.project.taxonomies import Subject
from framework.auth.oauth_scopes import CoreScopes


class PlosTaxonomy(JSONAPIBaseView, generics.ListAPIView):
    '''[PLOS taxonomy of subjects](http://journals.plos.org/plosone/browse/) in flattened form. *Read-only*

    ##Taxonomy Attributes

        name           type                   description
        ----------------------------------------------------------------------------
        data           array of subjects      List of subjects

    Each subject is represented by an object with the following fields:

    * `id` - autogenerated id of subject
    * `text` - a string that is the subject itself
    * `parent_ids` - ids of parent subjects
    * `type` - in this case the string `'plos'`

    **Note:** Subjects are unique (e.g. there exists only one object in this list with `text='Biology and life sciences'`),
    but as per the structure of the PLOS taxonomy, subjects can exist in separate paths down the taxonomy and as such
    can have multiple parent subjects.

    Only the top three levels of the PLOS taxonomy are included.
    '''
    permission_classes = (
        drf_permissions.IsAuthenticatedOrReadOnly,
        base_permissions.TokenHasScope
    )

    required_read_scopes = [CoreScopes.ALWAYS_PUBLIC]
    required_write_scopes = [CoreScopes.NULL]
    serializer_class = TaxonomySerializer
{'fraction_non_alphanumeric': 0.10730446024563671, 'fraction_numerical': 0.0, 'mean_word_length': 2.654073199527745, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6054690', 'n_tokens_mistral': 814, 'n_tokens_neox': 779, 'n_words': 301}