summaryrefslogtreecommitdiff
path: root/pgweb/docs/models.py
diff options
context:
space:
mode:
authorMagnus Hagander2017-05-25 15:28:39 +0000
committerMagnus Hagander2017-05-25 15:28:39 +0000
commit496416ceda9c1015d9e7a6ef4b4fb18dae8a8d4e (patch)
tree6a8bb4c48be04e66fa399e2e8cadb4433dd008b6 /pgweb/docs/models.py
parent0585a97556d9673883b5bc3fbfbd3471b60b5704 (diff)
Invent the concept of a docs page alias
This allows us to say that "app-pgreceivexlog.html" is actually the same as "app-pgreceivewal.html" on a different version. Turns out the templates would already render this correctly if we could just find the map, so it's a simple case of adding an additional join (that the django orm can't figure out, but we can do it in manual sql). Adds a non-django managed unique index to make sure that it's not possible to add the same alias twice in different "directions". Violating this will cause a django excpetion in the admin interface since it doesn't know about it, but as this is a very uncommon operation and admin only, we don't care about that. Finally, we don't bother issuing varnish purges for changes here, the admin is expected to handle those manually. These changes are supposed to happen very seldom, and the contents are purged automatically when the docs are loaded anyway.
Diffstat (limited to 'pgweb/docs/models.py')
-rw-r--r--pgweb/docs/models.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/pgweb/docs/models.py b/pgweb/docs/models.py
index 0c99240b..d5aa1859 100644
--- a/pgweb/docs/models.py
+++ b/pgweb/docs/models.py
@@ -20,3 +20,15 @@ class DocPage(models.Model):
db_table = 'docs'
# Index file first, because we want to list versions by file
unique_together = [('file', 'version')]
+
+class DocPageAlias(models.Model):
+ file1 = models.CharField(max_length=64, null=False, blank=False, unique=True)
+ file2 = models.CharField(max_length=64, null=False, blank=False, unique=True)
+
+ def __unicode__(self):
+ return u"%s <-> %s" % (self.file1, self.file2)
+
+ # XXX: needs a unique functional index as well, see the migration!
+ class Meta:
+ db_table = 'docsalias'
+ verbose_name_plural='Doc page aliases'