<commit_before>from django.contrib.auth.models import User, Group
from django.http import JsonResponse

from espacios.models import Miembro
from rest_framework import viewsets
from .serializers import MiembroSerializer, UserSerializer, GroupSerializer


class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer


class GroupViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows groups to be viewed or edited.
    """
    queryset = Group.objects.all()
    serializer_class = GroupSerializer


class MiembroViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows miembros to be viewed or edited.
    """
    queryset = Miembro.objects.all().order_by('-fecha_alta')
    serializer_class = MiembroSerializer

def spaceapi(request):
    # https://spaceapi.io/
    # TODO esta hardcodeado para probar, pasar a DB o a settings
    context = {
      "api": "0.13",
      "space": "Kreitek",
      "logo": "https://kreitek.org//sites/default/files/kreitek_imagen.jpg",
      "url": "https://kreitek.org",
      "location": {
        "address": "Colegio Nuryana, Calle San Francisco de Paula, San Cristobal de La Laguna, Santa Cruz de Tenerife, Spain",
        "lon": 28.4787801,
        "lat": -16.3256688
      },
      "contact": {
        "email": "<EMAIL>",
        "twitter": "@kreitek"
      },
      "issue_report_channels": [
        "email"
      ],
      "state": {
        "icon": {
          "open": "https://kreitek.org//sites/default/files/site_open.gif",
          "closed": "https://kreitek.org//sites/default/files/site_closed.gif"
        },
        "open": False
      },
      "projects": [
        "https://github.com/kreitek",
        "https://wiki.kreitek.org"
      ]
    }
    return JsonResponse(context)
<commit_msg>habilitar CORS solo para endpoint spaceapi<commit_after>from django.contrib.auth.models import User, Group
from django.http import JsonResponse

from espacios.models import Miembro
from rest_framework import viewsets
from .serializers import MiembroSerializer, UserSerializer, GroupSerializer


class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer


class GroupViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows groups to be viewed or edited.
    """
    queryset = Group.objects.all()
    serializer_class = GroupSerializer


class MiembroViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows miembros to be viewed or edited.
    """
    queryset = Miembro.objects.all().order_by('-fecha_alta')
    serializer_class = MiembroSerializer


def spaceapi(request):
    # https://spaceapi.io/
    # TODO esta hardcodeado para probar, pasar a DB o a settings
    context = {
        "api": "0.13",
        "space": "Kreitek",
        "logo": "https://kreitek.org//sites/default/files/kreitek_imagen.jpg",
        "url": "https://kreitek.org",
        "location": {
            "address": "Colegio Nuryana, Calle San Francisco de Paula, San Cristobal de La Laguna, Santa Cruz de Tenerife, Spain",
            "lon": 28.4787801,
            "lat": -16.3256688
        },
        "contact": {
            "email": "<EMAIL>",
            "twitter": "@kreitek"
        },
        "issue_report_channels": [
            "email"
        ],
        "state": {
            "icon": {
                "open": "https://kreitek.org//sites/default/files/site_open.gif",
                "closed": "https://kreitek.org//sites/default/files/site_closed.gif"
            },
            "open": False
        },
        "projects": [
            "https://github.com/kreitek",
            "https://wiki.kreitek.org"
        ]
    }
    response = JsonResponse(context)
    response["Access-Control-Allow-Origin"] = "*"
    response["Access-Control-Allow-Methods"] = "GET, OPTIONS"
    response["Access-Control-Max-Age"] = "900"
    response["Access-Control-Allow-Headers"] = "X-Requested-With, Content-Type"
    return response

{'fraction_non_alphanumeric': 0.1297130661607778, 'fraction_numerical': 0.010671093194213896, 'mean_word_length': 2.6020495303159694, 'pattern_counts': {'":': 36, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 14, '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': '6405716', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1290, 'n_words': 290}