Skip to content

Commit 5b677dc

Browse files
committed
Merge author stats branch into new branch from trunk
- Legacy-Id: 13159
2 parents d2c2d80 + 22c979d commit 5b677dc

98 files changed

Lines changed: 6824 additions & 404 deletions

File tree

Some content is hidden

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

ietf/api/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def dehydrate(self, bundle, for_list=True):
212212
if not foreign_obj:
213213
if not self.null:
214214
if callable(self.attribute):
215-
raise ApiFieldError("The related resource for resource %s could not be found." % (previous_obj))
215+
raise ApiFieldError(u"The related resource for resource %s could not be found." % (previous_obj))
216216
else:
217-
raise ApiFieldError("The model '%r' has an empty attribute '%s' and doesn't allow a null value." % (previous_obj, attr))
217+
raise ApiFieldError(u"The model '%r' has an empty attribute '%s' and doesn't allow a null value." % (previous_obj, attr))
218218
return None
219219

220220
fk_resource = self.get_related_resource(foreign_obj)

ietf/bin/find-submission-confirmation-email-in-postfix-log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if "<" in from_email:
6666

6767
submission = Submission.objects.filter(name=draft).latest('submission_date')
6868
document = Document.objects.get(name=draft)
69-
emails = [ author.address for author in document.authors.all() ]
69+
emails = [ author.email.address for author in document.documentauthor_set.all() if author.email ]
7070

7171
timestrings = []
7272
for file in [ Path(settings.INTERNET_DRAFT_PATH) / ("%s-%s.txt"%(draft, submission.rev)),

ietf/bin/generate-draft-aliases

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def get_draft_authors_emails(draft):
6565
" Get list of authors for the given draft."
6666

6767
# This feels 'correct'; however, it creates fairly large delta
68-
return [email.email_address() for email in draft.authors.all()]
68+
return [author.email.email_address() for author in draft.documentauthor_set.all() if author.email.email_address()]
6969

7070
# This gives fairly small delta compared to current state,
7171
# however, it seems to be wrong (doesn't check for emails being

ietf/community/migrations/0004_cleanup_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def try_to_uniquify_person(rule, person_qs):
5757

5858

5959
elif rule.rule_type in ["author", "author_rfc"]:
60-
found_persons = list(try_to_uniquify_person(rule, Person.objects.filter(email__documentauthor__id__gte=1).filter(name__icontains=rule.value).distinct()))
60+
found_persons = list(try_to_uniquify_person(rule, Person.objects.filter(documentauthor__id__gte=1).filter(name__icontains=rule.value).distinct()))
6161

6262
if found_persons:
6363
rule.person = found_persons[0]

ietf/community/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_rule_matching(self):
3333

3434
rule_state_iesg = SearchRule.objects.create(rule_type="state_iesg", state=State.objects.get(type="draft-iesg", slug="lc"), community_list=clist)
3535

36-
rule_author = SearchRule.objects.create(rule_type="author", state=State.objects.get(type="draft", slug="active"), person=Person.objects.filter(email__documentauthor__document=draft).first(), community_list=clist)
36+
rule_author = SearchRule.objects.create(rule_type="author", state=State.objects.get(type="draft", slug="active"), person=Person.objects.filter(documentauthor__document=draft).first(), community_list=clist)
3737

3838
rule_ad = SearchRule.objects.create(rule_type="ad", state=State.objects.get(type="draft", slug="active"), person=draft.ad, community_list=clist)
3939

@@ -115,7 +115,7 @@ def test_manage_personal_list(self):
115115
r = self.client.post(url, {
116116
"action": "add_rule",
117117
"rule_type": "author_rfc",
118-
"author_rfc-person": Person.objects.filter(email__documentauthor__document=draft).first().pk,
118+
"author_rfc-person": Person.objects.filter(documentauthor__document=draft).first().pk,
119119
"author_rfc-state": State.objects.get(type="draft", slug="rfc").pk,
120120
})
121121
self.assertEqual(r.status_code, 302)

ietf/community/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def docs_matching_community_list_rule(rule):
9090
elif rule.rule_type.startswith("state_"):
9191
return docs.filter(states=rule.state)
9292
elif rule.rule_type in ["author", "author_rfc"]:
93-
return docs.filter(states=rule.state, documentauthor__author__person=rule.person)
93+
return docs.filter(states=rule.state, documentauthor__person=rule.person)
9494
elif rule.rule_type == "ad":
9595
return docs.filter(states=rule.state, ad=rule.person)
9696
elif rule.rule_type == "shepherd":
@@ -123,7 +123,7 @@ def community_list_rules_matching_doc(doc):
123123
rules |= SearchRule.objects.filter(
124124
rule_type__in=["author", "author_rfc"],
125125
state__in=states,
126-
person__in=list(Person.objects.filter(email__documentauthor__document=doc)),
126+
person__in=list(Person.objects.filter(documentauthor__document=doc)),
127127
)
128128

129129
if doc.ad_id:

ietf/doc/admin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DocAliasInline(admin.TabularInline):
2626

2727
class DocAuthorInline(admin.TabularInline):
2828
model = DocumentAuthor
29-
raw_id_fields = ['author', ]
29+
raw_id_fields = ['person', 'email']
3030
extra = 1
3131

3232
class RelatedDocumentInline(admin.TabularInline):
@@ -100,7 +100,7 @@ class DocumentAdmin(admin.ModelAdmin):
100100
list_display = ['name', 'rev', 'group', 'pages', 'intended_std_level', 'author_list', 'time']
101101
search_fields = ['name']
102102
list_filter = ['type']
103-
raw_id_fields = ['authors', 'group', 'shepherd', 'ad']
103+
raw_id_fields = ['group', 'shepherd', 'ad']
104104
inlines = [DocAliasInline, DocAuthorInline, RelatedDocumentInline, ]
105105
form = DocumentForm
106106

@@ -123,7 +123,7 @@ class DocHistoryAdmin(admin.ModelAdmin):
123123
list_display = ['doc', 'rev', 'state', 'group', 'pages', 'intended_std_level', 'author_list', 'time']
124124
search_fields = ['doc__name']
125125
ordering = ['time', 'doc', 'rev']
126-
raw_id_fields = ['doc', 'authors', 'group', 'shepherd', 'ad']
126+
raw_id_fields = ['doc', 'group', 'shepherd', 'ad']
127127

128128
def state(self, instance):
129129
return instance.get_state()
@@ -175,7 +175,8 @@ class BallotPositionDocEventAdmin(DocEventAdmin):
175175
admin.site.register(BallotPositionDocEvent, BallotPositionDocEventAdmin)
176176

177177
class DocumentAuthorAdmin(admin.ModelAdmin):
178-
list_display = ['id', 'document', 'author', 'order']
179-
search_fields = [ 'document__name', 'author__address', ]
178+
list_display = ['id', 'document', 'person', 'email', 'affiliation', 'country', 'order']
179+
search_fields = ['document__docalias__name', 'person__name', 'email__address', 'affiliation', 'country']
180+
raw_id_fields = ["document", "person", "email"]
180181
admin.site.register(DocumentAuthor, DocumentAuthorAdmin)
181182

ietf/doc/factories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def states(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
4646
def authors(obj, create, extracted, **kwargs): # pylint: disable=no-self-argument
4747
if create and extracted:
4848
order = 0
49-
for email in extracted:
50-
DocumentAuthor.objects.create(document=obj, author=email, order=order)
49+
for person in extracted:
50+
DocumentAuthor.objects.create(document=obj, person=person, order=order)
5151
order += 1
5252

5353
@classmethod
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('name', '0019_formallanguagename'),
11+
('doc', '0025_auto_20170307_0146'),
12+
]
13+
14+
operations = [
15+
migrations.AddField(
16+
model_name='dochistory',
17+
name='words',
18+
field=models.IntegerField(null=True, blank=True),
19+
),
20+
migrations.AddField(
21+
model_name='document',
22+
name='words',
23+
field=models.IntegerField(null=True, blank=True),
24+
),
25+
migrations.AddField(
26+
model_name='dochistory',
27+
name='formal_languages',
28+
field=models.ManyToManyField(help_text=b'Formal languages used in document', to='name.FormalLanguageName', blank=True),
29+
),
30+
migrations.AddField(
31+
model_name='document',
32+
name='formal_languages',
33+
field=models.ManyToManyField(help_text=b'Formal languages used in document', to='name.FormalLanguageName', blank=True),
34+
),
35+
migrations.RemoveField(
36+
model_name='dochistory',
37+
name='authors',
38+
),
39+
migrations.RemoveField(
40+
model_name='document',
41+
name='authors',
42+
),
43+
migrations.AddField(
44+
model_name='dochistoryauthor',
45+
name='affiliation',
46+
field=models.CharField(help_text=b'Organization/company used by author for submission', max_length=100, blank=True),
47+
),
48+
migrations.AddField(
49+
model_name='dochistoryauthor',
50+
name='country',
51+
field=models.CharField(blank=True, help_text=b'Country used by author for submission', max_length=255),
52+
),
53+
migrations.RenameField(
54+
model_name='dochistoryauthor',
55+
old_name='author',
56+
new_name='email',
57+
),
58+
migrations.AlterField(
59+
model_name='dochistoryauthor',
60+
name='email',
61+
field=models.ForeignKey(blank=True, to='person.Email', help_text=b'Email address used by author for submission', null=True),
62+
),
63+
migrations.AddField(
64+
model_name='dochistoryauthor',
65+
name='person',
66+
field=models.ForeignKey(blank=True, to='person.Person', null=True),
67+
),
68+
migrations.AddField(
69+
model_name='documentauthor',
70+
name='affiliation',
71+
field=models.CharField(help_text=b'Organization/company used by author for submission', max_length=100, blank=True),
72+
),
73+
migrations.AddField(
74+
model_name='documentauthor',
75+
name='country',
76+
field=models.CharField(blank=True, help_text=b'Country used by author for submission', max_length=255),
77+
),
78+
migrations.RenameField(
79+
model_name='documentauthor',
80+
old_name='author',
81+
new_name='email',
82+
),
83+
migrations.AlterField(
84+
model_name='documentauthor',
85+
name='email',
86+
field=models.ForeignKey(blank=True, to='person.Email', help_text=b'Email address used by author for submission', null=True),
87+
),
88+
migrations.AddField(
89+
model_name='documentauthor',
90+
name='person',
91+
field=models.ForeignKey(blank=True, to='person.Person', null=True),
92+
),
93+
migrations.AlterField(
94+
model_name='dochistoryauthor',
95+
name='document',
96+
field=models.ForeignKey(related_name='documentauthor_set', to='doc.DocHistory'),
97+
),
98+
migrations.AlterField(
99+
model_name='dochistoryauthor',
100+
name='order',
101+
field=models.IntegerField(default=1),
102+
),
103+
migrations.RunSQL("update doc_documentauthor a inner join person_email e on a.email_id = e.address set a.person_id = e.person_id;", migrations.RunSQL.noop),
104+
migrations.RunSQL("update doc_dochistoryauthor a inner join person_email e on a.email_id = e.address set a.person_id = e.person_id;", migrations.RunSQL.noop),
105+
migrations.AlterField(
106+
model_name='documentauthor',
107+
name='person',
108+
field=models.ForeignKey(to='person.Person'),
109+
),
110+
migrations.AlterField(
111+
model_name='dochistoryauthor',
112+
name='person',
113+
field=models.ForeignKey(to='person.Person'),
114+
),
115+
]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations
5+
6+
def fix_invalid_emails(apps, schema_editor):
7+
Email = apps.get_model("person", "Email")
8+
Role = apps.get_model("group", "Role")
9+
RoleHistory = apps.get_model("group", "RoleHistory")
10+
DocumentAuthor = apps.get_model("doc", "DocumentAuthor")
11+
DocHistoryAuthor = apps.get_model("doc", "DocHistoryAuthor")
12+
13+
e = Email.objects.filter(address="unknown-email-Gigi-Karmous-Edwards").first()
14+
if e:
15+
# according to ftp://ietf.org/ietf/97dec/adsl-minutes-97dec.txt
16+
new_e, _ = Email.objects.get_or_create(
17+
address="GiGi.Karmous-Edwards@pulse.com",
18+
primary=e.primary,
19+
active=e.active,
20+
person=e.person,
21+
)
22+
Role.objects.filter(email=e).update(email=new_e)
23+
RoleHistory.objects.filter(email=e).update(email=new_e)
24+
e.delete()
25+
26+
e = Email.objects.filter(address="unknown-email-Pat-Thaler").first()
27+
if e:
28+
# current chair email
29+
new_e = Email.objects.get(address="pat.thaler@broadcom.com")
30+
Role.objects.filter(email=e).update(email=new_e)
31+
RoleHistory.objects.filter(email=e).update(email=new_e)
32+
e.delete()
33+
34+
e = Email.objects.filter(address="unknown-email-Greg-<gregimirsky@gmail.com>>").first()
35+
if e:
36+
# current email
37+
new_e = Email.objects.get(address="gregimirsky@gmail.com")
38+
DocumentAuthor.objects.filter(email=e).update(email=new_e)
39+
DocHistoryAuthor.objects.filter(email=e).update(email=new_e)
40+
e.delete()
41+
42+
DocumentAuthor.objects.filter(email__address__startswith="unknown-email-").exclude(email__address__contains="@").update(email=None)
43+
DocHistoryAuthor.objects.filter(email__address__startswith="unknown-email-").exclude(email__address__contains="@").update(email=None)
44+
Email.objects.exclude(address__contains="@").filter(address__startswith="unknown-email-").delete()
45+
46+
assert not Email.objects.filter(address__startswith="unknown-email-")
47+
48+
class Migration(migrations.Migration):
49+
50+
dependencies = [
51+
('doc', '0026_author_revamp_and_extra_attributes'),
52+
('person', '0014_auto_20160613_0751'),
53+
('group', '0009_auto_20150930_0758'),
54+
]
55+
56+
operations = [
57+
migrations.RunPython(fix_invalid_emails, migrations.RunPython.noop),
58+
]

0 commit comments

Comments
 (0)