<commit_before># -*- coding: UTF-8 -*-
# Application: Vimba - CMS
# Module: www
# Copyright (c) 2010 Vimba inc. All rights reserved.
# Created by <NAME> on 30-05-2010.
import datetime

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.contenttypes import generic
from django.db.models import signals

from vcms.www.models.menu import CMSMenu
from vcms.www.fields import StatusField
from vcms.www.models.language import Language

from vcms.www.managers.page import BasicPageManager
    
class BasicPage(models.Model):
    """ A page is a placeholder accessible by the user that represents a section content
        Like a news page, a forum page with multiple sub-section, a contact page ...
        A page can have multiple sub-section define in the application urls

        -- Link
        The CMS generate links to make these placeholder accessible in menus
        it uses the follow pattern : /{APP_SLUGS}/page/{page_slug}/
        ex: A basic Page model will be accessible at : /www/page/examplepage
            A news page model will be accessible at : /news/page/newspage

        -- Language
        Page can be classified by language - NOTE not yet working
        # TODO : add multi-language fonctionnality
    """
    name = models.CharField(max_length=100, unique=False, help_text=_('Max 100 characters.'))
    status = StatusField()
    slug = models.SlugField(max_length=150, unique=True, help_text=_("Used for hyperlinks, no spaces or special characters."))
    app_slug = models.SlugField(default="", editable=False, null=True, blank=True)
    module = models.CharField(max_length=30, default='', editable=False)
    description = models.CharField(max_length=250, help_text=_("Short description of the page (helps with search engine optimization.)"))
    keywords = models.CharField(max_length=250, null=True, blank=True, help_text=_("Page keywords (Help for search engine optimization.)"))
    
    date_created = models.DateTimeField(auto_now_add=True, editable=False)
    date_modified = models.DateTimeField(auto_now=True, editable=False)
    date_published = models.DateTimeField(default=datetime.datetime.min, editable=False)
    language = models.ForeignKey(Language)
    
    menu = generic.GenericRelation(CMSMenu)
    
    objects = BasicPageManager()

    # Generic FK to the container, used as an inheritance workaround
    #widget_type = models.ForeignKey(ContentType)
    #widget_id = models.PositiveIntegerField()
    #widget = generic.GenericForeignKey('widget_type', 'widget_id')
    

    class Meta:
        verbose_name = _("Page - Basic page (do not edit)")
        verbose_name_plural = _("Page - Basic pages (do not edit)")
        app_label = 'www'

    def __unicode__(self):
        return self.name

    def get_name(self):
        return self.__unicode__()

    def get_absolute_url(self):
        return "/www/page/" + self.slug

    def _add_to_main_menu(self, root):
        root.add_child(menu_name=self.name, content_object=self)

    @staticmethod
    def get_containers():
        raise NotImplementedError()
    
    @staticmethod
    def get_menu(self):
        raise NotImplementedError()<commit_msg>remove custom field in page to make it works with south<commit_after># -*- coding: UTF-8 -*-
# Application: Vimba - CMS
# Module: www
# Copyright (c) 2010 Vimba inc. All rights reserved.
# Created by <NAME> on 30-05-2010.
import datetime

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.contenttypes import generic
from django.db.models import signals

from vcms.www.models.menu import CMSMenu
from vcms.www.models.language import Language

from vcms.www.managers.page import BasicPageManager


class BasicPage(models.Model):
    DRAFT = 0
    PUBLISHED = 1
    STATUSES = (
        (DRAFT, _('Draft')),
        (PUBLISHED, _('Published')),
    )
    """ A page is a placeholder accessible by the user that represents a section content
        Like a news page, a forum page with multiple sub-section, a contact page ...
        A page can have multiple sub-section define in the application urls

        -- Link
        The CMS generate links to make these placeholder accessible in menus
        it uses the follow pattern : /{APP_SLUGS}/page/{page_slug}/
        ex: A basic Page model will be accessible at : /www/page/examplepage
            A news page model will be accessible at : /news/page/newspage

        -- Language
        Page can be classified by language - NOTE not yet working
        # TODO : add multi-language fonctionnality
    """
    name = models.CharField(max_length=100, unique=False, help_text=_('Max 100 characters.'))
    
    status = models.PositiveIntegerField(choices=STATUSES, default=STATUSES[DRAFT])

    slug = models.SlugField(max_length=150, unique=True, help_text=_("Used for hyperlinks, no spaces or special characters."))
    app_slug = models.SlugField(default="", editable=False, null=True, blank=True)
    module = models.CharField(max_length=30, default='', editable=False)
    description = models.CharField(max_length=250, help_text=_("Short description of the page (helps with search engine optimization.)"))
    keywords = models.CharField(max_length=250, null=True, blank=True, help_text=_("Page keywords (Help for search engine optimization.)"))
    
    date_created = models.DateTimeField(auto_now_add=True, editable=False)
    date_modified = models.DateTimeField(auto_now=True, editable=False)
    date_published = models.DateTimeField(default=datetime.datetime.min, editable=False)
    language = models.ForeignKey(Language)
    
    menu = generic.GenericRelation(CMSMenu)
    
    objects = BasicPageManager()

    # Generic FK to the container, used as an inheritance workaround
    #widget_type = models.ForeignKey(ContentType)
    #widget_id = models.PositiveIntegerField()
    #widget = generic.GenericForeignKey('widget_type', 'widget_id')

    class Meta:
        verbose_name = _("Page - Basic page (do not edit)")
        verbose_name_plural = _("Page - Basic pages (do not edit)")
        app_label = 'www'

    def __unicode__(self):
        return self.name

    def get_name(self):
        return self.__unicode__()

    def get_absolute_url(self):
        return "/www/page/" + self.slug

    def _add_to_main_menu(self, root):
        root.add_child(menu_name=self.name, content_object=self)

    @staticmethod
    def get_containers():
        raise NotImplementedError()
    
    @staticmethod
    def get_menu(self):
        raise NotImplementedError()
{'fraction_non_alphanumeric': 0.093513185813883, 'fraction_numerical': 0.009396786905122764, 'mean_word_length': 3.4921715452688904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 13, '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': '1186904', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1860, 'n_words': 569}