Skip to content

Commit

Permalink
Remove Django<2 legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed May 11, 2020
1 parent 8e61685 commit af6d930
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions shop/forms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError
from django.forms import widgets
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
Expand Down Expand Up @@ -57,13 +57,13 @@ def as_text(self):
line.append(dict(bound_field.field.choices)[cast_to(v)])
except (AttributeError, KeyError):
pass
output.append(force_text(', '.join(line)))
output.append(force_str(', '.join(line)))
elif value:
try:
value = dict(bound_field.field.choices)[value]
except (AttributeError, KeyError):
pass
output.append(force_text(value))
output.append(force_str(value))
return mark_safe('\n'.join(output))

def get_response_data(self):
Expand Down
4 changes: 2 additions & 2 deletions shop/models/fields.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import enum
from django.conf import settings
from django.db import models
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _


Expand Down Expand Up @@ -87,7 +87,7 @@ class Color(ChoiceEnum):
)
"""
def __str__(self):
return force_text(self.label)
return force_str(self.label)


class ChoiceEnumField(models.PositiveSmallIntegerField):
Expand Down
4 changes: 2 additions & 2 deletions shop/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.db.models.aggregates import Sum
from django.db.models.functions import Coalesce
from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _

try:
Expand Down Expand Up @@ -228,7 +228,7 @@ def product_type(self):
"""
Returns the polymorphic type of the product.
"""
return force_text(self.polymorphic_ctype)
return force_str(self.polymorphic_ctype)
product_type.short_description = _("Product type")

@property
Expand Down
6 changes: 3 additions & 3 deletions shop/templatetags/shop_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.template import Node, TemplateSyntaxError
from django.template.loader import select_template
from django.utils import formats
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.safestring import mark_safe
from django.utils.dateformat import format, time_format
from django.utils.timezone import datetime
Expand Down Expand Up @@ -37,7 +37,7 @@ def render(self, context):
except CartModel.DoesNotExist:
cart_data = {'total_quantity': 0, 'num_items': 0}
context.update({
'cart_as_json': mark_safe(force_text(cart_data)),
'cart_as_json': mark_safe(force_str(cart_data)),
'has_dropdown': self.with_items != CartItems.without,
})
return self.get_template().render(context)
Expand Down Expand Up @@ -123,4 +123,4 @@ def rest_json(value, arg=None):
else:
msg = "Given value must be of type dict, OrderedDict, list or tuple but it is {}."
raise ValueError(msg.format(value.__class__.__name__))
return mark_safe(force_text(data))
return mark_safe(force_str(data))
3 changes: 1 addition & 2 deletions tests/testshop/modifiers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from shop.payment.modifiers import PayInAdvanceModifier
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class ComplexPayInAdvanceModifier(PayInAdvanceModifier):
identifier = "complex-pay-in-advance-modifier"
def get_choice(self):
return (self.identifier, _("Pay in advance with complex payment system X"))

0 comments on commit af6d930

Please sign in to comment.