initial upload

This commit is contained in:
2022-04-21 13:49:31 +02:00
parent fc93b5552a
commit e3d4616e62
51 changed files with 1677 additions and 54 deletions

View File

@@ -0,0 +1,33 @@
import datetime #<- will be used to set default dates on models
from cao_blogr.models.meta import Base #<- we need to import our sqlalchemy metadata from which model classes will inherit
from sqlalchemy import (
Column,
Integer,
Unicode, #<- will provide Unicode field
UnicodeText, #<- will provide Unicode text field
DateTime, #<- time abstraction field
)
from webhelpers2.text import urlify #<- will generate slugs
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates
class BlogRecord(Base):
__tablename__ = 'entries'
id = Column(Integer, primary_key=True)
title = Column(Unicode(255), unique=True, nullable=False)
body = Column(UnicodeText, default=u'')
body_html = Column(UnicodeText, default=u'')
tag = Column(Unicode, default=u'pyramid')
topic = Column(Unicode, default=u'blog')
created = Column(DateTime, default=datetime.datetime.utcnow)
edited = Column(DateTime, default=datetime.datetime.utcnow)
@property
def slug(self):
return urlify(self.title)
@property
def created_in_words(self):
return distance_of_time_in_words(self.created,
datetime.datetime.utcnow())