From 1ea8ecd12a688f1cedc7a70927ac3ed61879d28c Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 4 Dec 2011 15:14:54 +0100 Subject: [PATCH] Include docs load timestamp in developer docs This makes it possible to figure out when the docs were actually loaded, since developer docs don't carry a version number. This is actually going to be the docs *load* timestamp, and not build timestamp, but they should be close enough together that it shouldn't matter. Fixes #108 --- pgweb/core/models.py | 1 + pgweb/docs/views.py | 3 +++ templates/docs/docspage.html | 2 +- tools/docs/docload.py | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pgweb/core/models.py b/pgweb/core/models.py index f77893ca..ccc4d65f 100644 --- a/pgweb/core/models.py +++ b/pgweb/core/models.py @@ -12,6 +12,7 @@ class Version(PgModel, models.Model): relnotes = models.CharField(max_length=32, null=False, blank=False) current = models.BooleanField(null=False, blank=False, default=False) supported = models.BooleanField(null=False, blank=False, default=True) + docsloaded = models.DateTimeField(null=True, blank=True, help_text="The timestamp of the latest docs load. Really only used for developer docs for now, but set for all of them.") def __unicode__(self): return self.versionstring diff --git a/pgweb/docs/views.py b/pgweb/docs/views.py index d62ee57f..d5969a8b 100644 --- a/pgweb/docs/views.py +++ b/pgweb/docs/views.py @@ -15,6 +15,7 @@ from models import DocPage, DocComment from forms import DocCommentForm def docpage(request, version, typ, filename): + loaddate = None # Get the current version both to map the /current/ url, and to later # determine if we allow comments on this page. currver = Version.objects.filter(current=True)[0].tree @@ -24,6 +25,7 @@ def docpage(request, version, typ, filename): if not typ == 'static': raise Http404("Only static version of developer docs available") ver = Decimal(0) + loaddate = Version.objects.get(tree=Decimal(0)).docsloaded else: ver = Decimal(version) @@ -54,6 +56,7 @@ def docpage(request, version, typ, filename): 'comments': comments, 'can_comment': (typ=="interactive" and ver==currver), 'doc_index_filename': indexname, + 'loaddate': loaddate, }) def docsrootpage(request, version, typ): diff --git a/templates/docs/docspage.html b/templates/docs/docspage.html index 58fcae65..14b0e44e 100644 --- a/templates/docs/docspage.html +++ b/templates/docs/docspage.html @@ -37,7 +37,7 @@
Text Size: Normal / Large
-HomeDocumentationManualsPostgreSQL {{doc_nav_version}} +HomeDocumentationManualsPostgreSQL {{doc_nav_version}}{%if loaddate%} ({{loaddate|date:"Y-m-d H:i:s"}}){%endif%}
diff --git a/tools/docs/docload.py b/tools/docs/docload.py index bf663a48..6946a750 100755 --- a/tools/docs/docload.py +++ b/tools/docs/docload.py @@ -104,6 +104,9 @@ for member in tf: load_doc_file(inner_member.name, inner_tar.extractfile(inner_member)) tf.close() +# Update the docs loaded timestamp +curs.execute("UPDATE core_version SET docsloaded=CURRENT_TIMESTAMP WHERE tree=%(v)s", {'v': ver}) + # Issue varnish purge for all docs of this version if ver == "0": # Special handling of developer docs...