app/django/contrib/flatpages/admin.py
author Lennard de Rijk <ljvderijk@gmail.com>
Fri, 13 Mar 2009 13:26:03 +0000
changeset 1828 3db2a7be7239
parent 323 ff1a9aa48cfd
permissions -rw-r--r--
Changed the edit template to show a Submit button instead of Save Changes when "creating" an entity. This is because Save Changes confuses people, it has the tendency to imply a partial save. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed

from django import forms
from django.contrib import admin
from django.contrib.flatpages.models import FlatPage
from django.utils.translation import ugettext_lazy as _


class FlatpageForm(forms.ModelForm):
    url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/]+$',
        help_text = _("Example: '/about/contact/'. Make sure to have leading"
                      " and trailing slashes."),
        error_message = _("This value must contain only letters, numbers,"
                          " underscores, dashes or slashes."))

    class Meta:
        model = FlatPage


class FlatPageAdmin(admin.ModelAdmin):
    form = FlatpageForm
    fieldsets = (
        (None, {'fields': ('url', 'title', 'content', 'sites')}),
        (_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
    )
    list_display = ('url', 'title')
    list_filter = ('sites', 'enable_comments', 'registration_required')
    search_fields = ('url', 'title')

admin.site.register(FlatPage, FlatPageAdmin)