summaryrefslogtreecommitdiff
path: root/pgweb/docs/models.py
diff options
context:
space:
mode:
authorMagnus Hagander2013-08-17 14:47:14 +0000
committerMagnus Hagander2013-08-17 14:48:03 +0000
commit8e458731cba7658bec1957455dc6db753e4bd711 (patch)
tree68a61e0ff54bf7c9cf41995fdaf62b8548b6f054 /pgweb/docs/models.py
parentbeaa87f16231090d13e8ec4b756e94466c9e76b3 (diff)
Make an actual foreign key between docs versions and core versions
This was originally not done because we had a lot of old legacy data that didn't have entries in both tables. This is no longer the case, and the docloads script already enforced that it couldn't happen again. Requires SQL: ALTER TABLE core_version ADD CONSTRAINT version_unique_tree UNIQUE(tree); ALTER TABLE docs ADD CONSTRAINT docs_version_fkey FOREIGN KEY (version) REFERENCES core_version(tree);
Diffstat (limited to 'pgweb/docs/models.py')
-rw-r--r--pgweb/docs/models.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/pgweb/docs/models.py b/pgweb/docs/models.py
index 5ea1497d..d882951e 100644
--- a/pgweb/docs/models.py
+++ b/pgweb/docs/models.py
@@ -8,16 +8,16 @@ from datetime import datetime
class DocPage(models.Model):
id = models.AutoField(null=False, primary_key=True)
file = models.CharField(max_length=64, null=False, blank=False)
- version = models.DecimalField(max_digits=3, decimal_places=1, null=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 == 0:
+ if self.version.tree == 0:
return 'devel'
else:
- return str(self.version)
+ return str(self.version.tree)
class Meta:
db_table = 'docs'