Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add unicity constraints to the docs models.

  • Loading branch information...
commit a4e34ad48767bbbdf46e2dc265bc816c8f632b91 1 parent 1d0d28e
@aaugustin aaugustin authored
Showing with 52 additions and 0 deletions.
  1. +46 −0 docs/migrations/0005_add_unicity_constaints.py
  2. +6 −0 docs/models.py
View
46 docs/migrations/0005_add_unicity_constaints.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding unique constraint on 'DocumentRelease', fields ['lang', 'version']
+ db.create_unique(u'docs_documentrelease', ['lang', 'version'])
+
+ # Adding unique constraint on 'Document', fields ['release', 'path']
+ db.create_unique(u'docs_document', ['release_id', 'path'])
+
+
+ def backwards(self, orm):
+ # Removing unique constraint on 'Document', fields ['release', 'path']
+ db.delete_unique(u'docs_document', ['release_id', 'path'])
+
+ # Removing unique constraint on 'DocumentRelease', fields ['lang', 'version']
+ db.delete_unique(u'docs_documentrelease', ['lang', 'version'])
+
+
+ models = {
+ u'docs.document': {
+ 'Meta': {'unique_together': "(('release', 'path'),)", 'object_name': 'Document'},
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'path': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
+ 'release': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'documents'", 'to': u"orm['docs.DocumentRelease']"}),
+ 'title': ('django.db.models.fields.CharField', [], {'max_length': '500'})
+ },
+ u'docs.documentrelease': {
+ 'Meta': {'unique_together': "(('lang', 'version'),)", 'object_name': 'DocumentRelease'},
+ 'docs_subdir': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
+ u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'is_default': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'lang': ('django.db.models.fields.CharField', [], {'default': "'en'", 'max_length': '2'}),
+ 'scm': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
+ 'scm_url': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+ 'version': ('django.db.models.fields.CharField', [], {'max_length': '20'})
+ }
+ }
+
+ complete_apps = ['docs']
View
6 docs/models.py
@@ -41,6 +41,9 @@ class DocumentRelease(models.Model):
objects = DocumentReleaseManager()
+ class Meta:
+ unique_together = ('lang', 'version')
+
def __unicode__(self):
return "%s/%s" % (self.lang, self.version)
@@ -78,6 +81,9 @@ class Document(models.Model):
path = models.CharField(max_length=500)
title = models.CharField(max_length=500)
+ class Meta:
+ unique_together = ('release', 'path')
+
def __unicode__(self):
return "/".join([self.release.lang, self.release.version, self.path])
Please sign in to comment.
Something went wrong with that request. Please try again.