2021-09-28 13:10:22 +00:00
|
|
|
import logging
|
2021-10-10 15:06:43 +00:00
|
|
|
import json
|
2021-09-28 13:10:22 +00:00
|
|
|
|
2021-10-10 15:06:43 +00:00
|
|
|
from django.conf import settings
|
2021-09-28 13:10:22 +00:00
|
|
|
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)
|
|
|
|
|
2021-10-11 12:26:51 +00:00
|
|
|
slug = models.SlugField(blank=True)
|
2021-09-28 13:10:22 +00:00
|
|
|
public = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
|
2021-10-11 12:26:51 +00:00
|
|
|
title = models.TextField(blank=True)
|
|
|
|
#teaser = models.TextField(blank=True)
|
|
|
|
body = models.TextField(blank=True)
|
|
|
|
data = models.JSONField(default=dict, blank=True)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return '%s (%s)' % (self.title, self.slug)
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
if self.slug:
|
|
|
|
return '/' + settings.URL_PREFIX + '' + self.slug
|
|
|
|
else:
|
|
|
|
return '/' + settings.URL_PREFIX[:-1]
|
|
|
|
|
2021-09-28 13:10:22 +00:00
|
|
|
|
2021-10-10 15:06:43 +00:00
|
|
|
class Text(models.Model):
|
2021-09-28 13:10:22 +00:00
|
|
|
created = models.DateTimeField(auto_now_add=True)
|
|
|
|
modified = models.DateTimeField(auto_now=True)
|
|
|
|
|
|
|
|
slug = models.SlugField()
|
|
|
|
public = models.BooleanField(default=False)
|
|
|
|
|
2021-10-10 15:06:43 +00:00
|
|
|
title = models.TextField()
|
|
|
|
teaser = models.TextField(default="", blank=True)
|
|
|
|
body = models.TextField(default="", blank=True)
|
|
|
|
|
2021-09-28 13:10:22 +00:00
|
|
|
data = models.JSONField(default=dict)
|
|
|
|
|
2021-10-10 15:06:43 +00:00
|
|
|
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)
|