Permalink
Browse files

Permit multiple entries for a particular foreign word.

Fixes #16. After discussion with Matt, we decided not to enforce any
uniqueness constraint here. This required retrofitting a couple of
migrations, but since the code doesn't work for databases that enforce
unique constraints prior to this commit, this won't break any existing
installs.
  • Loading branch information...
1 parent d42b91f commit 54ff9fabefc787147e9f0b9f199ac99cf20f676d @malcolmt committed Oct 31, 2010
@@ -1,76 +0,0 @@
-# encoding: 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 'Word', fields ['word', 'language']
- db.create_unique('minerva_word', ['word', 'language'])
-
-
- def backwards(self, orm):
-
- # Removing unique constraint on 'Word', fields ['word', 'language']
- db.delete_unique('minerva_word', ['word', 'language'])
-
-
- models = {
- 'auth.group': {
- 'Meta': {'object_name': 'Group'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
- 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
- },
- 'auth.permission': {
- 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
- 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- },
- 'auth.user': {
- 'Meta': {'object_name': 'User'},
- 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
- 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
- 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
- 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
- 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
- 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
- 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
- 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
- },
- 'contenttypes.contenttype': {
- 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
- 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
- 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
- },
- 'minerva.progress': {
- 'Meta': {'object_name': 'Progress'},
- 'attempts': ('django.db.models.fields.PositiveIntegerField', [], {}),
- 'correct': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'student': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
- 'word': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['minerva.Word']"})
- },
- 'minerva.word': {
- 'Meta': {'unique_together': "(('word', 'language'),)", 'object_name': 'Word'},
- 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
- 'language': ('django.db.models.fields.CharField', [], {'max_length': '3'}),
- 'level': ('django.db.models.fields.PositiveIntegerField', [], {}),
- 'meaning': ('django.db.models.fields.TextField', [], {}),
- 'word': ('django.db.models.fields.CharField', [], {'max_length': '50'})
- }
- }
-
- complete_apps = ['minerva']
@@ -7,34 +7,20 @@
class Migration(SchemaMigration):
def forwards(self, orm):
-
- # Removing unique constraint on 'Word', fields ['word', 'language']
- db.delete_unique('minerva_word', ['word', 'language'])
-
# Deleting field 'Word.language'
db.delete_column('minerva_word', 'language')
# Changing field 'Word.lang_code'
db.alter_column('minerva_word', 'lang_code_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['minerva.Language']))
- # Adding unique constraint on 'Word', fields ['lang_code', 'word']
- db.create_unique('minerva_word', ['lang_code_id', 'word'])
-
def backwards(self, orm):
-
- # Removing unique constraint on 'Word', fields ['lang_code', 'word']
- db.delete_unique('minerva_word', ['lang_code_id', 'word'])
-
# Adding field 'Word.language'
db.add_column('minerva_word', 'language', self.gf('django.db.models.fields.CharField')(default=1, max_length=3), keep_default=False)
# Changing field 'Word.lang_code'
db.alter_column('minerva_word', 'lang_code_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['minerva.Language'], null=True))
- # Adding unique constraint on 'Word', fields ['word', 'language']
- db.create_unique('minerva_word', ['word', 'language'])
-
models = {
'auth.group': {
View
@@ -31,9 +31,6 @@ class Word(models.Model):
objects = WordManager()
- class Meta:
- unique_together = ("word", "lang_code")
-
def __unicode__(self):
return u"%s (%s)" % (self.word, self.meaning)

0 comments on commit 54ff9fa

Please sign in to comment.