<commit_before>"""Core models used by the CMS."""


import datetime

from django.contrib.contenttypes.models import ContentType
from django.core import urlresolvers
from django.db import models
from django.db.models import Q
from django.utils.functional import cached_property

from cms import sitemaps
from cms.models.base import PageBase, PublishedBaseManager
from cms.apps import historylinks


def get_default_page_parent():
    """Returns the default page parent."""
    try:
        return Page.objects.all()[0]
    except IndexError:
        return None


class PageManager(PublishedBaseManager):
    
    """Manager for Page objects."""
    
    def get_homepage(self):
        """Returns the site homepage."""
        return self.prefetch_related("child_set__child_set").get(parent=None)


class Page(PageBase):

    """A page within the site."""
    
    objects = PageManager()
    
    @classmethod
    def select_published(cls, queryset):
        """Selects only published pages."""
        queryset = super(Page, cls).select_published(queryset)
        now = datetime.datetime.now()
        queryset = queryset.filter(Q(publication_date=None) | Q(publication_date__lte=now))
        queryset = queryset.filter(Q(expiry_date=None) | Q(expiry_date__gt=now))<commit_msg>Removing runtime warnings from using naive timezones.<commit_after>"""Core models used by the CMS."""

from django.contrib.contenttypes.models import ContentType
from django.core import urlresolvers
from django.db import models
from django.db.models import Q
from django.utils.functional import cached_property
from django.utils import timezone

from cms import sitemaps
from cms.models.base import PageBase, PublishedBaseManager
from cms.apps import historylinks


def get_default_page_parent():
    """Returns the default page parent."""
    try:
        return Page.objects.all()[0]
    except IndexError:
        return None


class PageManager(PublishedBaseManager):
    
    """Manager for Page objects."""
    
    def get_homepage(self):
        """Returns the site homepage."""
        return self.prefetch_related("child_set__child_set").get(parent=None)


class Page(PageBase):

    """A page within the site."""
    
    objects = PageManager()
    
    @classmethod
    def select_published(cls, queryset):
        """Selects only published pages."""
        queryset = super(Page, cls).select_published(queryset)
        now = timezone.now()
        queryset = queryset.filter(Q(publication_date=None) | Q(publication_date__lte=now))
        queryset = queryset.filter(Q(expiry_date=None) | Q(expiry_date__gt=now))
{'fraction_non_alphanumeric': 0.09927175162897663, 'fraction_numerical': 0.0007665772326561902, 'mean_word_length': 3.78021978021978, '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': '95856', 'n_tokens_mistral': 743, 'n_tokens_neox': 730, 'n_words': 201}