mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00
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.
This commit is contained in:
@ -54,9 +54,13 @@ def docpage(request, version, typ, filename):
|
||||
|
||||
fullname = "%s.%s" % (filename, extension)
|
||||
page = get_object_or_404(DocPage, version=ver, file=fullname)
|
||||
versions = DocPage.objects.filter(file=fullname).extra(select={
|
||||
'supported':"COALESCE((SELECT supported FROM core_version v WHERE v.tree=version), 'f')",
|
||||
'testing':"COALESCE((SELECT testing FROM core_version v WHERE v.tree=version),0)",
|
||||
qq = Q(file=fullname) | Q(file='kalle.html')
|
||||
versions = DocPage.objects.extra(
|
||||
where=["file=%s OR file IN (SELECT file2 FROM docsalias WHERE file1=%s) OR file IN (SELECT file1 FROM docsalias WHERE file2=%s)"],
|
||||
params=[fullname, fullname, fullname],
|
||||
select={
|
||||
'supported':"COALESCE((SELECT supported FROM core_version v WHERE v.tree=version), 'f')",
|
||||
'testing':"COALESCE((SELECT testing FROM core_version v WHERE v.tree=version),0)",
|
||||
}).order_by('-supported', '-version').only('version', 'file')
|
||||
|
||||
if typ=="interactive":
|
||||
|
Reference in New Issue
Block a user