admin_rich_text.py 521 B

12345678910111213141516171819
  1. from django import forms
  2. from tinymce.widgets import TinyMCE
  3. from landing.models import LandingPage
  4. from landing.rich_text import sanitize_rich_html
  5. class LandingPageAdminForm(forms.ModelForm):
  6. """Editor widget boundary for LandingPage rich HTML."""
  7. class Meta:
  8. model = LandingPage
  9. fields = "__all__"
  10. widgets = {
  11. "content": TinyMCE(attrs={"cols": 80, "rows": 24}),
  12. }
  13. def clean_content(self):
  14. return sanitize_rich_html(self.cleaned_data.get("content"))