From 6420a185d257158e3a83bee3c8792ca0bc3f4696 Mon Sep 17 00:00:00 2001 From: blag Date: Mon, 20 Dec 2021 00:53:23 -0800 Subject: [PATCH] Python 3 only - everything is unicode --- tos/models.py | 12 ++++++------ tos/views.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tos/models.py b/tos/models.py index dbddfa2..402727b 100644 --- a/tos/models.py +++ b/tos/models.py @@ -22,7 +22,7 @@ class TermsOfServiceManager(models.Manager): return self.get(active=True) except self.model.DoesNotExist: raise NoActiveTermsOfService( - u'Please create an active Terms-of-Service' + 'Please create an active Terms-of-Service' ) @@ -31,7 +31,7 @@ class TermsOfService(BaseModel): default=False, verbose_name=_('active'), help_text=_( - u'Only one terms of service is allowed to be active' + 'Only one terms of service is allowed to be active' ) ) content = models.TextField(verbose_name=_('content'), blank=True) @@ -43,7 +43,7 @@ class TermsOfService(BaseModel): verbose_name = _('Terms of Service') verbose_name_plural = _('Terms of Service') - def __unicode__(self): + def __str__(self): active = 'inactive' if self.active: active = 'active' @@ -61,7 +61,7 @@ class TermsOfService(BaseModel): .filter(active=True)\ .exists(): raise NoActiveTermsOfService( - u'One of the terms of service must be marked active' + 'One of the terms of service must be marked active' ) super(TermsOfService, self).save(*args, **kwargs) @@ -71,8 +71,8 @@ class UserAgreement(BaseModel): terms_of_service = models.ForeignKey(TermsOfService, related_name='terms', on_delete=models.CASCADE) user = models.ForeignKey(get_fk_user_model(), related_name='user_agreement', on_delete=models.CASCADE) - def __unicode__(self): - return u'%s agreed to TOS: %s' % (self.user.username, + def __str__(self): + return '%s agreed to TOS: %s' % (self.user.username, unicode(self.terms_of_service)) diff --git a/tos/views.py b/tos/views.py index d67299a..8fe4f18 100644 --- a/tos/views.py +++ b/tos/views.py @@ -73,7 +73,7 @@ def check_tos(request, template_name='tos/tos_check.html', else: messages.error( request, - _(u"You cannot login without agreeing to the terms of this site.") + _("You cannot login without agreeing to the terms of this site.") ) context = { 'tos': tos,