Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Table Demo</title>
<!-- Tell the browser to be responsive to screen width -->
<!-- Tabulator Table -->
<link rel="stylesheet" href="https://unpkg.com/tabulator-tables@4.3.0/dist/css/tabulator.min.css">
@dkirkham
dkirkham / tests.py
Created June 5, 2021 09:41
Wagtail tests, creating image file to match JSON fixtures
from wagtail.tests.utils import WagtailPageTests
import os
import PIL.Image
from django.core.files.images import ImageFile
from wagtail.images import get_image_model
Image = get_image_model()
def make_test_image_file(filename='hero.jpg', colour='white', size=(960, 450)):
if os.access(filename, os.R_OK):
@dkirkham
dkirkham / models.py
Created July 17, 2021 00:31
This validator checks the amount of text in a RichTextField, by stripping away basic formatting markup. It also incorporates an adjustment for markup that causes line breaks.
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from proj.richtext_validator import RichTextLengthValidator
class AuthorPage(Page):
biography = RichTextField(
max_length=3600,
validators=[RichTextLengthValidator(3000, line_length=50)],