from things.models import Thing, register_thing from things import attrs, types from .utils import clear_snippet_cache class Snippet(Thing): cls_attrs = ( { "name": "HTML Allowed", "key": "allow_html", "description": "If this isn't checked, HTML will be stripped out of the {{ model }}.", "datatype": types.TYPE_BOOLEAN, "editable": False }, attrs.CONTENT, ) public_order_by = '-updated_at' class Meta: proxy = True def save(self, *args, **kwargs): self.published_at = timezone.now() super(Snippet, self).save(*args, **kwargs) clear_snippet_cache(self) register_thing(Snippet)
from things import attrs, models PAGE_ATTRIBUTES = ( attrs.CONTENT, ) class Page(models.Thing): class Meta: proxy = True models.register_thing(Page, PAGE_ATTRIBUTES)
'published_at__lte': datetime.now().replace(second=0, microsecond=0) } super_user_order = ['-published_at', '-created_at'] public_order = "-published_at" class Meta: proxy = True POST_PHOTO_ATTRIBUTES = ( attrs.IMAGE, { "name": "Related Post", "key": "post", "description": "The Post related to the {{ model }}.", "datatype": types.TYPE_FOREIGNKEY, "required": True, "model": Post }, ) class PostPhoto(models.Thing): class Meta: proxy = True models.register_thing(Post, POST_ATTRIBUTES) models.register_thing(PostPhoto, POST_PHOTO_ATTRIBUTES)