From c6ba694941fb222c7d7bee96e87748621b80873c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 8 Jun 2015 13:24:01 +0200 Subject: [PATCH 1/1] planet: Update posting header --- static/css/style.css | 4 ++++ templates/planet/posting.html | 37 +++++++++++++++++++++++------------ webapp/backend/planet.py | 13 ++++++++++++ 3 files changed, 42 insertions(+), 12 deletions(-) diff --git a/static/css/style.css b/static/css/style.css index 0bd54ca..0f01509 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -72,6 +72,10 @@ section > .page-header ~ .page-header { text-align: center; } +.jumbotron a { + color: white; +} + /* Download button */ .masthead .btn, .download-button { padding: 19px 24px; diff --git a/templates/planet/posting.html b/templates/planet/posting.html index 9be8c74..dcc1d13 100644 --- a/templates/planet/posting.html +++ b/templates/planet/posting.html @@ -2,20 +2,23 @@ {% block title %}{{ entry.title }}{% end block %} -{% block body %} - +

+ {{ _("by") }} {{ entry.author.name }} + • {{ locale.format_date(entry.published, shorter=True) }} +

+ + +{% end header %} +{% block body %} {% if entry.is_draft() %}
@@ -26,4 +29,14 @@ {% module PlanetAuthorBox(entry.author) %} {% raw entry.text %} + +
+ +

+ {{ _("Posted:") }} {{ locale.format_date(entry.published, shorter=True, relative=False) }} + + • + + {{ _("One view", "%(views)s views", entry.views) % { "views" : entry.views } }} +

{% end block %} diff --git a/webapp/backend/planet.py b/webapp/backend/planet.py index d116ced..9916770 100644 --- a/webapp/backend/planet.py +++ b/webapp/backend/planet.py @@ -119,6 +119,19 @@ class PlanetEntry(Object): self.db.execute("INSERT INTO planet_views(post_id, referer, location) \ VALUES(%s, %s, %s)", self.id, referer, location) + if hasattr(self, "_views"): + self._views += 1 + + @property + def views(self): + if not hasattr(self, "_views"): + res = self.db.get("SELECT COUNT(*) AS views FROM planet_views \ + WHERE post_id = %s", self.id) + + self._views = res.views + + return self._views + class Planet(Object): def get_authors(self): -- 2.39.2