diff --git a/brewman/brewman/models/auth.py b/brewman/brewman/models/auth.py index b625816e..97e37958 100644 --- a/brewman/brewman/models/auth.py +++ b/brewman/brewman/models/auth.py @@ -130,6 +130,10 @@ class User(Base): def list(cls): return DBSession.query(cls).order_by(cls.name).all() + @classmethod + def query(cls): + return DBSession.query(cls) + @classmethod def filtered_list(cls, name): query = DBSession.query(cls) diff --git a/brewman/brewman/models/messaging.py b/brewman/brewman/models/messaging.py index 7285c4fe..7e08d012 100644 --- a/brewman/brewman/models/messaging.py +++ b/brewman/brewman/models/messaging.py @@ -63,7 +63,7 @@ class Thread(Base): def __init__(self, title=None, creation_date=None, user_id=None, priority=5, public=False, closed=False): self.title = title - self.creation_date = datetime.now() if creation_date is None else creation_date + self.creation_date = datetime.utcnow() if creation_date is None else creation_date self.user_id = user_id self.priority = priority self.public = public @@ -96,7 +96,7 @@ class Post(Base): def __init__(self, content='', creation_date=None, user_id=None, date=None): self.content = content - self.creation_date = datetime.now() if creation_date is None else creation_date + self.creation_date = datetime.utcnow() if creation_date is None else creation_date self.user_id = user_id self.date = self.creation_date if date is None else date @@ -123,7 +123,7 @@ class Subscriber(Base): user = relationship('User', primaryjoin="User.id==Subscriber.user_id", cascade=None) - def __init__(self, thread_id=None, user_id=None, read=None): + def __init__(self, thread_id=None, user_id=None, read=False): self.thread_id = thread_id self.user_id = user_id self.read = read \ No newline at end of file diff --git a/brewman/brewman/models/tzinfoutc.py b/brewman/brewman/models/tzinfoutc.py new file mode 100644 index 00000000..78085421 --- /dev/null +++ b/brewman/brewman/models/tzinfoutc.py @@ -0,0 +1,35 @@ +from datetime import timedelta, tzinfo, datetime + +__author__ = 'tanshu' + + +ZERO = timedelta(0) +HOUR = timedelta(hours=1) + +# A UTC class. + +class UTC(tzinfo): + """UTC""" + + def utcoffset(self, dt): + return ZERO + + def tzname(self, dt): + return "UTC" + + def dst(self, dt): + return ZERO + +utc = UTC() + + +def get_age(old_date): + now = datetime.utcnow().replace(tzinfo=utc) + delta = now - old_date + if delta.days > 0: + return '{0} days'.format(delta.days) + if delta.seconds > 3600: + return '{0} hours'.format(delta.seconds // 3600) + if delta.seconds > 60: + return '{0} minutes'.format(delta.seconds // 3600) + return '{0} seconds'.format(delta.seconds) diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index 6e069717..b3de24ea 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2013-05-30.1 +# version 2013-06-06.1 CACHE: /partial/404.html diff --git a/brewman/brewman/static/partial/home.html b/brewman/brewman/static/partial/home.html index 32b7ba5b..6647a80a 100644 --- a/brewman/brewman/static/partial/home.html +++ b/brewman/brewman/static/partial/home.html @@ -18,17 +18,28 @@
+ + + + + + +
+ + +
Details
+
- + -

{{item.Title}}

+

{{item.Title}}

{{tag}}
diff --git a/brewman/brewman/static/partial/message-detail.html b/brewman/brewman/static/partial/message-detail.html index 2d6b1f21..a366c673 100644 --- a/brewman/brewman/static/partial/message-detail.html +++ b/brewman/brewman/static/partial/message-detail.html @@ -4,7 +4,8 @@
- +
@@ -32,13 +33,30 @@
+
+ + +
+ +
+