<commit_before>from collections import OrderedDict
from urllib import urlencode

from django.core.urlresolvers import reverse_lazy
from django.http import JsonResponse
from django.views.generic import View


class APIView(View):
    pass


class ChangeListRetrieveAPIView(APIView):

    def get_api_next_url(self, request, cl):
        page_num = cl.page_num
        if page_num and page_num is not int or not cl.multi_page:
            return None
        info = self.model._meta.app_label, self.model._meta.model_name
        url = reverse_lazy("admin:%s_%s_api_list" % info)
        host = request.get_host()
        params = cl.params
        params["p"] = page_num + 1
        return "%s://%s%s?%s" % (request.scheme, host, url, urlencode(params))

    def get_api_previous_url(self, request, cl):
        page_num = cl.page_num
        if page_num == 0 or not cl.multi_page:
            return None

        info = self.model._meta.app_label, self.model._meta.model_name
        url = reverse_lazy("admin:%s_%s_api_list" % info)
        host = request.get_host()
        params = cl.params
        params["p"] = page_num - 1
        return "%s://%s%s?%s" % (request.scheme, host, url, urlencode(params))

    def get(self, request, model_admin, admin_cl, *args, **kwargs):
        self.model = admin_cl.model
        results = []
        for obj in admin_cl.result_list:
            results.append(model_admin.obj_as_dict(request, obj))

        data = OrderedDict()
        data["count"] = admin_cl.result_count
        data["next"] = self.get_api_next_url(request, admin_cl)
        data["previous"] = self.get_api_previous_url(request, admin_cl)
        data["results"] = results
        return JsonResponse(data)
<commit_msg>implemented AdminDetailRetrieveAPIView  for detail api endpoint<commit_after>from collections import OrderedDict
from urllib import urlencode

from django.core.urlresolvers import reverse_lazy
from django.http import JsonResponse
from django.views.generic import View


class APIView(View):
    pass


class ChangeListRetrieveAPIView(APIView):

    def get_api_next_url(self, request, cl):
        page_num = cl.page_num
        if page_num and page_num is not int or not cl.multi_page:
            return None
        info = self.model._meta.app_label, self.model._meta.model_name
        url = reverse_lazy("admin:%s_%s_api_list" % info)
        host = request.get_host()
        params = cl.params
        params["p"] = page_num + 1
        return "%s://%s%s?%s" % (request.scheme, host, url, urlencode(params))

    def get_api_previous_url(self, request, cl):
        page_num = cl.page_num
        if page_num == 0 or not cl.multi_page:
            return None

        info = self.model._meta.app_label, self.model._meta.model_name
        url = reverse_lazy("admin:%s_%s_api_list" % info)
        host = request.get_host()
        params = cl.params
        params["p"] = page_num - 1
        return "%s://%s%s?%s" % (request.scheme, host, url, urlencode(params))

    def get(self, request, model_admin, admin_cl, *args, **kwargs):
        self.model = admin_cl.model
        results = []
        for obj in admin_cl.result_list:
            results.append(model_admin.obj_as_dict(request, obj))

        data = OrderedDict()
        data["count"] = admin_cl.result_count
        data["next"] = self.get_api_next_url(request, admin_cl)
        data["previous"] = self.get_api_previous_url(request, admin_cl)
        data["results"] = results
        return JsonResponse(data)


class AdminDetailRetrieveAPIView(APIView):

    def get(self, request, model_admin, admin_cl, *args, **kwargs):
        return JsonResponse({})
{'fraction_non_alphanumeric': 0.10859481582537517, 'fraction_numerical': 0.0016371077762619372, 'mean_word_length': 2.9, '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': '4961221', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1144, 'n_words': 266}