Commit f37ef6e1 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

use gettext instead of deprecated ugettext

parent ed8c1e02
Pipeline #75726 passed with stage
in 45 seconds
...@@ -3,7 +3,7 @@ from django.contrib.admin.options import get_content_type_for_model ...@@ -3,7 +3,7 @@ from django.contrib.admin.options import get_content_type_for_model
from django.urls import reverse from django.urls import reverse
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ugettext from django.utils.translation import gettext
from basetheme_bootstrap.user_preferences_utils import get_user_preference_class from basetheme_bootstrap.user_preferences_utils import get_user_preference_class
...@@ -26,7 +26,7 @@ class ViewOnSiteModelAdmin(admin.ModelAdmin): ...@@ -26,7 +26,7 @@ class ViewOnSiteModelAdmin(admin.ModelAdmin):
'object_id': obj.pk 'object_id': obj.pk
}) + '"><i class="fa fa-external-link"></i></a><center>') }) + '"><i class="fa fa-external-link"></i></a><center>')
view_on_site_in_list.short_description = format_html('<center>' + ugettext('View on site') + '<center>') view_on_site_in_list.short_description = format_html('<center>' + gettext('View on site') + '<center>')
class UserPreferencesAdmin(admin.ModelAdmin): class UserPreferencesAdmin(admin.ModelAdmin):
......
...@@ -4,7 +4,7 @@ from django.db.models import Q ...@@ -4,7 +4,7 @@ from django.db.models import Q
from django.forms import widgets from django.forms import widgets
from django.urls import reverse from django.urls import reverse
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_lazy as _
from basetheme_bootstrap.default_settings import is_username_is_email, is_first_last_name_required from basetheme_bootstrap.default_settings import is_username_is_email, is_first_last_name_required
......
...@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model ...@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _, ugettext from django.utils.translation import gettext_lazy as _
from basetheme_bootstrap import user_preferences_utils from basetheme_bootstrap import user_preferences_utils
......
...@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model ...@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _, ugettext from django.utils.translation import gettext
logger = logging.getLogger("basetheme_bootstrap") logger = logging.getLogger("basetheme_bootstrap")
...@@ -83,7 +83,7 @@ class UserPreferencesAbstractModelWithoutUser(models.Model): ...@@ -83,7 +83,7 @@ class UserPreferencesAbstractModelWithoutUser(models.Model):
return super().save(*args, **kwargs) return super().save(*args, **kwargs)
def __str__(self): def __str__(self):
return ugettext("Default preferences") if self.user is None else '%s (%s)' % ( return gettext("Default preferences") if self.user is None else '%s (%s)' % (
self.user.username, self.user.username,
self._meta.verbose_name.title(), self._meta.verbose_name.title(),
) )
......
...@@ -20,7 +20,7 @@ from django.template.defaultfilters import time as time_filter ...@@ -20,7 +20,7 @@ from django.template.defaultfilters import time as time_filter
from django.urls import reverse from django.urls import reverse
from django.utils.encoding import force_bytes, force_text from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.utils.translation import ugettext from django.utils.translation import gettext
from basetheme_bootstrap import tokens from basetheme_bootstrap import tokens
from basetheme_bootstrap import user_preferences_utils from basetheme_bootstrap import user_preferences_utils
...@@ -57,8 +57,8 @@ def change_password(request): ...@@ -57,8 +57,8 @@ def change_password(request):
else: else:
form = PasswordChangeForm(request.user) form = PasswordChangeForm(request.user)
return render(request, 'registration/small_form_host.html', { return render(request, 'registration/small_form_host.html', {
'title': ugettext('Change password'), 'title': gettext('Change password'),
'submit_text': ugettext('Save changes'), 'submit_text': gettext('Save changes'),
'form': form 'form': form
}) })
...@@ -113,10 +113,10 @@ def signup(request): ...@@ -113,10 +113,10 @@ def signup(request):
def account_is_pending_view(request, email): def account_is_pending_view(request, email):
return render(request, 'basetheme_bootstrap/simple_message_page.html', { return render(request, 'basetheme_bootstrap/simple_message_page.html', {
'page_title': ugettext('Account activation pending'), 'page_title': gettext('Account activation pending'),
'message': ugettext('An email was sent with a link to validate your account, ' 'message': gettext('An email was sent with a link to validate your account, '
'please click on the link to enable your account.'), 'please click on the link to enable your account.'),
'sub_message': ugettext('The email has been addressed to %s.') % email, 'sub_message': gettext('The email has been addressed to %s.') % email,
}) })
...@@ -130,7 +130,7 @@ def send_account_created(request, user, auto_active=False, next_page=None): ...@@ -130,7 +130,7 @@ def send_account_created(request, user, auto_active=False, next_page=None):
if next_page: if next_page:
activation_link += "?next=" + next_page activation_link += "?next=" + next_page
if auto_active: if auto_active:
message = ugettext( message = gettext(
'Dear %(first_name)s %(last_name)s\n\n' 'Dear %(first_name)s %(last_name)s\n\n'
'Your account have successfully been created on %(joined)s.' 'Your account have successfully been created on %(joined)s.'
'\n\n' '\n\n'
...@@ -140,7 +140,7 @@ def send_account_created(request, user, auto_active=False, next_page=None): ...@@ -140,7 +140,7 @@ def send_account_created(request, user, auto_active=False, next_page=None):
joined=str(user.date_joined), joined=str(user.date_joined),
) )
else: else:
message = ugettext( message = gettext(
'Dear %(first_name)s %(last_name)s\n\n' 'Dear %(first_name)s %(last_name)s\n\n'
'Your account have successfully been created on %(joined)s.' 'Your account have successfully been created on %(joined)s.'
'\n\n' '\n\n'
...@@ -154,7 +154,7 @@ def send_account_created(request, user, auto_active=False, next_page=None): ...@@ -154,7 +154,7 @@ def send_account_created(request, user, auto_active=False, next_page=None):
activation_link=activation_link, activation_link=activation_link,
) )
send_mail( send_mail(
subject=ugettext('Account successfully created'), subject=gettext('Account successfully created'),
message=message, message=message,
from_email=settings.DEFAULT_FROM_EMAIL, from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[user.email], recipient_list=[user.email],
...@@ -177,8 +177,8 @@ def user_update(request): ...@@ -177,8 +177,8 @@ def user_update(request):
else: else:
form = MyUserChangeForm(instance=request.user) form = MyUserChangeForm(instance=request.user)
return render(request, 'registration/small_form_host.html', { return render(request, 'registration/small_form_host.html', {
'title': ugettext('Update account'), 'title': gettext('Update account'),
'submit_text': ugettext('Save changes'), 'submit_text': gettext('Save changes'),
'form': form, 'form': form,
'medium_width': True, 'medium_width': True,
}) })
...@@ -195,7 +195,7 @@ def user_delete(request): ...@@ -195,7 +195,7 @@ def user_delete(request):
messages.success(request, 'Your account was successfully deleted!') messages.success(request, 'Your account was successfully deleted!')
return redirect('/') return redirect('/')
except ProtectedError as e: except ProtectedError as e:
messages.error(request, ugettext("Some data remaining in the system prevent the deletion of your " messages.error(request, gettext("Some data remaining in the system prevent the deletion of your "
"account. Please either remove these data, or contact the " "account. Please either remove these data, or contact the "
"administrator to solve the issue.\nMessage:\n" + str(e))) "administrator to solve the issue.\nMessage:\n" + str(e)))
except Exception as e: except Exception as e:
...@@ -206,8 +206,8 @@ def user_delete(request): ...@@ -206,8 +206,8 @@ def user_delete(request):
collector = NestedObjects(using=router.db_for_write(get_user_model())) collector = NestedObjects(using=router.db_for_write(get_user_model()))
collector.collect([request.user,]) collector.collect([request.user,])
return render(request, 'registration/account_deletion.html', { return render(request, 'registration/account_deletion.html', {
'title': ugettext('Account deletion'), 'title': gettext('Account deletion'),
'submit_text': ugettext('Delete account and all related data'), 'submit_text': gettext('Delete account and all related data'),
'form': form, 'form': form,
'protected': collector.protected, 'protected': collector.protected,
'medium_width': True, 'medium_width': True,
...@@ -236,7 +236,7 @@ def account_detail(request): ...@@ -236,7 +236,7 @@ def account_detail(request):
form_prefs.save() form_prefs.save()
messages.success( messages.success(
request=request, request=request,
message=ugettext("Preferences successfully saved on %s") % time_filter(datetime.now()), message=gettext("Preferences successfully saved on %s") % time_filter(datetime.now()),
) )
return redirect(reverse("basetheme_bootstrap:account")) return redirect(reverse("basetheme_bootstrap:account"))
# dirty patch for time field (don't know why django doesn't express the correct type by default) # dirty patch for time field (don't know why django doesn't express the correct type by default)
...@@ -263,7 +263,7 @@ def activate(request, uidb64, token): ...@@ -263,7 +263,7 @@ def activate(request, uidb64, token):
user.groups.remove(user.groups.get(name=__PENDING_ACCOUNT_USER)) user.groups.remove(user.groups.get(name=__PENDING_ACCOUNT_USER))
user.save() user.save()
login(request, user) login(request, user)
message = ugettext('Thank you for your email confirmation, you account have been activated ' message = gettext('Thank you for your email confirmation, you account have been activated '
'and you are now logged in.') 'and you are now logged in.')
next_page = request.GET.get("next", '') next_page = request.GET.get("next", '')
if next_page: if next_page:
...@@ -272,7 +272,7 @@ def activate(request, uidb64, token): ...@@ -272,7 +272,7 @@ def activate(request, uidb64, token):
# return redirect('home') # return redirect('home')
# return HttpResponse('Thank you for your email confirmation. Now you can login your account.') # return HttpResponse('Thank you for your email confirmation. Now you can login your account.')
return render(request, 'basetheme_bootstrap/simple_message_page.html', { return render(request, 'basetheme_bootstrap/simple_message_page.html', {
'page_title': ugettext('Account activated'), 'page_title': gettext('Account activated'),
'message': message, 'message': message,
}) })
else: else:
...@@ -280,5 +280,5 @@ def activate(request, uidb64, token): ...@@ -280,5 +280,5 @@ def activate(request, uidb64, token):
return account_is_pending_view(request, email=user.email) return account_is_pending_view(request, email=user.email)
else: else:
return render(request, 'basetheme_bootstrap/simple_message_page.html', { return render(request, 'basetheme_bootstrap/simple_message_page.html', {
'page_title': ugettext('Activation link is invalid!'), 'page_title': gettext('Activation link is invalid!'),
}) })
...@@ -7,7 +7,7 @@ readme = open('README.rst').read() ...@@ -7,7 +7,7 @@ readme = open('README.rst').read()
setup( setup(
name='django-basetheme-bootstrap', name='django-basetheme-bootstrap',
version='0.2.78', version='0.2.79',
description='Django Basetheme Bootstrap', description='Django Basetheme Bootstrap',
long_description=readme, long_description=readme,
author='Bryan Brancotte', author='Bryan Brancotte',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment