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
from django.urls import reverse
from django.utils.html import format_html
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
......@@ -26,7 +26,7 @@ class ViewOnSiteModelAdmin(admin.ModelAdmin):
'object_id': obj.pk
}) + '"><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):
......
......@@ -4,7 +4,7 @@ from django.db.models import Q
from django.forms import widgets
from django.urls import reverse
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
......
......@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.core.exceptions import ValidationError
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
......
......@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.core.exceptions import ValidationError
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")
......@@ -83,7 +83,7 @@ class UserPreferencesAbstractModelWithoutUser(models.Model):
return super().save(*args, **kwargs)
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._meta.verbose_name.title(),
)
......
......@@ -20,7 +20,7 @@ from django.template.defaultfilters import time as time_filter
from django.urls import reverse
from django.utils.encoding import force_bytes, force_text
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 user_preferences_utils
......@@ -57,8 +57,8 @@ def change_password(request):
else:
form = PasswordChangeForm(request.user)
return render(request, 'registration/small_form_host.html', {
'title': ugettext('Change password'),
'submit_text': ugettext('Save changes'),
'title': gettext('Change password'),
'submit_text': gettext('Save changes'),
'form': form
})
......@@ -113,10 +113,10 @@ def signup(request):
def account_is_pending_view(request, email):
return render(request, 'basetheme_bootstrap/simple_message_page.html', {
'page_title': ugettext('Account activation pending'),
'message': ugettext('An email was sent with a link to validate your account, '
'page_title': gettext('Account activation pending'),
'message': gettext('An email was sent with a link to validate 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):
if next_page:
activation_link += "?next=" + next_page
if auto_active:
message = ugettext(
message = gettext(
'Dear %(first_name)s %(last_name)s\n\n'
'Your account have successfully been created on %(joined)s.'
'\n\n'
......@@ -140,7 +140,7 @@ def send_account_created(request, user, auto_active=False, next_page=None):
joined=str(user.date_joined),
)
else:
message = ugettext(
message = gettext(
'Dear %(first_name)s %(last_name)s\n\n'
'Your account have successfully been created on %(joined)s.'
'\n\n'
......@@ -154,7 +154,7 @@ def send_account_created(request, user, auto_active=False, next_page=None):
activation_link=activation_link,
)
send_mail(
subject=ugettext('Account successfully created'),
subject=gettext('Account successfully created'),
message=message,
from_email=settings.DEFAULT_FROM_EMAIL,
recipient_list=[user.email],
......@@ -177,8 +177,8 @@ def user_update(request):
else:
form = MyUserChangeForm(instance=request.user)
return render(request, 'registration/small_form_host.html', {
'title': ugettext('Update account'),
'submit_text': ugettext('Save changes'),
'title': gettext('Update account'),
'submit_text': gettext('Save changes'),
'form': form,
'medium_width': True,
})
......@@ -195,7 +195,7 @@ def user_delete(request):
messages.success(request, 'Your account was successfully deleted!')
return redirect('/')
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 "
"administrator to solve the issue.\nMessage:\n" + str(e)))
except Exception as e:
......@@ -206,8 +206,8 @@ def user_delete(request):
collector = NestedObjects(using=router.db_for_write(get_user_model()))
collector.collect([request.user,])
return render(request, 'registration/account_deletion.html', {
'title': ugettext('Account deletion'),
'submit_text': ugettext('Delete account and all related data'),
'title': gettext('Account deletion'),
'submit_text': gettext('Delete account and all related data'),
'form': form,
'protected': collector.protected,
'medium_width': True,
......@@ -236,7 +236,7 @@ def account_detail(request):
form_prefs.save()
messages.success(
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"))
# 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):
user.groups.remove(user.groups.get(name=__PENDING_ACCOUNT_USER))
user.save()
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.')
next_page = request.GET.get("next", '')
if next_page:
......@@ -272,7 +272,7 @@ def activate(request, uidb64, token):
# return redirect('home')
# return HttpResponse('Thank you for your email confirmation. Now you can login your account.')
return render(request, 'basetheme_bootstrap/simple_message_page.html', {
'page_title': ugettext('Account activated'),
'page_title': gettext('Account activated'),
'message': message,
})
else:
......@@ -280,5 +280,5 @@ def activate(request, uidb64, token):
return account_is_pending_view(request, email=user.email)
else:
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()
setup(
name='django-basetheme-bootstrap',
version='0.2.78',
version='0.2.79',
description='Django Basetheme Bootstrap',
long_description=readme,
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