Skip to content

Commit

Permalink
feat: remove DocAlias
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsparks committed Aug 19, 2023
1 parent 94e9f43 commit 96fae0c
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 71 deletions.
16 changes: 2 additions & 14 deletions ietf/doc/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django import forms

from .models import (StateType, State, RelatedDocument, DocumentAuthor, Document, RelatedDocHistory,
DocHistoryAuthor, DocHistory, DocAlias, DocReminder, DocEvent, NewRevisionDocEvent,
DocHistoryAuthor, DocHistory, DocReminder, DocEvent, NewRevisionDocEvent,
StateDocEvent, ConsensusDocEvent, BallotType, BallotDocEvent, WriteupDocEvent, LastCallDocEvent,
TelechatDocEvent, BallotPositionDocEvent, ReviewRequestDocEvent, InitialReviewDocEvent,
AddedMessageEvent, SubmissionDocEvent, DeletedEvent, EditedAuthorsDocEvent, DocumentURL,
Expand All @@ -27,10 +27,6 @@ class StateAdmin(admin.ModelAdmin):
filter_horizontal = ["next_states"]
admin.site.register(State, StateAdmin)

# class DocAliasInline(admin.TabularInline):
# model = DocAlias
# extra = 1

class DocAuthorInline(admin.TabularInline):
model = DocumentAuthor
raw_id_fields = ['person', 'email']
Expand Down Expand Up @@ -71,7 +67,7 @@ class Meta:

class DocumentAuthorAdmin(admin.ModelAdmin):
list_display = ['id', 'document', 'person', 'email', 'affiliation', 'country', 'order']
search_fields = ['document__docalias__name', 'person__name', 'email__address', 'affiliation', 'country']
search_fields = ['document__name', 'person__name', 'email__address', 'affiliation', 'country']
raw_id_fields = ["document", "person", "email"]
admin.site.register(DocumentAuthor, DocumentAuthorAdmin)

Expand Down Expand Up @@ -109,14 +105,6 @@ def state(self, instance):

admin.site.register(DocHistory, DocHistoryAdmin)

class DocAliasAdmin(admin.ModelAdmin):
list_display = ['name', 'targets']
search_fields = ['name']
raw_id_fields = ['docs']
def targets(self, obj):
return ', '.join([o.name for o in obj.docs.all()])
admin.site.register(DocAlias, DocAliasAdmin)

class DocReminderAdmin(admin.ModelAdmin):
list_display = ['id', 'event', 'type', 'due', 'active']
list_filter = ['type', 'due', 'active']
Expand Down
19 changes: 1 addition & 18 deletions ietf/doc/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.conf import settings
from django.utils import timezone

from ietf.doc.models import ( Document, DocEvent, NewRevisionDocEvent, DocAlias, State, DocumentAuthor,
from ietf.doc.models import ( Document, DocEvent, NewRevisionDocEvent, State, DocumentAuthor,
StateDocEvent, BallotPositionDocEvent, BallotDocEvent, BallotType, IRSGBallotDocEvent, TelechatDocEvent,
DocumentActionHolder, BofreqEditorDocEvent, BofreqResponsibleDocEvent, DocExtResource )
from ietf.group.models import Group
Expand Down Expand Up @@ -270,23 +270,6 @@ class ReviewFactory(BaseDocumentFactory):
name = factory.LazyAttribute(lambda o: 'review-doesnotexist-00-%s-%s'%(o.group.acronym,date_today().isoformat()))
group = factory.SubFactory('ietf.group.factories.GroupFactory',type_id='review')

class DocAliasFactory(factory.django.DjangoModelFactory):
class Meta:
model = DocAlias

@factory.post_generation
def document(self, create, extracted, **kwargs):
if create and extracted:
self.docs.add(extracted)

@factory.post_generation
def docs(self, create, extracted, **kwargs):
if create and extracted:
for doc in extracted:
if not doc in self.docs.all():
self.docs.add(doc)


class DocEventFactory(factory.django.DjangoModelFactory):
class Meta:
model = DocEvent
Expand Down
3 changes: 1 addition & 2 deletions ietf/doc/management/commands/import_iab_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.conf import settings
from django.core.management.base import BaseCommand

from ietf.doc.models import Document, DocAlias, DocEvent, State
from ietf.doc.models import Document, DocEvent, State
from ietf.utils.text import xslugify


Expand Down Expand Up @@ -95,7 +95,6 @@ def handle(self, *args, **options):
uploaded_filename=filename,
)
doc.set_state(State.objects.get(type_id="statement", slug="active"))
DocAlias.objects.create(name=doc.name).docs.add(doc)
year, month, day = [int(part) for part in date_string.split("-")]
e1 = DocEvent.objects.create(
time=datetime.datetime(
Expand Down
19 changes: 0 additions & 19 deletions ietf/doc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,25 +1153,6 @@ class Meta:
verbose_name = "document history"
verbose_name_plural = "document histories"

class DocAlias(models.Model):
"""This is used for documents that may appear under multiple names,
and in particular for RFCs, which for continuity still keep the
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, unique=True)
docs = models.ManyToManyField(Document, related_name='docalias')

@property
def document(self):
return self.docs.first()

def __str__(self):
return u"%s-->%s" % (self.name, ','.join([force_str(d.name) for d in self.docs.all() if isinstance(d, Document) ]))
document_link = admin_link("document")
class Meta:
verbose_name = "document alias"
verbose_name_plural = "document aliases"

class DocReminder(models.Model):
event = ForeignKey('DocEvent')
Expand Down
17 changes: 1 addition & 16 deletions ietf/doc/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ietf import api

from ietf.doc.models import (BallotType, DeletedEvent, StateType, State, Document,
DocumentAuthor, DocEvent, StateDocEvent, DocHistory, ConsensusDocEvent, DocAlias,
DocumentAuthor, DocEvent, StateDocEvent, DocHistory, ConsensusDocEvent,
TelechatDocEvent, DocReminder, LastCallDocEvent, NewRevisionDocEvent, WriteupDocEvent,
InitialReviewDocEvent, DocHistoryAuthor, BallotDocEvent, RelatedDocument,
RelatedDocHistory, BallotPositionDocEvent, AddedMessageEvent, SubmissionDocEvent,
Expand Down Expand Up @@ -286,21 +286,6 @@ class Meta:
}
api.doc.register(ConsensusDocEventResource())

class DocAliasResource(ModelResource):
document = ToOneField(DocumentResource, 'document')
class Meta:
cache = SimpleCache()
queryset = DocAlias.objects.all()
serializer = api.Serializer()
detail_uri_name = 'name'
#resource_name = 'docalias'
ordering = ['id', ]
filtering = {
"name": ALL,
"document": ALL_WITH_RELATIONS,
}
api.doc.register(DocAliasResource())

from ietf.person.resources import PersonResource
class TelechatDocEventResource(ModelResource):
by = ToOneField(PersonResource, 'by')
Expand Down
1 change: 0 additions & 1 deletion ietf/sync/rfceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ def update_docs_from_rfc_index(
)
if created_rfc:
rfc_changes.append(f"created document {prettify_std_name(doc.name)}")
# Create DocAlias (for consistency until we drop DocAlias altogether)
doc.set_state(rfc_published_state)
if draft:
doc.formal_languages.set(draft.formal_languages.all())
Expand Down
2 changes: 1 addition & 1 deletion ietf/sync/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import debug # pyflakes:ignore

from ietf.doc.factories import WgDraftFactory, RfcFactory
from ietf.doc.models import Document, DocAlias, DocEvent, DeletedEvent, DocTagName, RelatedDocument, State, StateDocEvent
from ietf.doc.models import Document, DocEvent, DeletedEvent, DocTagName, RelatedDocument, State, StateDocEvent
from ietf.doc.utils import add_state_change_event
from ietf.group.factories import GroupFactory
from ietf.person.models import Person
Expand Down

0 comments on commit 96fae0c

Please sign in to comment.