Skip to content

Commit 4946430

Browse files
committed
chore: checkpoint: halfway through removing docalias
1 parent a867de2 commit 4946430

49 files changed

Lines changed: 8618 additions & 8677 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ietf/bin/recalculate-rfc-authors-snapshot

Lines changed: 8290 additions & 8288 deletions
Large diffs are not rendered by default.

ietf/community/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def reset_name_contains_index_for_rule(rule):
6060
if not rule.rule_type == "name_contains":
6161
return
6262

63-
rule.name_contains_index.set(Document.objects.filter(docalias__name__regex=rule.text))
63+
rule.name_contains_index.set(Document.objects.filter(name__regex=rule.text))
6464

6565
def update_name_contains_indexes_with_new_doc(doc):
6666
for r in SearchRule.objects.filter(rule_type="name_contains"):
@@ -182,7 +182,7 @@ def docs_tracked_by_community_list(clist):
182182
doc_ids = set()
183183
for doc in clist.added_docs.all():
184184
doc_ids.add(doc.pk)
185-
doc_ids.update(alias.docs.first().pk for alias in doc.related_that_doc("became_rfc"))
185+
doc_ids.update(rfc.pk for rfc in doc.related_that_doc("became_rfc"))
186186

187187
for rule in clist.searchrule_set.all():
188188
doc_ids = doc_ids | set(docs_matching_community_list_rule(rule).values_list("pk", flat=True))

ietf/community/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def manage_list(request, username=None, acronym=None, group_type=None):
129129

130130
@login_required
131131
def track_document(request, name, username=None, acronym=None):
132-
doc = get_object_or_404(Document, docalias__name=name)
132+
doc = get_object_or_404(Document, name=name)
133133

134134
if request.method == "POST":
135135
clist = lookup_community_list(username, acronym)
@@ -153,7 +153,7 @@ def track_document(request, name, username=None, acronym=None):
153153

154154
@login_required
155155
def untrack_document(request, name, username=None, acronym=None):
156-
doc = get_object_or_404(Document, docalias__name=name)
156+
doc = get_object_or_404(Document, name=name)
157157
clist = lookup_community_list(username, acronym)
158158
if not can_manage_community_list(request.user, clist):
159159
permission_denied(request, "You do not have permission to access this view")

ietf/doc/factories.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ def name(self, n):
5252

5353
newrevisiondocevent = factory.RelatedFactory('ietf.doc.factories.NewRevisionDocEventFactory','doc')
5454

55-
@factory.post_generation
56-
def other_aliases(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
57-
alias = DocAliasFactory(name=obj.name)
58-
alias.docs.add(obj)
59-
if create and extracted:
60-
for name in extracted:
61-
alias = DocAliasFactory(name=name)
62-
alias.docs.add(obj)
63-
6455
@factory.post_generation
6556
def states(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
6657
if create and extracted:

ietf/doc/feeds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DocumentChangesFeed(Feed):
3636
feed_type = Atom1Feed
3737

3838
def get_object(self, request, name):
39-
return Document.objects.get(docalias__name=name)
39+
return Document.objects.get(name=name)
4040

4141
def title(self, obj):
4242
return "Changes for %s" % obj.display_name()

ietf/doc/fields.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import debug # pyflakes:ignore
1515

16-
from ietf.doc.models import Document, DocAlias
16+
from ietf.doc.models import Document
1717
from ietf.doc.utils import uppercase_std_abbreviated_name
1818
from ietf.utils.fields import SearchableField
1919

@@ -69,19 +69,3 @@ def ajax_url(self):
6969
class SearchableDocumentField(SearchableDocumentsField):
7070
"""Specialized to only return one Document"""
7171
max_entries = 1
72-
73-
74-
class SearchableDocAliasesField(SearchableDocumentsField):
75-
"""Search DocAliases instead of Documents"""
76-
model = DocAlias # type: Type[models.Model]
77-
78-
def doc_type_filter(self, queryset):
79-
"""Filter to include only desired doc type
80-
81-
For DocAlias, pass through to the docs to check type.
82-
"""
83-
return queryset.filter(docs__type=self.doc_type)
84-
85-
class SearchableDocAliasField(SearchableDocAliasesField):
86-
"""Specialized to only return one DocAlias"""
87-
max_entries = 1

ietf/doc/mails.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ietf.utils import log
2020
from ietf.utils.mail import send_mail, send_mail_text
2121
from ietf.ipr.utils import iprs_from_docs, related_docs
22-
from ietf.doc.models import WriteupDocEvent, LastCallDocEvent, DocAlias, ConsensusDocEvent
22+
from ietf.doc.models import WriteupDocEvent, LastCallDocEvent, ConsensusDocEvent
2323
from ietf.doc.utils import needed_ballot_positions
2424
from ietf.doc.utils_bofreq import bofreq_editors, bofreq_responsible
2525
from ietf.group.models import Role
@@ -202,7 +202,7 @@ def generate_last_call_announcement(request, doc):
202202

203203
doc.filled_title = textwrap.fill(doc.title, width=70, subsequent_indent=" " * 3)
204204

205-
iprs = iprs_from_docs(related_docs(DocAlias.objects.get(name=doc.canonical_name())))
205+
iprs = iprs_from_docs(related_docs(Document.objects.get(name=doc.canonical_name())))
206206
if iprs:
207207
ipr_links = [ urlreverse("ietf.ipr.views.show", kwargs=dict(id=i.id)) for i in iprs]
208208
ipr_links = [ settings.IDTRACKER_BASE_URL+url if not url.startswith("http") else url for url in ipr_links ]
@@ -670,7 +670,7 @@ def send_review_possibly_replaces_request(request, doc, submitter_info):
670670
to = set(addrs.to)
671671
cc = set(addrs.cc)
672672

673-
possibly_replaces = Document.objects.filter(name__in=[alias.name for alias in doc.related_that_doc("possibly-replaces")])
673+
possibly_replaces = Document.objects.filter(name__in=[related.name for related in doc.related_that_doc("possibly-replaces")])
674674
for other_doc in possibly_replaces:
675675
(other_to, other_cc) = gather_address_lists('doc_replacement_suggested',doc=other_doc)
676676
to.update(other_to)

ietf/doc/models.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def friendly_state(self):
355355
elif state.slug == "repl":
356356
rs = self.related_that("replaces")
357357
if rs:
358-
return mark_safe("Replaced by " + ", ".join("<a href=\"%s\">%s</a>" % (urlreverse('ietf.doc.views_doc.document_main', kwargs=dict(name=alias.document.name)), alias.document) for alias in rs))
358+
return mark_safe("Replaced by " + ", ".join("<a href=\"%s\">%s</a>" % (urlreverse('ietf.doc.views_doc.document_main', kwargs=dict(name=related.name)), related) for related in rs))
359359
else:
360360
return "Replaced"
361361
elif state.slug == "active":
@@ -493,10 +493,10 @@ def all_relations_that_doc(self, relationship, related=None):
493493
return related
494494

495495
def related_that(self, relationship):
496-
return list(set([x.source.docalias.get(name=x.source.name) for x in self.relations_that(relationship)]))
496+
return list(set([x.source for x in self.relations_that(relationship)]))
497497

498498
def all_related_that(self, relationship, related=None):
499-
return list(set([x.source.docalias.get(name=x.source.name) for x in self.all_relations_that(relationship)]))
499+
return list(set([x.source for x in self.all_relations_that(relationship)]))
500500

501501
def related_that_doc(self, relationship):
502502
return list(set([x.target for x in self.relations_that_doc(relationship)]))
@@ -843,20 +843,6 @@ def latest_event(self, *args, **filter_args):
843843
e = model.objects.filter(doc=self).filter(**filter_args).order_by('-time', '-id').first()
844844
return e
845845

846-
def canonical_name(self):
847-
if not hasattr(self, '_canonical_name'):
848-
name = self.name
849-
if self.type_id == "draft" and self.get_state_slug() == "rfc":
850-
a = self.docalias.filter(name__startswith="rfc").order_by('-name').first()
851-
if a:
852-
name = a.name
853-
self._canonical_name = name
854-
return self._canonical_name
855-
856-
857-
def canonical_docalias(self):
858-
return self.docalias.get(name=self.name)
859-
860846
def display_name(self):
861847
name = self.canonical_name()
862848
if name.startswith('rfc'):
@@ -963,8 +949,8 @@ def related_ipr(self):
963949
from ietf.ipr.models import IprDocRel
964950
iprs = (
965951
IprDocRel.objects.filter(
966-
document__in=list(self.docalias.all())
967-
+ [x.docalias.first() for x in self.all_related_that_doc(("obs", "replaces"))] # this really is docalias until IprDocRel changes
952+
document__in=list(self)
953+
+ self.all_related_that_doc(("obs", "replaces"))
968954
)
969955
.filter(disclosure__state__in=("posted", "removed"))
970956
.values_list("disclosure", flat=True)
@@ -1157,10 +1143,6 @@ def last_presented(self):
11571143
def groupmilestone_set(self):
11581144
return self.doc.groupmilestone_set
11591145

1160-
@property
1161-
def docalias(self):
1162-
return self.doc.docalias
1163-
11641146
def is_dochistory(self):
11651147
return True
11661148

ietf/doc/resources.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ class Meta:
490490
from ietf.name.resources import DocRelationshipNameResource
491491
class RelatedDocumentResource(ModelResource):
492492
source = ToOneField(DocumentResource, 'source')
493-
target = ToOneField(DocAliasResource, 'target')
493+
target = ToOneField(DocumentResource, 'target')
494494
relationship = ToOneField(DocRelationshipNameResource, 'relationship')
495495
class Meta:
496496
cache = SimpleCache()
@@ -509,7 +509,7 @@ class Meta:
509509
from ietf.name.resources import DocRelationshipNameResource
510510
class RelatedDocHistoryResource(ModelResource):
511511
source = ToOneField(DocHistoryResource, 'source')
512-
target = ToOneField(DocAliasResource, 'target')
512+
target = ToOneField(DocumentResource, 'target')
513513
relationship = ToOneField(DocRelationshipNameResource, 'relationship')
514514
class Meta:
515515
cache = SimpleCache()

ietf/doc/templatetags/ietf_filters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import debug # pyflakes:ignore
2424

25-
from ietf.doc.models import BallotDocEvent, DocAlias
25+
from ietf.doc.models import BallotDocEvent, Document
2626
from ietf.doc.models import ConsensusDocEvent
2727
from ietf.ietfauth.utils import can_request_rfc_publication as utils_can_request_rfc_publication
2828
from ietf.utils.html import sanitize_fragment
@@ -146,8 +146,9 @@ def find_unique(n):
146146
key = hash(n)
147147
found = cache.get(key)
148148
if not found:
149-
exact = DocAlias.objects.filter(name=n).first()
149+
exact = Document.objects.filter(name=n)
150150
found = exact.name if exact else "_"
151+
# TODO review this cache policy (and the need for these entire function)
151152
cache.set(key, found, timeout=60*60*24) # cache for one day
152153
return None if found == "_" else found
153154

0 commit comments

Comments
 (0)