Skip to content

Commit 76628be

Browse files
committed
Merged in ^/branch/iola/author-stats-r13145 from olau@iola.dk, and fixed some tests in code which moved after the latest merge with trunk. The test suite passes, but the migrations are _not_ ready to run, because of numbering conflicts (again due to code changes on trunk since the latest sync).
- Legacy-Id: 13479
2 parents e0c994f + 12eb4dc commit 76628be

File tree

106 files changed

+7563
-408
lines changed

Some content is hidden

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

106 files changed

+7563
-408
lines changed

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)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import sys, os, argparse
5+
6+
basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
7+
sys.path = [ basedir ] + sys.path
8+
os.environ["DJANGO_SETTINGS_MODULE"] = "ietf.settings"
9+
10+
virtualenv_activation = os.path.join(basedir, "env", "bin", "activate_this.py")
11+
if os.path.exists(virtualenv_activation):
12+
execfile(virtualenv_activation, dict(__file__=virtualenv_activation))
13+
14+
import django
15+
django.setup()
16+
17+
parser = argparse.ArgumentParser()
18+
parser.add_argument("--meeting", help="meeting to fetch data for")
19+
parser.add_argument("--all", action="store_true", help="fetch data for all meetings")
20+
parser.add_argument("--latest", type=int, help="fetch data for latest N meetings")
21+
args = parser.parse_args()
22+
23+
24+
import syslog
25+
26+
from ietf.meeting.models import Meeting
27+
28+
from ietf.stats.utils import get_meeting_registration_data
29+
30+
meetings = Meeting.objects.none()
31+
if args.meeting:
32+
meetings = Meeting.objects.filter(number=args.meeting, type="ietf")
33+
elif args.all:
34+
meetings = Meeting.objects.filter(type="ietf").order_by("date")
35+
elif args.latest:
36+
meetings = Meeting.objects.filter(type="ietf").order_by("-date")[:args.latest]
37+
else:
38+
print("Please use one of --meeting, --all or --latest")
39+
sys.exit(1)
40+
41+
for meeting in meetings:
42+
total = get_meeting_registration_data(meeting)
43+
msg = "Fetched data for meeting {}: {} registrations added".format(meeting.number, total)
44+
if sys.stdout.isatty():
45+
print(msg) # make debugging a bit easier
46+
else:
47+
syslog.syslog(msg)

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
@@ -35,7 +35,7 @@ def test_rule_matching(self):
3535

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

38-
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)
38+
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)
3939

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

@@ -117,7 +117,7 @@ def test_manage_personal_list(self):
117117
r = self.client.post(url, {
118118
"action": "add_rule",
119119
"rule_type": "author_rfc",
120-
"author_rfc-person": Person.objects.filter(email__documentauthor__document=draft).first().pk,
120+
"author_rfc-person": Person.objects.filter(documentauthor__document=draft).first().pk,
121121
"author_rfc-state": State.objects.get(type="draft", slug="rfc").pk,
122122
})
123123
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 & 6 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,8 +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', ]
180-
raw_id_fields = ['document', 'author', ]
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"]
181181
admin.site.register(DocumentAuthor, DocumentAuthorAdmin)
182182

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+
]

0 commit comments

Comments
 (0)