added topic listing
This commit is contained in:
@@ -6,6 +6,7 @@ from sqlalchemy import (
|
||||
Unicode, #<- will provide Unicode field
|
||||
UnicodeText, #<- will provide Unicode text field
|
||||
DateTime, #<- time abstraction field
|
||||
Index,
|
||||
)
|
||||
from webhelpers2.text import urlify #<- will generate slugs
|
||||
from webhelpers2.date import distance_of_time_in_words #<- human friendly dates
|
||||
@@ -15,10 +16,10 @@ 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='pyramid')
|
||||
topic = Column(Unicode, default='blog')
|
||||
body = Column(UnicodeText, default='')
|
||||
body_html = Column(UnicodeText, default='')
|
||||
tag = Column(Unicode(25), index=True)
|
||||
topic = Column(Unicode(25), index=True)
|
||||
created = Column(DateTime, default=datetime.datetime.utcnow)
|
||||
edited = Column(DateTime, default=datetime.datetime.utcnow)
|
||||
|
||||
@@ -28,6 +29,19 @@ class BlogRecord(Base):
|
||||
|
||||
@property
|
||||
def created_in_words(self):
|
||||
return distance_of_time_in_words(self.created,
|
||||
datetime.datetime.utcnow())
|
||||
return distance_of_time_in_words(self.created, datetime.datetime.utcnow())
|
||||
|
||||
|
||||
class Topics(Base):
|
||||
__tablename__ = 'topics'
|
||||
topic = Column(Unicode(25), primary_key=True)
|
||||
topic_name = Column(Unicode(25), nullable=False)
|
||||
|
||||
|
||||
class Tags(Base):
|
||||
__tablename__ = 'tags'
|
||||
id = Column(Integer, primary_key=True)
|
||||
topic = Column(Unicode(25))
|
||||
tag = Column(Unicode(25))
|
||||
tag_name = Column(Unicode(25), nullable=False)
|
||||
__table_args__ = (Index('topic_index', "topic", "tag"), )
|
||||
|
||||
Reference in New Issue
Block a user