Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Removed unneeded utf-8 encodings #663

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions td/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -338,27 +340,27 @@ def get_absolute_url(self):

@property
def cc(self):
return self.country.code.encode("utf-8") if self.country else ""
return self.country.code if self.country else ""

@property
def cc_all(self):
pks = [int(pk)
for pk in self.attributes.filter(attribute="country_id")
.values_list("value", flat=True)]
countries = Country.objects.filter(pk__in=pks)
return [c.code.encode("utf-8") for c in countries]
return [c.code for c in countries]

@property
def lr(self):
return self.country.region.name.encode("utf-8") if self.country and self.country.region else ""
return self.country.region.name if self.country and self.country.region else ""

@property
def lc(self):
return self.code

@property
def ln(self):
return self.name.encode("utf-8")
return self.name

@property
def ang(self):
Expand Down Expand Up @@ -394,15 +396,15 @@ def alt_name_all(self):
for pk in self.attributes.filter(attribute="alt_name_id")
.values_list("value", flat=True)]
alt_names = LanguageAltName.objects.filter(pk__in=pks)
return [n.name.encode("utf-8") for n in alt_names]
return [n.name for n in alt_names]

@property
def tag_display(self):
return self.anglicized_name or self.name

@property
def tag_tip(self):
return ", ".join(self.alt_name_all).decode("utf-8")
return ", ".join(self.alt_name_all)

@property
def tag_slug(self):
Expand Down Expand Up @@ -430,7 +432,7 @@ def codes_text(cls):
@classmethod
def names_text(cls):
return "\n".join([
"{}\t{}".format(x.code.encode("utf-8"), x.name.encode("utf-8"))
"{}\t{}".format(x.code, x.name)
for x in cls.objects.all().order_by("code")
])

Expand Down
2 changes: 1 addition & 1 deletion td/tracking/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Charter(CommentableModel):

def __unicode__(self):
# Returning the language.name cause encoding error in admin
return self.language.code.encode("utf-8")
return self.language.code

__unicode__.allow_tags = True
__unicode__.admin_order_field = "language"
Expand Down
6 changes: 3 additions & 3 deletions td/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def languages_autocomplete(request):
data = get_langnames(short=True)
d = []
if len(term) <= 3:
term = term.encode("utf-8")
term = term
# search: lc
# first do a *starts with* style search of language code (lc)
d.extend([
Expand All @@ -109,7 +109,7 @@ def languages_autocomplete(request):
])
if len(term) >= 3:
# search: lc, ln, lr
term = term.encode("utf-8")
term = term
d.extend([
x
for x in data
Expand All @@ -126,7 +126,7 @@ def gateway_languages_autocomplete(request):
term = request.GET.get("q", "")
data = Language.get_gateway_languages()
d = []
term = term.lower().encode("utf-8")
term = term.lower()
if len(term) <= 3:
# search: lc
# first do a *starts with* style search of language code (lc)
Expand Down