mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00

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.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from django.db import models
|
|
from django.contrib.auth.models import User
|
|
from pgweb.core.models import Version
|
|
|
|
class DocPage(models.Model):
|
|
id = models.AutoField(null=False, primary_key=True)
|
|
file = models.CharField(max_length=64, null=False, blank=False)
|
|
version = models.ForeignKey(Version, null=False, blank=False, db_column='version', to_field='tree')
|
|
title = models.CharField(max_length=256, null=True, blank=True)
|
|
content = models.TextField(null=True, blank=True)
|
|
|
|
def display_version(self):
|
|
"""Version as used for displaying and in URLs"""
|
|
if self.version.tree == 0:
|
|
return 'devel'
|
|
else:
|
|
return str(self.version.numtree)
|
|
|
|
class Meta:
|
|
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'
|