Skip to content

Commit ea8c84d

Browse files
committed
Python2/3 compatibility: used @python_2_unicode_compatible to provide __unicode__() versions of __str__() methods.
- Legacy-Id: 16455
1 parent 2cfb81f commit ea8c84d

17 files changed

Lines changed: 137 additions & 12 deletions

File tree

docker/install-extras

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ su - -c "apt-get update \
55
&& apt-get install -qy graphviz ghostscript apache2-utils \
66
&& apt-get clean \
77
&& rm -rf /var/lib/apt/lists/*"
8+

ietf/community/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# Copyright The IETF Trust 2012-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from __future__ import absolute_import, print_function, unicode_literals
6+
27
from django.contrib.auth.models import User
38
from django.db import models
49
from django.db.models import signals
510
from django.urls import reverse as urlreverse
11+
from django.utils.encoding import python_2_unicode_compatible
612

713
from ietf.doc.models import Document, DocEvent, State
814
from ietf.group.models import Group
915
from ietf.person.models import Person, Email
1016
from ietf.utils.models import ForeignKey
1117

18+
@python_2_unicode_compatible
1219
class CommunityList(models.Model):
1320
user = ForeignKey(User, blank=True, null=True)
1421
group = ForeignKey(Group, blank=True, null=True)
@@ -34,6 +41,7 @@ def get_absolute_url(self):
3441
return ""
3542

3643

44+
@python_2_unicode_compatible
3745
class SearchRule(models.Model):
3846
# these types define the UI for setting up the rule, and also
3947
# helps when interpreting the rule and matching documents
@@ -79,6 +87,7 @@ class SearchRule(models.Model):
7987
def __str__(self):
8088
return "%s %s %s/%s/%s/%s" % (self.community_list, self.rule_type, self.state, self.group, self.person, self.text)
8189

90+
@python_2_unicode_compatible
8291
class EmailSubscription(models.Model):
8392
community_list = ForeignKey(CommunityList)
8493
email = ForeignKey(Email)

ietf/dbtemplate/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22
# Copyright The IETF Trust 2012-2019, All Rights Reserved
3-
4-
3+
from __future__ import absolute_import, print_function, unicode_literals
54

65
from django.db import models
76
from django.core.exceptions import ValidationError
87
from django.template import Context
8+
from django.utils.encoding import python_2_unicode_compatible
99

1010
from ietf.group.models import Group
1111
from ietf.name.models import DBTemplateTypeName
@@ -19,6 +19,7 @@
1919
)
2020

2121

22+
@python_2_unicode_compatible
2223
class DBTemplate(models.Model):
2324
path = models.CharField( max_length=255, unique=True, blank=False, null=False, )
2425
title = models.CharField( max_length=255, blank=False, null=False, )

ietf/iesg/models.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright The IETF Trust 2007-2019, All Rights Reserved
2-
2+
# -*- coding: utf-8 -*-
3+
#
34
# Portion Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
45
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
56
#
@@ -32,11 +33,15 @@
3233
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3334
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3435

36+
37+
from __future__ import absolute_import, print_function, unicode_literals
38+
3539
import datetime
3640

3741
from django.db import models
42+
from django.utils.encoding import python_2_unicode_compatible
3843

39-
44+
@python_2_unicode_compatible
4045
class TelechatAgendaItem(models.Model):
4146
TYPE_CHOICES = (
4247
(1, "Any Other Business (WG News, New Proposals, etc.)"),
@@ -51,7 +56,7 @@ class TelechatAgendaItem(models.Model):
5156

5257
def __str__(self):
5358
type_name = self.TYPE_CHOICES_DICT.get(self.type, str(self.type))
54-
return '%s: %s' % (type_name, self.title or "")
59+
return "%s: %s" % (type_name, self.title or "")
5560

5661
class Telechat(models.Model):
5762
telechat_id = models.IntegerField(primary_key=True)
@@ -77,6 +82,7 @@ class TelechatDateManager(models.Manager):
7782
def active(self):
7883
return self.get_queryset().filter(date__gte=datetime.date.today())
7984

85+
@python_2_unicode_compatible
8086
class TelechatDate(models.Model):
8187
objects = TelechatDateManager()
8288

ietf/ipr/models.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
# Copyright The IETF Trust 2007-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from __future__ import absolute_import, print_function, unicode_literals
26

37
import datetime
48

59
from django.conf import settings
6-
from django.urls import reverse
710
from django.db import models
11+
from django.urls import reverse
12+
from django.utils.encoding import python_2_unicode_compatible
813

914
from ietf.doc.models import DocAlias
1015
from ietf.name.models import DocRelationshipName,IprDisclosureStateName,IprLicenseTypeName,IprEventTypeName
1116
from ietf.person.models import Person
1217
from ietf.message.models import Message
1318
from ietf.utils.models import ForeignKey
1419

20+
@python_2_unicode_compatible
1521
class IprDisclosureBase(models.Model):
1622
by = ForeignKey(Person) # who was logged in, or System if nobody was logged in
1723
compliant = models.BooleanField("Complies to RFC3979", default=True)
@@ -148,6 +154,7 @@ class GenericIprDisclosure(IprDisclosureBase):
148154
holder_contact_info = models.TextField(blank=True, help_text="Address, phone, etc.")
149155
statement = models.TextField() # includes licensing info
150156

157+
@python_2_unicode_compatible
151158
class IprDocRel(models.Model):
152159
disclosure = ForeignKey(IprDisclosureBase)
153160
document = ForeignKey(DocAlias)
@@ -178,6 +185,7 @@ def __str__(self):
178185
else:
179186
return "%s which applies to %s" % (self.disclosure, self.document.name)
180187

188+
@python_2_unicode_compatible
181189
class RelatedIpr(models.Model):
182190
source = ForeignKey(IprDisclosureBase,related_name='relatedipr_source_set')
183191
target = ForeignKey(IprDisclosureBase,related_name='relatedipr_target_set')
@@ -186,6 +194,7 @@ class RelatedIpr(models.Model):
186194
def __str__(self):
187195
return "%s %s %s" % (self.source.title, self.relationship.name.lower(), self.target.title)
188196

197+
@python_2_unicode_compatible
189198
class IprEvent(models.Model):
190199
time = models.DateTimeField(auto_now_add=True)
191200
type = ForeignKey(IprEventTypeName)

ietf/liaisons/models.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# Copyright The IETF Trust 2007-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from __future__ import absolute_import, print_function, unicode_literals
26

37
from django.conf import settings
48
from django.urls import reverse as urlreverse
59
from django.db import models
10+
from django.utils.encoding import python_2_unicode_compatible
611
from django.utils.text import slugify
712

813
from ietf.person.models import Email, Person
@@ -24,6 +29,7 @@
2429
}
2530

2631

32+
@python_2_unicode_compatible
2733
class LiaisonStatement(models.Model):
2834
title = models.CharField(max_length=255)
2935
from_groups = models.ManyToManyField(Group, blank=True, related_name='liaisonstatement_from_set')
@@ -47,7 +53,6 @@ class LiaisonStatement(models.Model):
4753

4854
class Meta:
4955
ordering = ['id']
50-
5156

5257
def __str__(self):
5358
return self.title or "<no title>"
@@ -198,6 +203,7 @@ def approver_emails(self):
198203
approval_set.intersection_update(group.liaison_approvers())
199204
return list(set([ r.email.address for r in approval_set ]))
200205

206+
@python_2_unicode_compatible
201207
class LiaisonStatementAttachment(models.Model):
202208
statement = ForeignKey(LiaisonStatement)
203209
document = ForeignKey(Document)
@@ -207,6 +213,7 @@ def __str__(self):
207213
return self.document.name
208214

209215

216+
@python_2_unicode_compatible
210217
class RelatedLiaisonStatement(models.Model):
211218
source = ForeignKey(LiaisonStatement, related_name='source_of_set')
212219
target = ForeignKey(LiaisonStatement, related_name='target_of_set')
@@ -216,6 +223,7 @@ def __str__(self):
216223
return "%s %s %s" % (self.source.title, self.relationship.name.lower(), self.target.title)
217224

218225

226+
@python_2_unicode_compatible
219227
class LiaisonStatementGroupContacts(models.Model):
220228
group = ForeignKey(Group, unique=True, null=True)
221229
contacts = models.CharField(max_length=255,blank=True)
@@ -225,6 +233,7 @@ def __str__(self):
225233
return "%s" % self.group.name
226234

227235

236+
@python_2_unicode_compatible
228237
class LiaisonStatementEvent(models.Model):
229238
time = models.DateTimeField(auto_now_add=True)
230239
type = ForeignKey(LiaisonStatementEventTypeName)

ietf/mailinglists/models.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
# Copyright The IETF Trust 2016-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
23

34

5+
from __future__ import absolute_import, print_function, unicode_literals
6+
47
from django.conf import settings
58
from django.core.validators import validate_email
69
from django.db import models
10+
from django.utils.encoding import python_2_unicode_compatible
711

812
from ietf.person.models import Person
913
from ietf.utils.models import ForeignKey
1014

15+
@python_2_unicode_compatible
1116
class List(models.Model):
1217
name = models.CharField(max_length=32)
1318
description = models.CharField(max_length=256)
1419
advertised = models.BooleanField(default=True)
20+
1521
def __str__(self):
1622
return "<List: %s>" % self.name
1723
def info_url(self):
1824
return settings.MAILING_LIST_INFO_URL % {'list_addr': self.name }
1925

26+
@python_2_unicode_compatible
2027
class Subscribed(models.Model):
2128
time = models.DateTimeField(auto_now_add=True)
2229
email = models.CharField(max_length=64, validators=[validate_email])
@@ -26,6 +33,7 @@ def __str__(self):
2633
class Meta:
2734
verbose_name_plural = "Subscribed"
2835

36+
@python_2_unicode_compatible
2937
class Whitelisted(models.Model):
3038
time = models.DateTimeField(auto_now_add=True)
3139
email = models.CharField("Email address", max_length=64, validators=[validate_email])

ietf/mailtrigger/models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Copyright The IETF Trust 2015-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from __future__ import absolute_import, print_function, unicode_literals
26

37
from django.db import models
48
from django.template import Template, Context
9+
from django.utils.encoding import python_2_unicode_compatible
510

611
from email.utils import parseaddr
712
from ietf.utils.mail import formataddr, get_email_addresses_from_text
@@ -28,6 +33,7 @@ def clean_duplicates(addrlist):
2833
addresses.append(addr)
2934
return addresses
3035

36+
@python_2_unicode_compatible
3137
class MailTrigger(models.Model):
3238
slug = models.CharField(max_length=32, primary_key=True)
3339
desc = models.TextField(blank=True)
@@ -40,6 +46,7 @@ class Meta:
4046
def __str__(self):
4147
return self.slug
4248

49+
@python_2_unicode_compatible
4350
class Recipient(models.Model):
4451
slug = models.CharField(max_length=32, primary_key=True)
4552
desc = models.TextField(blank=True)

ietf/message/models.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# Copyright The IETF Trust 2012-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from __future__ import absolute_import, print_function, unicode_literals
6+
27
import datetime
38
import email.utils
49

510
from django.db import models
11+
from django.utils.encoding import python_2_unicode_compatible
612

713
import debug # pyflakes:ignore
814

@@ -13,6 +19,7 @@
1319
from ietf.utils.models import ForeignKey
1420
from ietf.utils.mail import get_email_addresses_from_text
1521

22+
@python_2_unicode_compatible
1623
class Message(models.Model):
1724
time = models.DateTimeField(default=datetime.datetime.now)
1825
by = ForeignKey(Person)
@@ -41,6 +48,7 @@ def get(self, field):
4148
return r if isinstance(r, list) else get_email_addresses_from_text(r)
4249

4350

51+
@python_2_unicode_compatible
4452
class MessageAttachment(models.Model):
4553
message = ForeignKey(Message)
4654
filename = models.CharField(max_length=255, db_index=True, blank=True)
@@ -53,6 +61,7 @@ def __str__(self):
5361
return self.filename
5462

5563

64+
@python_2_unicode_compatible
5665
class SendQueue(models.Model):
5766
time = models.DateTimeField(default=datetime.datetime.now)
5867
by = ForeignKey(Person)
@@ -71,6 +80,7 @@ def __str__(self):
7180
return "'%s' %s -> %s (sent at %s)" % (self.message.subject, self.message.frm, self.message.to, self.sent_at or "<not yet>")
7281

7382

83+
@python_2_unicode_compatible
7484
class AnnouncementFrom(models.Model):
7585
name = ForeignKey(RoleName)
7686
group = ForeignKey(Group)

ietf/name/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Copyright The IETF Trust 2010-2019, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
4+
5+
from __future__ import absolute_import, print_function, unicode_literals
26

37
from django.db import models
8+
from django.utils.encoding import python_2_unicode_compatible
49

510
from ietf.utils.models import ForeignKey
611

12+
@python_2_unicode_compatible
713
class NameModel(models.Model):
814
slug = models.CharField(max_length=32, primary_key=True)
915
name = models.CharField(max_length=255)

0 commit comments

Comments
 (0)