class Document(db.TimeStampedBase): owner = db.ForeignKey(kind=Member) logo = db.Binary() template = db.ForeignKey(kind=Template) name = db.String() injections = db.JSON() assembly = db.JSON() declarations = db.JSON() pdf = db.String() revision = db.Integer(default=0) signup_sheet = db.Boolean(default=True) table_of_contents = db.Boolean(default=True) declaration_page = db.Boolean(default=True) pretty_filenames = db.Boolean(default=True) section_page_breaks = db.Boolean(default=False) def summary(self): d = { "key": self.id(), "name": self.name, "revision": self.revision, "pdf": self.pdf, "created": str(self.created)[:19], "modified": str(self.modified)[:19], "declarations": self.declarations or {} } if self.template: t = self.template.get() d["template"] = {"key": t.id(), "name": t.name} return d def content(self, sections=None): return self.template.get().content( sections, page_breaks=self.section_page_breaks)
class Section(SecBase): image = db.Binary() headerless = db.Boolean(default=False) def labeler(self): return "%s [%s]" % (self.name, self.index) def header(self): return self.headerless and " " or self.name def desc(self, depth=0, novars=False): d = self.fixed_desc(depth, novars) if not self.image: return d return "%s\r\n\r\n![](%s)" % (d, symage(self.image.path))
class Table(db.TimeStampedBase): name = db.String() csv = db.Binary()
class Photo(db.TimeStampedBase): img = db.Binary() caption = db.String() label = "caption"
class VideoPost(BasePost): # rename this, simplify code, migrate old dbs? video = db.Binary() poster = db.Binary()
class Post(BasePost): img = db.Binary() body = db.Text()
class Image(db.TimeStampedBase): image = db.Binary() link = db.String()
class Media(LibItem): item = db.Binary() kind = db.String(choices=["img", "video", "audio", "pdf"])