Skip to content

Commit 4daf66d

Browse files
committed
Added DocEvent rev= parameter througout the code.
- Legacy-Id: 12978
1 parent ff31644 commit 4daf66d

44 files changed

Lines changed: 361 additions & 172 deletions

Some content is hidden

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

PLAN

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,10 @@ Updated: $Date$
77
Planned work in rough order
88
===========================
99

10-
* Add a 'rev' field to DocEvent, migrate 'rev' information from New
11-
Revision and Submit DocEvents, and infer 'rev' information for others
12-
13-
* Break out the htmlzation code used on tools in a library, and use that
14-
in the datatracker rendering, replacing the simpler code currently in use.
15-
This is also going to require some fancy caching, to avoid re-building the
16-
html if not needed, as it takes quite some time.
10+
* Break out the htmlzation code used on tools.ietf.org in a library, and use
11+
that in the datatracker rendering, replacing the simpler code currently in
12+
use. This is also going to require some fancy caching, to avoid re-building
13+
the html if not needed, as it takes quite some time.
1714

1815
* Use the htmlization lib to improve the rendering of draft text in the
1916
datatracker's /doc/draft-foo-bar/ pages.

ietf/doc/expire.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def expire_draft(doc):
143143
if e:
144144
events.append(e)
145145

146-
events.append(DocEvent.objects.create(doc=doc, by=system, type="expired_document", desc="Document has expired"))
146+
events.append(DocEvent.objects.create(doc=doc, rev=doc.rev, by=system, type="expired_document", desc="Document has expired"))
147147

148148
doc.set_state(State.objects.get(used=True, type="draft", slug="expired"))
149149
doc.save_with_history(events)

ietf/doc/factories.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ class Meta:
7979
doc = factory.SubFactory(DocumentFactory)
8080
desc = factory.Faker('sentence',nb_words=6)
8181

82+
@factory.lazy_attribute
83+
def rev(self):
84+
return self.doc.rev
85+
8286
class NewRevisionDocEventFactory(DocEventFactory):
8387
class Meta:
8488
model = NewRevisionDocEvent

ietf/doc/lastcall.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def request_last_call(request, doc):
2828
e.type = "requested_last_call"
2929
e.by = request.user.person
3030
e.doc = doc
31+
e.rev = doc.rev
3132
e.desc = "Last call was requested"
3233
e.save()
3334

ietf/doc/mails.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def generate_ballot_writeup(request, doc):
112112
e.type = "changed_ballot_writeup_text"
113113
e.by = request.user.person
114114
e.doc = doc
115+
e.rev = doc.rev
115116
e.desc = u"Ballot writeup was generated"
116117
e.text = unicode(render_to_string("doc/mail/ballot_writeup.txt", {'iana': iana}))
117118

@@ -123,6 +124,7 @@ def generate_ballot_rfceditornote(request, doc):
123124
e.type = "changed_ballot_rfceditornote_text"
124125
e.by = request.user.person
125126
e.doc = doc
127+
e.rev = doc.rev
126128
e.desc = u"RFC Editor Note for ballot was generated"
127129
e.text = unicode(render_to_string("doc/mail/ballot_rfceditornote.txt"))
128130
e.save()
@@ -167,6 +169,7 @@ def generate_last_call_announcement(request, doc):
167169
e.type = "changed_last_call_text"
168170
e.by = request.user.person
169171
e.doc = doc
172+
e.rev = doc.rev
170173
e.desc = u"Last call announcement was generated"
171174
e.text = unicode(mail)
172175

@@ -186,6 +189,7 @@ def generate_approval_mail(request, doc):
186189
e.type = "changed_ballot_approval_text"
187190
e.by = request.user.person
188191
e.doc = doc
192+
e.rev = doc.rev
189193
e.desc = u"Ballot approval text was generated"
190194
e.text = unicode(mail)
191195

ietf/doc/models.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from ietf.name.models import ( DocTypeName, DocTagName, StreamName, IntendedStdLevelName, StdLevelName,
1818
DocRelationshipName, DocReminderTypeName, BallotPositionName, ReviewRequestStateName )
1919
from ietf.person.models import Email, Person
20+
from ietf.utils import log
2021
from ietf.utils.admin import admin_link
2122
from ietf.utils.validators import validate_no_control_chars
2223

@@ -760,7 +761,7 @@ class DocEvent(models.Model):
760761
type = models.CharField(max_length=50, choices=EVENT_TYPES)
761762
by = models.ForeignKey(Person)
762763
doc = models.ForeignKey('doc.Document')
763-
rev = models.CharField(verbose_name="revision", max_length=16, blank=True)
764+
rev = models.CharField(verbose_name="revision", max_length=16, null=True, blank=True)
764765
desc = models.TextField()
765766

766767
def for_current_revision(self):
@@ -773,6 +774,10 @@ def get_dochistory(self):
773774
def __unicode__(self):
774775
return u"%s %s by %s at %s" % (self.doc.name, self.get_type_display().lower(), self.by.plain_name(), self.time)
775776

777+
def save(self, *args, **kwargs):
778+
super(DocEvent, self).save(*args, **kwargs)
779+
log.assertion('self.rev != None')
780+
776781
class Meta:
777782
ordering = ['-time', '-id']
778783

@@ -854,7 +859,7 @@ def all_positions(self):
854859
norecord = BallotPositionName.objects.get(slug="norecord")
855860
for ad in active_ads:
856861
if ad not in seen:
857-
e = BallotPositionDocEvent(type="changed_ballot_position", doc=self.doc, ad=ad)
862+
e = BallotPositionDocEvent(type="changed_ballot_position", doc=self.doc, rev=self.doc.rev, ad=ad)
858863
e.by = ad
859864
e.pos = norecord
860865
e.old_ad = False

ietf/doc/resources.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class Meta:
162162
"id": ALL,
163163
"time": ALL,
164164
"type": ALL,
165+
"rev": ALL,
165166
"desc": ALL,
166167
"by": ALL_WITH_RELATIONS,
167168
"doc": ALL_WITH_RELATIONS,
@@ -184,6 +185,7 @@ class Meta:
184185
"id": ALL,
185186
"time": ALL,
186187
"type": ALL,
188+
"rev": ALL,
187189
"desc": ALL,
188190
"by": ALL_WITH_RELATIONS,
189191
"doc": ALL_WITH_RELATIONS,
@@ -255,6 +257,7 @@ class Meta:
255257
"id": ALL,
256258
"time": ALL,
257259
"type": ALL,
260+
"rev": ALL,
258261
"desc": ALL,
259262
"consensus": ALL,
260263
"by": ALL_WITH_RELATIONS,
@@ -290,6 +293,7 @@ class Meta:
290293
"id": ALL,
291294
"time": ALL,
292295
"type": ALL,
296+
"rev": ALL,
293297
"desc": ALL,
294298
"telechat_date": ALL,
295299
"returning_item": ALL,
@@ -331,6 +335,7 @@ class Meta:
331335
"id": ALL,
332336
"time": ALL,
333337
"type": ALL,
338+
"rev": ALL,
334339
"desc": ALL,
335340
"expires": ALL,
336341
"by": ALL_WITH_RELATIONS,
@@ -375,6 +380,7 @@ class Meta:
375380
"id": ALL,
376381
"time": ALL,
377382
"type": ALL,
383+
"rev": ALL,
378384
"desc": ALL,
379385
"text": ALL,
380386
"by": ALL_WITH_RELATIONS,
@@ -397,6 +403,7 @@ class Meta:
397403
"id": ALL,
398404
"time": ALL,
399405
"type": ALL,
406+
"rev": ALL,
400407
"desc": ALL,
401408
"expires": ALL,
402409
"by": ALL_WITH_RELATIONS,
@@ -437,6 +444,7 @@ class Meta:
437444
"id": ALL,
438445
"time": ALL,
439446
"type": ALL,
447+
"rev": ALL,
440448
"desc": ALL,
441449
"by": ALL_WITH_RELATIONS,
442450
"doc": ALL_WITH_RELATIONS,
@@ -499,6 +507,7 @@ class Meta:
499507
"id": ALL,
500508
"time": ALL,
501509
"type": ALL,
510+
"rev": ALL,
502511
"desc": ALL,
503512
"discuss": ALL,
504513
"discuss_time": ALL,
@@ -530,6 +539,7 @@ class Meta:
530539
"id": ALL,
531540
"time": ALL,
532541
"type": ALL,
542+
"rev": ALL,
533543
"desc": ALL,
534544
"msgtype": ALL,
535545
"by": ALL_WITH_RELATIONS,
@@ -582,6 +592,7 @@ class Meta:
582592
"id": ALL,
583593
"time": ALL,
584594
"type": ALL,
595+
"rev": ALL,
585596
"desc": ALL,
586597
"by": ALL_WITH_RELATIONS,
587598
"doc": ALL_WITH_RELATIONS,

ietf/doc/tests.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ def test_search(self):
119119
def test_search_for_name(self):
120120
draft = make_test_data()
121121
make_meeting_test_data()
122-
draft.save_with_history([DocEvent.objects.create(doc=draft, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
122+
draft.save_with_history([DocEvent.objects.create(doc=draft, rev=draft.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
123123

124124
prev_rev = draft.rev
125125
draft.rev = "%02d" % (int(prev_rev) + 1)
126-
draft.save_with_history([DocEvent.objects.create(doc=draft, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
126+
draft.save_with_history([DocEvent.objects.create(doc=draft, rev=draft.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
127127

128128
# exact match
129129
r = self.client.get(urlreverse('ietf.doc.views_search.search_for_name', kwargs=dict(name=draft.name)))
@@ -526,7 +526,7 @@ def test_document_draft(self):
526526
# draft published as RFC
527527
draft.set_state(State.objects.get(type="draft", slug="rfc"))
528528
draft.std_level_id = "bcp"
529-
draft.save_with_history([DocEvent.objects.create(doc=draft, type="published_rfc", by=Person.objects.get(name="(System)"))])
529+
draft.save_with_history([DocEvent.objects.create(doc=draft, rev=draft.rev, type="published_rfc", by=Person.objects.get(name="(System)"))])
530530

531531

532532
rfc_alias = DocAlias.objects.create(name="rfc123456", document=draft)
@@ -577,10 +577,10 @@ def test_document_primary_and_history_views(self):
577577
]:
578578
doc = Document.objects.get(name=docname)
579579
# give it some history
580-
doc.save_with_history([DocEvent.objects.create(doc=doc, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
580+
doc.save_with_history([DocEvent.objects.create(doc=doc, rev=doc.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
581581

582582
doc.rev = "01"
583-
doc.save_with_history([DocEvent.objects.create(doc=doc, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
583+
doc.save_with_history([DocEvent.objects.create(doc=doc, rev=doc.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
584584

585585
r = self.client.get(urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=doc.name)))
586586
self.assertEqual(r.status_code, 200)
@@ -638,10 +638,11 @@ def test_document_ballot(self):
638638
ballot = doc.active_ballot()
639639

640640
# make sure we have some history
641-
doc.save_with_history([DocEvent.objects.create(doc=doc, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
641+
doc.save_with_history([DocEvent.objects.create(doc=doc, rev=doc.rev, type="changed_document", by=Person.objects.get(user__username="secretary"), desc="Test")])
642642

643643
pos = BallotPositionDocEvent.objects.create(
644644
doc=doc,
645+
rev=doc.rev,
645646
ballot=ballot,
646647
type="changed_ballot_position",
647648
pos_id="yes",
@@ -715,20 +716,23 @@ def test_writeup(self):
715716

716717
appr = WriteupDocEvent.objects.create(
717718
doc=doc,
719+
rev=doc.rev,
718720
desc="Changed text",
719721
type="changed_ballot_approval_text",
720722
text="This is ballot approval text.",
721723
by=Person.objects.get(name="(System)"))
722724

723725
notes = WriteupDocEvent.objects.create(
724726
doc=doc,
727+
rev=doc.rev,
725728
desc="Changed text",
726729
type="changed_ballot_writeup_text",
727730
text="This is ballot writeup notes.",
728731
by=Person.objects.get(name="(System)"))
729732

730733
rfced_note = WriteupDocEvent.objects.create(
731734
doc=doc,
735+
rev=doc.rev,
732736
desc="Changed text",
733737
type="changed_rfc_editor_note_text",
734738
text="This is a note for the RFC Editor.",
@@ -746,6 +750,7 @@ def test_history(self):
746750

747751
e = DocEvent.objects.create(
748752
doc=doc,
753+
rev=doc.rev,
749754
desc="Something happened.",
750755
type="added_comment",
751756
by=Person.objects.get(name="(System)"))
@@ -760,6 +765,7 @@ def test_document_feed(self):
760765

761766
e = DocEvent.objects.create(
762767
doc=doc,
768+
rev=doc.rev,
763769
desc="Something happened.",
764770
type="added_comment",
765771
by=Person.objects.get(name="(System)"))
@@ -775,6 +781,7 @@ def test_last_call_feed(self):
775781

776782
LastCallDocEvent.objects.create(
777783
doc=doc,
784+
rev=doc.rev,
778785
desc="Last call",
779786
type="sent_last_call",
780787
by=Person.objects.get(user__username="secretary"),

0 commit comments

Comments
 (0)