<commit_before>from django.conf.urls import patterns, include, url
from django.contrib import admin
from rest_framework import viewsets, routers, filters

from . import models
from . import serializers

admin.autodiscover()

# ViewSets define the view behaviour.
class AircraftViewSet(viewsets.ModelViewSet):
    model = models.Aircraft
    serializer_class = serializers.AircraftSerializer

    def get_queryset(self):
        checklists = models.Checklist.objects.all()
        # return models.ChecklistPhase.objects.filter(checklist__aircraft__id=obj.id)[0].slug
        # return models.Aircraft.objects.filter(published=True)
        return models.Aircraft.objects.all()

class ChecklistPhaseViewSet(viewsets.ModelViewSet):
    model = models.ChecklistPhase
    serializer_class = serializers.ChecklistPhaseSerializer


class ChecklistStepViewSet(viewsets.ModelViewSet):
    model = models.ChecklistStep
    serializer_class = serializers.ChecklistStepSerializer


class ChecklistViewSet(viewsets.ModelViewSet):
    model = models.Checklist
    serializer_class = serializers.ChecklistSerializer
    filter_fields = ('aircraft',)

    def get_queryset(self):
        return models.Checklist.objects.filter(published=True)

# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register(r'aircraft', AircraftViewSet)
router.register(r'checklist', ChecklistViewSet)
router.register(r'checklist_phases', ChecklistPhaseViewSet)
router.register(r'checklist_steps', ChecklistStepViewSet)<commit_msg>Only return aircraft which have a published checklist<commit_after>from django.conf.urls import patterns, include, url
from django.contrib import admin
from rest_framework import viewsets, routers, filters

from . import models
from . import serializers

admin.autodiscover()

# ViewSets define the view behaviour.
class AircraftViewSet(viewsets.ModelViewSet):
    model = models.Aircraft
    serializer_class = serializers.AircraftSerializer

    def get_queryset(self):
        return models.Aircraft.objects.filter(checklist__published=True)

class ChecklistPhaseViewSet(viewsets.ModelViewSet):
    model = models.ChecklistPhase
    serializer_class = serializers.ChecklistPhaseSerializer


class ChecklistStepViewSet(viewsets.ModelViewSet):
    model = models.ChecklistStep
    serializer_class = serializers.ChecklistStepSerializer


class ChecklistViewSet(viewsets.ModelViewSet):
    model = models.Checklist
    serializer_class = serializers.ChecklistSerializer
    filter_fields = ('aircraft',)

    def get_queryset(self):
        return models.Checklist.objects.filter(published=True)

# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter()
router.register(r'aircraft', AircraftViewSet)
router.register(r'checklist', ChecklistViewSet)
router.register(r'checklist_phases', ChecklistPhaseViewSet)
router.register(r'checklist_steps', ChecklistStepViewSet)
{'fraction_non_alphanumeric': 0.0771043771043771, 'fraction_numerical': 0.0003367003367003367, 'mean_word_length': 5.631696428571429, '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': '6404288', 'n_tokens_mistral': 826, 'n_tokens_neox': 814, 'n_words': 178}