PageRenderTime 21ms CodeModel.GetById 18ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. from django import forms
  2. from django.contrib import admin
  3. from django.contrib.flatpages.models import FlatPage
  4. from django.utils.translation import ugettext_lazy as _
  5. class FlatpageForm(forms.ModelForm):
  6. url = forms.RegexField(label=_("URL"), max_length=100, regex=r'^[-\w/\.~]+$',
  7. help_text = _("Example: '/about/contact/'. Make sure to have leading"
  8. " and trailing slashes."),
  9. error_message = _("This value must contain only letters, numbers,"
  10. " dots, underscores, dashes, slashes or tildes."))
  11. class Meta:
  12. model = FlatPage
  13. class FlatPageAdmin(admin.ModelAdmin):
  14. form = FlatpageForm
  15. fieldsets = (
  16. (None, {'fields': ('url', 'title', 'content', 'sites')}),
  17. (_('Advanced options'), {'classes': ('collapse',), 'fields': ('enable_comments', 'registration_required', 'template_name')}),
  18. )
  19. list_display = ('url', 'title')
  20. list_filter = ('sites', 'enable_comments', 'registration_required')
  21. search_fields = ('url', 'title')
  22. admin.site.register(FlatPage, FlatPageAdmin)