import logging import json from django.conf import settings from django.contrib.auth import get_user_model from django.db import models logger = logging.getLogger(__name__) User = get_user_model() class Page(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) slug = models.SlugField() public = models.BooleanField(default=False) data = models.JSONField(default=dict) title = models.TextField() teaser = models.TextField() body = models.TextField() class Text(models.Model): created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) slug = models.SlugField() public = models.BooleanField(default=False) title = models.TextField() teaser = models.TextField(default="", blank=True) body = models.TextField(default="", blank=True) data = models.JSONField(default=dict) def __str__(self): return self.title def get_absolute_url(self): return '/' + settings.URL_PREFIX + 'assemblies/' + self.slug def json(self): data = {} data['title'] = self.title data.update(self.data) return json.dumps(data)