feat: remove DocAlias
This commit is contained in:
parent
94e9f433f6
commit
96fae0c436
|
@ -7,7 +7,7 @@ from django.db import models
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from .models import (StateType, State, RelatedDocument, DocumentAuthor, Document, RelatedDocHistory,
|
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,
|
StateDocEvent, ConsensusDocEvent, BallotType, BallotDocEvent, WriteupDocEvent, LastCallDocEvent,
|
||||||
TelechatDocEvent, BallotPositionDocEvent, ReviewRequestDocEvent, InitialReviewDocEvent,
|
TelechatDocEvent, BallotPositionDocEvent, ReviewRequestDocEvent, InitialReviewDocEvent,
|
||||||
AddedMessageEvent, SubmissionDocEvent, DeletedEvent, EditedAuthorsDocEvent, DocumentURL,
|
AddedMessageEvent, SubmissionDocEvent, DeletedEvent, EditedAuthorsDocEvent, DocumentURL,
|
||||||
|
@ -27,10 +27,6 @@ class StateAdmin(admin.ModelAdmin):
|
||||||
filter_horizontal = ["next_states"]
|
filter_horizontal = ["next_states"]
|
||||||
admin.site.register(State, StateAdmin)
|
admin.site.register(State, StateAdmin)
|
||||||
|
|
||||||
# class DocAliasInline(admin.TabularInline):
|
|
||||||
# model = DocAlias
|
|
||||||
# extra = 1
|
|
||||||
|
|
||||||
class DocAuthorInline(admin.TabularInline):
|
class DocAuthorInline(admin.TabularInline):
|
||||||
model = DocumentAuthor
|
model = DocumentAuthor
|
||||||
raw_id_fields = ['person', 'email']
|
raw_id_fields = ['person', 'email']
|
||||||
|
@ -71,7 +67,7 @@ class DocumentForm(forms.ModelForm):
|
||||||
|
|
||||||
class DocumentAuthorAdmin(admin.ModelAdmin):
|
class DocumentAuthorAdmin(admin.ModelAdmin):
|
||||||
list_display = ['id', 'document', 'person', 'email', 'affiliation', 'country', 'order']
|
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"]
|
raw_id_fields = ["document", "person", "email"]
|
||||||
admin.site.register(DocumentAuthor, DocumentAuthorAdmin)
|
admin.site.register(DocumentAuthor, DocumentAuthorAdmin)
|
||||||
|
|
||||||
|
@ -109,14 +105,6 @@ class DocHistoryAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
admin.site.register(DocHistory, DocHistoryAdmin)
|
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):
|
class DocReminderAdmin(admin.ModelAdmin):
|
||||||
list_display = ['id', 'event', 'type', 'due', 'active']
|
list_display = ['id', 'event', 'type', 'due', 'active']
|
||||||
list_filter = ['type', 'due', 'active']
|
list_filter = ['type', 'due', 'active']
|
||||||
|
|
|
@ -12,7 +12,7 @@ from typing import Optional # pyflakes:ignore
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils import timezone
|
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,
|
StateDocEvent, BallotPositionDocEvent, BallotDocEvent, BallotType, IRSGBallotDocEvent, TelechatDocEvent,
|
||||||
DocumentActionHolder, BofreqEditorDocEvent, BofreqResponsibleDocEvent, DocExtResource )
|
DocumentActionHolder, BofreqEditorDocEvent, BofreqResponsibleDocEvent, DocExtResource )
|
||||||
from ietf.group.models import Group
|
from ietf.group.models import Group
|
||||||
|
@ -270,23 +270,6 @@ class ReviewFactory(BaseDocumentFactory):
|
||||||
name = factory.LazyAttribute(lambda o: 'review-doesnotexist-00-%s-%s'%(o.group.acronym,date_today().isoformat()))
|
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')
|
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 DocEventFactory(factory.django.DjangoModelFactory):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = DocEvent
|
model = DocEvent
|
||||||
|
|
|
@ -16,7 +16,7 @@ from pathlib import Path
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.management.base import BaseCommand
|
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
|
from ietf.utils.text import xslugify
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@ class Command(BaseCommand):
|
||||||
uploaded_filename=filename,
|
uploaded_filename=filename,
|
||||||
)
|
)
|
||||||
doc.set_state(State.objects.get(type_id="statement", slug="active"))
|
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("-")]
|
year, month, day = [int(part) for part in date_string.split("-")]
|
||||||
e1 = DocEvent.objects.create(
|
e1 = DocEvent.objects.create(
|
||||||
time=datetime.datetime(
|
time=datetime.datetime(
|
||||||
|
|
|
@ -1153,25 +1153,6 @@ class DocHistory(DocumentInfo):
|
||||||
verbose_name = "document history"
|
verbose_name = "document history"
|
||||||
verbose_name_plural = "document histories"
|
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):
|
class DocReminder(models.Model):
|
||||||
event = ForeignKey('DocEvent')
|
event = ForeignKey('DocEvent')
|
||||||
|
|
|
@ -12,7 +12,7 @@ from tastypie.cache import SimpleCache
|
||||||
from ietf import api
|
from ietf import api
|
||||||
|
|
||||||
from ietf.doc.models import (BallotType, DeletedEvent, StateType, State, Document,
|
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,
|
TelechatDocEvent, DocReminder, LastCallDocEvent, NewRevisionDocEvent, WriteupDocEvent,
|
||||||
InitialReviewDocEvent, DocHistoryAuthor, BallotDocEvent, RelatedDocument,
|
InitialReviewDocEvent, DocHistoryAuthor, BallotDocEvent, RelatedDocument,
|
||||||
RelatedDocHistory, BallotPositionDocEvent, AddedMessageEvent, SubmissionDocEvent,
|
RelatedDocHistory, BallotPositionDocEvent, AddedMessageEvent, SubmissionDocEvent,
|
||||||
|
@ -286,21 +286,6 @@ class ConsensusDocEventResource(ModelResource):
|
||||||
}
|
}
|
||||||
api.doc.register(ConsensusDocEventResource())
|
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
|
from ietf.person.resources import PersonResource
|
||||||
class TelechatDocEventResource(ModelResource):
|
class TelechatDocEventResource(ModelResource):
|
||||||
by = ToOneField(PersonResource, 'by')
|
by = ToOneField(PersonResource, 'by')
|
||||||
|
|
|
@ -441,7 +441,6 @@ def update_docs_from_rfc_index(
|
||||||
)
|
)
|
||||||
if created_rfc:
|
if created_rfc:
|
||||||
rfc_changes.append(f"created document {prettify_std_name(doc.name)}")
|
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)
|
doc.set_state(rfc_published_state)
|
||||||
if draft:
|
if draft:
|
||||||
doc.formal_languages.set(draft.formal_languages.all())
|
doc.formal_languages.set(draft.formal_languages.all())
|
||||||
|
|
|
@ -16,7 +16,7 @@ from django.utils import timezone
|
||||||
import debug # pyflakes:ignore
|
import debug # pyflakes:ignore
|
||||||
|
|
||||||
from ietf.doc.factories import WgDraftFactory, RfcFactory
|
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.doc.utils import add_state_change_event
|
||||||
from ietf.group.factories import GroupFactory
|
from ietf.group.factories import GroupFactory
|
||||||
from ietf.person.models import Person
|
from ietf.person.models import Person
|
||||||
|
|
Loading…
Reference in a new issue