Skip to content

Commit b2ff10b

Browse files
committed
Add support for extracting the country line from the author addresses
to the draft parser (incorporating patch from trunk), store the extracted country instead of trying to turn it into an ISO country code, add country and continent name models and add initial data for those, add helper function for cleaning the countries, add author country and continent charts, move the affiliation models to stats/models.py, fix a bunch of bugs. - Legacy-Id: 12846
1 parent 882579b commit b2ff10b

34 files changed

+1234
-281
lines changed

ietf/doc/admin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ class BallotPositionDocEventAdmin(DocEventAdmin):
174174
admin.site.register(BallotPositionDocEvent, BallotPositionDocEventAdmin)
175175

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

ietf/doc/migrations/0020_auto_20170112_0753.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import unicode_literals
33

44
from django.db import migrations, models
5-
import django_countries.fields
65

76

87
class Migration(migrations.Migration):
@@ -49,7 +48,7 @@ class Migration(migrations.Migration):
4948
migrations.AddField(
5049
model_name='dochistoryauthor',
5150
name='country',
52-
field=django_countries.fields.CountryField(blank=True, help_text=b'Country used by author for submission', max_length=2),
51+
field=models.CharField(blank=True, help_text=b'Country used by author for submission', max_length=255),
5352
),
5453
migrations.RenameField(
5554
model_name='dochistoryauthor',
@@ -74,7 +73,7 @@ class Migration(migrations.Migration):
7473
migrations.AddField(
7574
model_name='documentauthor',
7675
name='country',
77-
field=django_countries.fields.CountryField(blank=True, help_text=b'Country used by author for submission', max_length=2),
76+
field=models.CharField(blank=True, help_text=b'Country used by author for submission', max_length=255),
7877
),
7978
migrations.RenameField(
8079
model_name='documentauthor',

ietf/doc/models.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from django.conf import settings
1212
from django.utils.html import mark_safe
1313

14-
from django_countries.fields import CountryField
15-
1614
import debug # pyflakes:ignore
1715

1816
from ietf.group.models import Group
@@ -406,7 +404,7 @@ class DocumentAuthorInfo(models.Model):
406404
# email should only be null for some historic documents
407405
email = models.ForeignKey(Email, help_text="Email address used by author for submission", blank=True, null=True)
408406
affiliation = models.CharField(max_length=100, blank=True, help_text="Organization/company used by author for submission")
409-
country = CountryField(blank=True, help_text="Country used by author for submission")
407+
country = models.CharField(max_length=255, blank=True, help_text="Country used by author for submission")
410408
order = models.IntegerField(default=1)
411409

412410
def formatted_email(self):

ietf/name/admin.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from django.contrib import admin
22

33
from ietf.name.models import (
4-
BallotPositionName, ConstraintName, DBTemplateTypeName, DocRelationshipName,
4+
BallotPositionName, ConstraintName, ContinentName, CountryName,
5+
DBTemplateTypeName, DocRelationshipName,
56
DocReminderTypeName, DocTagName, DocTypeName, DraftSubmissionStateName,
67
FeedbackTypeName, FormalLanguageName, GroupMilestoneStateName, GroupStateName, GroupTypeName,
78
IntendedStdLevelName, IprDisclosureStateName, IprEventTypeName, IprLicenseTypeName,
@@ -10,8 +11,11 @@
1011
ReviewRequestStateName, ReviewResultName, ReviewTypeName, RoleName, RoomResourceName,
1112
SessionStatusName, StdLevelName, StreamName, TimeSlotTypeName, )
1213

14+
from ietf.stats.models import CountryAlias
15+
1316
class NameAdmin(admin.ModelAdmin):
1417
list_display = ["slug", "name", "desc", "used"]
18+
search_fields = ["slug", "name"]
1519
prepopulate_from = { "slug": ("name",) }
1620

1721
class DocRelationshipNameAdmin(NameAdmin):
@@ -26,8 +30,19 @@ class GroupTypeNameAdmin(NameAdmin):
2630
list_display = ["slug", "name", "verbose_name", "desc", "used"]
2731
admin.site.register(GroupTypeName, GroupTypeNameAdmin)
2832

33+
class CountryAliasInline(admin.TabularInline):
34+
model = CountryAlias
35+
extra = 1
36+
37+
class CountryNameAdmin(NameAdmin):
38+
list_display = ["slug", "name", "continent", "in_eu"]
39+
list_filter = ["continent", "in_eu"]
40+
inlines = [CountryAliasInline]
41+
admin.site.register(CountryName, CountryNameAdmin)
42+
2943
admin.site.register(BallotPositionName, NameAdmin)
3044
admin.site.register(ConstraintName, NameAdmin)
45+
admin.site.register(ContinentName, NameAdmin)
3146
admin.site.register(DBTemplateTypeName, NameAdmin)
3247
admin.site.register(DocReminderTypeName, NameAdmin)
3348
admin.site.register(DocTagName, NameAdmin)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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', '0018_add_formlang_names'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='ContinentName',
16+
fields=[
17+
('slug', models.CharField(max_length=32, serialize=False, primary_key=True)),
18+
('name', models.CharField(max_length=255)),
19+
('desc', models.TextField(blank=True)),
20+
('used', models.BooleanField(default=True)),
21+
('order', models.IntegerField(default=0)),
22+
],
23+
options={
24+
'ordering': ['order', 'name'],
25+
'abstract': False,
26+
},
27+
),
28+
migrations.CreateModel(
29+
name='CountryName',
30+
fields=[
31+
('slug', models.CharField(max_length=32, serialize=False, primary_key=True)),
32+
('name', models.CharField(max_length=255)),
33+
('desc', models.TextField(blank=True)),
34+
('used', models.BooleanField(default=True)),
35+
('order', models.IntegerField(default=0)),
36+
('in_eu', models.BooleanField(default=False, verbose_name='In EU')),
37+
('continent', models.ForeignKey(to='name.ContinentName')),
38+
],
39+
options={
40+
'ordering': ['order', 'name'],
41+
'abstract': False,
42+
},
43+
),
44+
]

0 commit comments

Comments
 (0)