PageRenderTime 75ms CodeModel.GetById 33ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 0ms

/django/contrib/flatpages/admin.py

https://code.google.com/p/mango-py/
Python | 28 lines | 22 code | 6 blank | 0 comment | 0 complexity | d6eb2c235879b9fb2b25d4812614124d MD5 | raw file
 1from django import forms
 2from django.contrib import admin
 3from django.contrib.flatpages.models import FlatPage
 4from django.utils.translation import ugettext_lazy as _
 5
 6
 7class FlatpageForm(forms.ModelForm):
 8    url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
 9        help_text = _("Example: '/about/contact/'. Make sure to have leading"
10                      " and trailing slashes."),
11        error_message = _("This value must contain only letters, numbers,"
12                          " dots, underscores, dashes, slashes or tildes."))
13
14    class Meta:
15        model = FlatPage
16
17
18class FlatPageAdmin(admin.ModelAdmin):
19    form = FlatpageForm
20    fieldsets = (
21        (None, {'fields': ('url', 'title', 'content', 'sites')}),
22        (_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
23    )
24    list_display = ('url', 'title')
25    list_filter = ('sites', 'enable_comments', 'registration_required')
26    search_fields = ('url', 'title')
27
28admin.site.register(FlatPage, FlatPageAdmin)