2006-05-02 09:31:56 +08:00
from django . core import validators
from django . db import models
from django . contrib . sites . models import Site
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
from django . utils . translation import ugettext_lazy as _
2006-05-02 09:31:56 +08:00
class FlatPage ( models . Model ) :
2007-08-05 13:14:46 +08:00
url = models . CharField ( _ ( ' URL ' ) , max_length = 100 , validator_list = [ validators . isAlphaNumericURL ] , db_index = True ,
2006-05-02 09:31:56 +08:00
help_text = _ ( " Example: ' /about/contact/ ' . Make sure to have leading and trailing slashes. " ) )
2007-08-05 13:14:46 +08:00
title = models . CharField ( _ ( ' title ' ) , max_length = 200 )
2006-05-02 09:31:56 +08:00
content = models . TextField ( _ ( ' content ' ) )
enable_comments = models . BooleanField ( _ ( ' enable comments ' ) )
2007-08-05 13:14:46 +08:00
template_name = models . CharField ( _ ( ' template name ' ) , max_length = 70 , blank = True ,
2006-07-10 06:35:08 +08:00
help_text = _ ( " Example: ' flatpages/contact_page.html ' . If this isn ' t provided, the system will use ' flatpages/default.html ' . " ) )
2006-05-02 09:31:56 +08:00
registration_required = models . BooleanField ( _ ( ' registration required ' ) , help_text = _ ( " If this is checked, only logged-in users will be able to view the page. " ) )
sites = models . ManyToManyField ( Site )
class Meta :
db_table = ' django_flatpage '
verbose_name = _ ( ' flat page ' )
verbose_name_plural = _ ( ' flat pages ' )
ordering = ( ' url ' , )
class Admin :
fields = (
( None , { ' fields ' : ( ' url ' , ' title ' , ' content ' , ' sites ' ) } ) ,
( ' Advanced options ' , { ' classes ' : ' collapse ' , ' fields ' : ( ' enable_comments ' , ' registration_required ' , ' template_name ' ) } ) ,
)
list_filter = ( ' sites ' , )
search_fields = ( ' url ' , ' title ' )
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
def __unicode__ ( self ) :
return u " %s -- %s " % ( self . url , self . title )
2006-05-02 09:31:56 +08:00
def get_absolute_url ( self ) :
return self . url