diff --git a/ietf/doc/admin.py b/ietf/doc/admin.py index 203f77c09..cc45d05f1 100644 --- a/ietf/doc/admin.py +++ b/ietf/doc/admin.py @@ -105,7 +105,7 @@ class DocHistoryAdmin(admin.ModelAdmin): list_display = ['doc', 'rev', 'state', 'group', 'pages', 'intended_std_level', 'author_list', 'time'] search_fields = ['doc__name'] ordering = ['time', 'doc', 'rev'] - raw_id_fields = ['doc', 'authors', 'related', 'group', 'shepherd', 'ad'] + raw_id_fields = ['doc', 'authors', 'group', 'shepherd', 'ad'] def state(self, instance): return instance.get_state() diff --git a/ietf/doc/migrations/0006_auto_20150929_0828.py b/ietf/doc/migrations/0006_auto_20150929_0828.py new file mode 100644 index 000000000..d2e29eb67 --- /dev/null +++ b/ietf/doc/migrations/0006_auto_20150929_0828.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0005_auto_20150721_0230'), + ] + + operations = [ + migrations.RemoveField( + model_name='dochistory', + name='related', + ), + migrations.AddField( + model_name='relateddochistory', + name='target_name', + field=models.CharField(default=b'', max_length=255), + preserve_default=True, + ), + migrations.AddField( + model_name='relateddocument', + name='target_name', + field=models.CharField(default=b'', max_length=255), + preserve_default=True, + ), + ] diff --git a/ietf/doc/migrations/0007_auto_20150929_0840.py b/ietf/doc/migrations/0007_auto_20150929_0840.py new file mode 100644 index 000000000..0320d0917 --- /dev/null +++ b/ietf/doc/migrations/0007_auto_20150929_0840.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations +import django.db + +def fill_in_docalias_relationship_names(apps, schema_editor): + with django.db.connection.cursor() as cursor: + cursor.execute("update doc_relateddocument join doc_docalias on doc_docalias.id = doc_relateddocument.target_id set doc_relateddocument.target_name = doc_docalias.name;") + cursor.execute("update doc_relateddochistory join doc_docalias on doc_docalias.id = doc_relateddochistory.target_id set doc_relateddochistory.target_name = doc_docalias.name;") + +def noop(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0006_auto_20150929_0828'), + ] + + operations = [ + migrations.RunPython(fill_in_docalias_relationship_names, noop) + ] diff --git a/ietf/doc/migrations/0008_auto_20150930_0242.py b/ietf/doc/migrations/0008_auto_20150930_0242.py new file mode 100644 index 000000000..b3ff2f593 --- /dev/null +++ b/ietf/doc/migrations/0008_auto_20150930_0242.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0007_auto_20150929_0840'), + ] + + operations = [ + migrations.RemoveField( + model_name='relateddochistory', + name='target', + ), + migrations.RenameField( + model_name='relateddochistory', + old_name='target_name', + new_name='target', + ), + migrations.RemoveField( + model_name='relateddocument', + name='target', + ), + migrations.RenameField( + model_name='relateddocument', + old_name='target_name', + new_name='target', + ), + ] diff --git a/ietf/doc/migrations/0009_auto_20150930_0248.py b/ietf/doc/migrations/0009_auto_20150930_0248.py new file mode 100644 index 000000000..879ae7c88 --- /dev/null +++ b/ietf/doc/migrations/0009_auto_20150930_0248.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0008_auto_20150930_0242'), + ('ipr', '0006_auto_20150930_0235'), + ] + + operations = [ + migrations.RemoveField( + model_name='docalias', + name='id', + ), + migrations.AlterField( + model_name='docalias', + name='name', + field=models.CharField(max_length=255, serialize=False, primary_key=True), + preserve_default=True, + ), + ] diff --git a/ietf/doc/migrations/0010_auto_20150930_0251.py b/ietf/doc/migrations/0010_auto_20150930_0251.py new file mode 100644 index 000000000..f68b9d84f --- /dev/null +++ b/ietf/doc/migrations/0010_auto_20150930_0251.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0009_auto_20150930_0248'), + ] + + operations = [ + migrations.AlterField( + model_name='relateddochistory', + name='target', + field=models.ForeignKey(related_name='reversely_related_document_history_set', to='doc.DocAlias'), + preserve_default=True, + ), + migrations.AlterField( + model_name='relateddocument', + name='target', + field=models.ForeignKey(to='doc.DocAlias'), + preserve_default=True, + ), + ] diff --git a/ietf/doc/models.py b/ietf/doc/models.py index 70bbe2142..ddc20b297 100644 --- a/ietf/doc/models.py +++ b/ietf/doc/models.py @@ -367,7 +367,6 @@ class DocumentAuthor(models.Model): class Document(DocumentInfo): name = models.CharField(max_length=255, primary_key=True) # immutable - #related = models.ManyToManyField('DocAlias', through=RelatedDocument, blank=True, related_name="reversely_related_document_set") authors = models.ManyToManyField(Email, through=DocumentAuthor, blank=True) def __unicode__(self): @@ -540,7 +539,6 @@ class DocHistory(DocumentInfo): # canonical_name and replace the function on Document with a # property name = models.CharField(max_length=255) - related = models.ManyToManyField('DocAlias', through=RelatedDocHistory, blank=True) authors = models.ManyToManyField(Email, through=DocHistoryAuthor, blank=True) def __unicode__(self): return unicode(self.doc.name) @@ -620,8 +618,8 @@ class DocAlias(models.Model): same immutable Document.name, in the tables, but will be referred to by RFC number, primarily, after achieving RFC status. """ + name = models.CharField(max_length=255, primary_key=True) document = models.ForeignKey(Document) - name = models.CharField(max_length=255, db_index=True) def __unicode__(self): return "%s-->%s" % (self.name, self.document.name) document_link = admin_link("document") diff --git a/ietf/doc/tests_draft.py b/ietf/doc/tests_draft.py index 44a9b0b61..2fa8cf1d0 100644 --- a/ietf/doc/tests_draft.py +++ b/ietf/doc/tests_draft.py @@ -1258,7 +1258,7 @@ class ChangeReplacesTests(TestCase): RelatedDocument.objects.create(source=self.replacea, target=self.basea.docalias_set.first(), relationship=DocRelationshipName.objects.get(slug="possibly-replaces")) self.assertEqual(self.basea.get_state().slug,'active') - r = self.client.post(url, dict(replaces=str(DocAlias.objects.get(name=self.basea.name).id))) + r = self.client.post(url, dict(replaces=self.basea.name)) self.assertEqual(r.status_code, 302) self.assertEqual(RelatedDocument.objects.filter(relationship__slug='replaces',source=self.replacea).count(),1) self.assertEqual(Document.objects.get(name='draft-test-base-a').get_state().slug,'repl') @@ -1267,7 +1267,7 @@ class ChangeReplacesTests(TestCase): # Post that says replaceboth replaces both base a and base b url = urlreverse('doc_change_replaces', kwargs=dict(name=self.replaceboth.name)) self.assertEqual(self.baseb.get_state().slug,'expired') - r = self.client.post(url, dict(replaces=str(DocAlias.objects.get(name=self.basea.name).id) + "," + str(DocAlias.objects.get(name=self.baseb.name).id))) + r = self.client.post(url, dict(replaces=self.basea.name + "," + self.baseb.name)) self.assertEqual(r.status_code, 302) self.assertEqual(Document.objects.get(name='draft-test-base-a').get_state().slug,'repl') self.assertEqual(Document.objects.get(name='draft-test-base-b').get_state().slug,'repl') diff --git a/ietf/idindex/tests.py b/ietf/idindex/tests.py index c60c4cbad..556eff881 100644 --- a/ietf/idindex/tests.py +++ b/ietf/idindex/tests.py @@ -124,7 +124,6 @@ class IndexTests(TestCase): e = LastCallDocEvent.objects.create(doc=draft, type="sent_last_call", expires=datetime.datetime.now() + datetime.timedelta(days=14), by=draft.ad) - DocAlias.objects.create(name="rfc1234", document=draft) t = get_fields(all_id2_txt()) self.assertEqual(t[11], e.expires.strftime("%Y-%m-%d")) diff --git a/ietf/ipr/migrations/0004_iprdocrel_document_name.py b/ietf/ipr/migrations/0004_iprdocrel_document_name.py new file mode 100644 index 000000000..933a8972f --- /dev/null +++ b/ietf/ipr/migrations/0004_iprdocrel_document_name.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('ipr', '0003_auto_20150430_0847'), + ] + + operations = [ + migrations.AddField( + model_name='iprdocrel', + name='document_name', + field=models.CharField(default=b'', max_length=255), + preserve_default=True, + ), + ] diff --git a/ietf/ipr/migrations/0005_auto_20150930_0227.py b/ietf/ipr/migrations/0005_auto_20150930_0227.py new file mode 100644 index 000000000..61bfd0194 --- /dev/null +++ b/ietf/ipr/migrations/0005_auto_20150930_0227.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations +import django.db + +def fill_in_docalias_relationship_names(apps, schema_editor): + with django.db.connection.cursor() as cursor: + cursor.execute("update ipr_iprdocrel join doc_docalias on doc_docalias.id = ipr_iprdocrel.document_id set ipr_iprdocrel.document_name = doc_docalias.name;") + +def noop(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('ipr', '0004_iprdocrel_document_name'), + ] + + operations = [ + migrations.RunPython(fill_in_docalias_relationship_names, noop) + ] diff --git a/ietf/ipr/migrations/0006_auto_20150930_0235.py b/ietf/ipr/migrations/0006_auto_20150930_0235.py new file mode 100644 index 000000000..2fd48b013 --- /dev/null +++ b/ietf/ipr/migrations/0006_auto_20150930_0235.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('ipr', '0005_auto_20150930_0227'), + ] + + operations = [ + migrations.RemoveField( + model_name='iprdisclosurebase', + name='docs', + ), + migrations.RemoveField( + model_name='iprdocrel', + name='document', + ), + migrations.RenameField( + model_name='iprdocrel', + old_name='document_name', + new_name='document', + ), + ] diff --git a/ietf/ipr/migrations/0007_auto_20150930_0258.py b/ietf/ipr/migrations/0007_auto_20150930_0258.py new file mode 100644 index 000000000..045866ada --- /dev/null +++ b/ietf/ipr/migrations/0007_auto_20150930_0258.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('doc', '0010_auto_20150930_0251'), + ('ipr', '0006_auto_20150930_0235'), + ] + + operations = [ + migrations.AddField( + model_name='iprdisclosurebase', + name='docs', + field=models.ManyToManyField(to='doc.DocAlias', through='ipr.IprDocRel'), + preserve_default=True, + ), + migrations.AlterField( + model_name='iprdocrel', + name='document', + field=models.ForeignKey(to='doc.DocAlias'), + preserve_default=True, + ), + ]