<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib.sites.models import get_current_site
from django.utils import timezone

from rest_framework.generics import ListAPIView as RestListAPIView

from opps.views.generic.base import View
from opps.containers.models import ContainerBox


class ListView(View, RestListAPIView):
    def get_queryset(self):
        self.long_slug = self.get_long_slug()
        self.site = get_current_site(self.request)

        if not self.long_slug:
            return None

        self.set_channel_rules()

        self.articleboxes = ContainerBox.objects.filter(
            channel__long_slug=self.long_slug)

        for box in self.articleboxes:
            self.excluded_ids.update([a.pk for a in box.ordered_containers()])

        queryset = super(ListView, self).get_queryset()
        filters = {}
        filters['site_domain'] = self.site.domain
        try:
            if queryset.model._meta.get_field_by_name('channel_long_slug'):
                filters['channel_long_slug__in'] = self.channel_long_slug
        except:
            pass
        filters['date_available__lte'] = timezone.now()
        filters['published'] = True
        queryset = queryset.filter(**filters).exclude(pk__in=self.excluded_ids)

        return queryset._clone()<commit_msg>Add list create on API<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib.sites.models import get_current_site
from django.utils import timezone

from rest_framework.generics import ListAPIView as RestListAPIView
from rest_framework.generics import ListCreateAPIView

from opps.views.generic.base import View
from opps.containers.models import ContainerBox


class ListView(View, RestListAPIView):
    def get_queryset(self):
        self.long_slug = self.get_long_slug()
        self.site = get_current_site(self.request)

        if not self.long_slug:
            return None

        self.set_channel_rules()

        self.articleboxes = ContainerBox.objects.filter(
            channel__long_slug=self.long_slug)

        for box in self.articleboxes:
            self.excluded_ids.update([a.pk for a in box.ordered_containers()])

        queryset = super(ListView, self).get_queryset()
        filters = {}
        filters['site_domain'] = self.site.domain
        try:
            if queryset.model._meta.get_field_by_name('channel_long_slug'):
                filters['channel_long_slug__in'] = self.channel_long_slug
        except:
            pass
        filters['date_available__lte'] = timezone.now()
        filters['published'] = True
        queryset = queryset.filter(**filters).exclude(pk__in=self.excluded_ids)

        return queryset._clone()


class ListCreateView(ListCreateAPIView, ListView):
    pass
{'fraction_non_alphanumeric': 0.09443447037701976, 'fraction_numerical': 0.000718132854578097, 'mean_word_length': 2.9573863636363638, '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': '3492736', 'n_tokens_mistral': 823, 'n_tokens_neox': 813, 'n_words': 159}