2012-06-08 00:08:47 +08:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.sites.models import Site
|
2013-02-24 20:25:17 +08:00
|
|
|
from django.core.urlresolvers import get_script_prefix
|
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 _
|
2013-02-24 20:12:41 +08:00
|
|
|
from django.utils.encoding import iri_to_uri, python_2_unicode_compatible
|
2008-03-30 00:42:39 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2006-05-02 09:31:56 +08:00
|
|
|
class FlatPage(models.Model):
|
2008-08-11 12:28:33 +08:00
|
|
|
url = models.CharField(_('URL'), max_length=100, db_index=True)
|
2007-08-05 13:14:46 +08:00
|
|
|
title = models.CharField(_('title'), max_length=200)
|
2008-06-30 21:05:47 +08:00
|
|
|
content = models.TextField(_('content'), blank=True)
|
2013-03-24 20:47:01 +08:00
|
|
|
enable_comments = models.BooleanField(_('enable comments'), default=False)
|
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'."))
|
2013-03-24 20:47:01 +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."),
|
|
|
|
default=False)
|
2006-05-02 09:31:56 +08:00
|
|
|
sites = models.ManyToManyField(Site)
|
2008-03-30 00:42:39 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class Meta:
|
|
|
|
db_table = 'django_flatpage'
|
|
|
|
verbose_name = _('flat page')
|
|
|
|
verbose_name_plural = _('flat pages')
|
|
|
|
ordering = ('url',)
|
2008-08-11 12:28:33 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
def __str__(self):
|
2012-06-08 00:08:47 +08:00
|
|
|
return "%s -- %s" % (self.url, self.title)
|
2006-05-02 09:31:56 +08:00
|
|
|
|
|
|
|
def get_absolute_url(self):
|
2013-02-24 20:25:17 +08:00
|
|
|
# Handle script prefix manually because we bypass reverse()
|
|
|
|
return iri_to_uri(get_script_prefix().rstrip('/') + self.url)
|