<commit_before># -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

from rest_framework.response import Response
from rest_framework import status


from akvo.rsr.models import RelatedProject
from akvo.rsr.models.related_project import ParentChangeDisallowed
from ..serializers import RelatedProjectSerializer
from ..viewsets import PublicProjectViewSet


class RelatedProjectViewSet(PublicProjectViewSet):
    """
    """
    queryset = RelatedProject.objects.all()
    serializer_class = RelatedProjectSerializer

    def destroy(self, request, *args, **kwargs):
        try:
            return super(RelatedProjectViewSet, self).destroy(request, *args, **kwargs)
        except ParentChangeDisallowed as e:
            return Response(str(e), status=status.HTTP_403_FORBIDDEN)<commit_msg>[#3916] 405 when parent for project with imported results is removed<commit_after># -*- coding: utf-8 -*-

# Akvo RSR is covered by the GNU Affero General Public License.
# See more details in the license.txt file located at the root folder of the Akvo RSR module.
# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.

from rest_framework.response import Response
from rest_framework import status


from akvo.rsr.models import RelatedProject
from akvo.rsr.models.related_project import ParentChangeDisallowed
from ..serializers import RelatedProjectSerializer
from ..viewsets import PublicProjectViewSet


class RelatedProjectViewSet(PublicProjectViewSet):
    """
    """
    queryset = RelatedProject.objects.all()
    serializer_class = RelatedProjectSerializer

    def update(self, request, *args, **kwargs):
        try:
            return super().destroy(request, *args, **kwargs)
        except ParentChangeDisallowed as e:
            return Response(str(e), status=status.HTTP_405_METHOD_NOT_ALLOWED)

    def destroy(self, request, *args, **kwargs):
        try:
            return super().destroy(request, *args, **kwargs)
        except ParentChangeDisallowed as e:
            return Response(str(e), status=status.HTTP_405_METHOD_NOT_ALLOWED)
{'fraction_non_alphanumeric': 0.08437365475678002, 'fraction_numerical': 0.007748600947051227, 'mean_word_length': 3.9871244635193133, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7371336', 'n_tokens_mistral': 634, 'n_tokens_neox': 611, 'n_words': 203}