Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

432-gettext-gettext_lazy: use consistent import as for gettext's #855

Merged
merged 1 commit into from
May 6, 2024
Merged
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: 8 additions & 8 deletions amelie/about/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
from django.db import models
from django.template.defaultfilters import slugify
from django.utils.translation import get_language
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _l


class Page(models.Model):
name_nl = models.CharField(max_length=100, verbose_name=_('Name'))
name_en = models.CharField(max_length=100, verbose_name=_('Name (en)'), blank=True)
name_nl = models.CharField(max_length=100, verbose_name=_l('Name'))
name_en = models.CharField(max_length=100, verbose_name=_l('Name (en)'), blank=True)
slug_nl = models.SlugField(max_length=100, editable=False)
slug_en = models.SlugField(max_length=100, editable=False)
educational = models.BooleanField(default=False, verbose_name=_("Educational page?"))
content_nl = models.TextField(verbose_name=_('Content'))
content_en = models.TextField(verbose_name=_('Content (en)'), blank=True)
educational = models.BooleanField(default=False, verbose_name=_l("Educational page?"))
content_nl = models.TextField(verbose_name=_l('Content'))
content_en = models.TextField(verbose_name=_l('Content (en)'), blank=True)
last_modified = models.DateTimeField(auto_now=True)

class Meta:
ordering = ['name_nl']
verbose_name = _('Page')
verbose_name_plural = _("Pages")
verbose_name = _l('Page')
verbose_name_plural = _l("Pages")

def __str__(self):
return self.name
Expand Down
6 changes: 3 additions & 3 deletions amelie/activities/feeds.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from django.contrib.syndication.views import Feed
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _l

from amelie.activities.models import Activity


class Activities(Feed):
link = '/activities/'
title = _('IA Events')
description = _('Inter-Actief\'s activities in the coming weeks')
title = _l('IA Events')
description = _l('Inter-Actief\'s activities in the coming weeks')

title_template = "feeds/news_title.html"
description_template = "feeds/news_content.html"
Expand Down
52 changes: 26 additions & 26 deletions amelie/activities/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path
from django.forms import widgets, SplitDateTimeField
from django.utils import formats, timezone
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _l

from amelie.activities.models import Activity, EnrollmentoptionQuestion, \
EnrollmentoptionCheckbox, EnrollmentoptionCheckboxAnswer, \
Expand All @@ -25,7 +25,7 @@ class PaymentForm(forms.Form):
(Participation.PaymentMethodChoices.CASH.value,
Participation.PaymentMethodChoices.CASH.label),
],
label=_('Method of payment'))
label=_l('Method of payment'))

def __init__(self, mandate=False, waiting_list=False, board=False, *args, **kwargs):
super(PaymentForm, self).__init__(*args, **kwargs)
Expand All @@ -38,17 +38,17 @@ def __init__(self, mandate=False, waiting_list=False, board=False, *args, **kwar

if waiting_list:
self.fields['waiting_list'] = forms.ChoiceField(choices=[
('Wait', _("Place on bottom of waiting list")),
], label=_("Waiting list action"))
('Wait', _l("Place on bottom of waiting list")),
], label=_l("Waiting list action"))
if board:
choices = self.fields['waiting_list'].choices
choices.append(('Skip', _("Skip waiting list and enroll immediately")))
choices.append(('Skip', _l("Skip waiting list and enroll immediately")))
self.fields['waiting_list'].choices = choices


class ActivityForm(forms.ModelForm):

price = forms.DecimalField(required=False, initial="0.00", min_value=0, decimal_places=2, label=_('Price'))
price = forms.DecimalField(required=False, initial="0.00", min_value=0, decimal_places=2, label=_l('Price'))

class Meta:
model = Activity
Expand Down Expand Up @@ -93,18 +93,18 @@ def clean(self):
self.cleaned_data['price'] = 0

if self.cleaned_data["price"] > settings.PERSONAL_TAB_MAXIMUM_ACTIVITY_PRICE and self.cleaned_data["enrollment"]:
raise forms.ValidationError(_("Website enrolment has a maximum of {0} euro. Either turn off the ability to enrol or decrease the cost of the activity.").format(settings.PERSONAL_TAB_MAXIMUM_ACTIVITY_PRICE))
raise forms.ValidationError(_l("Website enrolment has a maximum of {0} euro. Either turn off the ability to enrol or decrease the cost of the activity.").format(settings.PERSONAL_TAB_MAXIMUM_ACTIVITY_PRICE))

if self.cleaned_data["enrollment"]:
if not self.cleaned_data.get('enrollment_begin', None):
self.add_error('enrollment_begin', _('There is no enrollment start date entered.'))
self.add_error('enrollment_begin', _l('There is no enrollment start date entered.'))

if not self.cleaned_data.get('enrollment_end'):
self.add_error('enrollment_end', _('There is no enrollment end date entered.'))
self.add_error('enrollment_end', _l('There is no enrollment end date entered.'))

if self.cleaned_data.get('enrollment_begin', None) and self.cleaned_data.get('enrollment_stop', None) \
and self.cleaned_data['enrollment_stop'] < self.cleaned_data['enrollment_begin']:
self.add_error('enrollment_stop', _("Signup end must be after the signup start."))
self.add_error('enrollment_stop', _l("Signup end must be after the signup start."))

return self.cleaned_data

Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(self, enrollmentoption, checked, *args, **kwargs):
def clean_answer(self):
data = self.cleaned_data['answer']
if data and not self.enrollmentoption.spots_left():
self.add_error('answer', _("Sorry, but the last spot has been claimed already!"))
self.add_error('answer', _l("Sorry, but the last spot has been claimed already!"))
return data

class Meta:
Expand All @@ -207,9 +207,9 @@ def clean_answer(self):
if not data:
data = 0
if max_per_person is not None and data > max_per_person:
self.add_error('answer', _("Sorry, but you cannot exceed the maximum amount per person!"))
self.add_error('answer', _l("Sorry, but you cannot exceed the maximum amount per person!"))
if data > 0 and not self.enrollmentoption.spots_left():
self.add_error('answer', _("Sorry, but there are not enough spots left!"))
self.add_error('answer', _l("Sorry, but there are not enough spots left!"))
return data

class Meta:
Expand All @@ -232,17 +232,17 @@ class PhotoCheckboxSelectMultiple(widgets.CheckboxSelectMultiple):


class PhotoUploadForm(forms.Form):
photographer = forms.ModelChoiceField(Person.objects.none(), label=_('Photographer'), required=False)
first_name = forms.CharField(max_length=50, label=_('First name'), required=False,
help_text=_('Use this field if a non-member is the owner of these pictures'))
last_name_prefix = forms.CharField(max_length=25, label=_('Last name pre-fix'), required=False,
help_text=_('Use this field if a non-member is the owner of these pictures'))
last_name = forms.CharField(max_length=50, label=_('Last name'), required=False,
help_text=_('Use this field if a non-member is the owner of these pictures'))
activity = ActivityModelChoiceField(Activity.objects.none(), label=_('Activities'))
public = forms.BooleanField(label=_('Public'), required=False,
help_text=_('Photos are also available without logging in'), initial=True)
photos = forms.MultipleChoiceField(widget=PhotoCheckboxSelectMultiple, label=_('Photos'))
photographer = forms.ModelChoiceField(Person.objects.none(), label=_l('Photographer'), required=False)
first_name = forms.CharField(max_length=50, label=_l('First name'), required=False,
help_text=_l('Use this field if a non-member is the owner of these pictures'))
last_name_prefix = forms.CharField(max_length=25, label=_l('Last name pre-fix'), required=False,
help_text=_l('Use this field if a non-member is the owner of these pictures'))
last_name = forms.CharField(max_length=50, label=_l('Last name'), required=False,
help_text=_l('Use this field if a non-member is the owner of these pictures'))
activity = ActivityModelChoiceField(Activity.objects.none(), label=_l('Activities'))
public = forms.BooleanField(label=_l('Public'), required=False,
help_text=_l('Photos are also available without logging in'), initial=True)
photos = forms.MultipleChoiceField(widget=PhotoCheckboxSelectMultiple, label=_l('Photos'))

def __init__(self, photos, *args, **kwargs):
super(PhotoUploadForm, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -281,7 +281,7 @@ def clean_photo_files(self):
extension = Path(file.name).suffix[1:].lower()
if extension not in allowed_extensions:
raise ValidationError(
message=_('File extension “%(extension)s” is not allowed. '
message=_l('File extension “%(extension)s” is not allowed. '
'Allowed extensions are: %(allowed_extensions)s.'),
code='invalid_extension',
params={'extension': extension,
Expand All @@ -291,7 +291,7 @@ def clean_photo_files(self):


class EventDeskActivityMatchForm(forms.Form):
activity = ActivityModelChoiceField(Activity.objects.none(), label=_('Activity'))
activity = ActivityModelChoiceField(Activity.objects.none(), label=_l('Activity'))

def __init__(self, activities, *args, **kwargs):
super(EventDeskActivityMatchForm, self).__init__(*args, **kwargs)
Expand Down
10 changes: 5 additions & 5 deletions amelie/activities/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from amelie.members.models import Preference
from amelie.tools.calendar import ical_calendar
from amelie.tools.mail import PersonRecipient
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _l


def activity_send_cashrefundmail(cash_participants, activity, request):
Expand Down Expand Up @@ -59,9 +59,9 @@ def activity_send_enrollmentmail(participation, from_waiting_list=False):
if from_waiting_list:
template_name = "activities/activity_enrolled_from_waiting_list.mail"

task = MailTask(from_=_(u'Inter-Activity') + ' <[email protected]>',
task = MailTask(from_=_l(u'Inter-Activity') + ' <[email protected]>',
template_name=template_name,
report_to=_(u'Inter-Activity') + ' <[email protected]>', report_always=False)
report_to=_l(u'Inter-Activity') + ' <[email protected]>', report_always=False)
task.add_recipient(PersonRecipient(
recipient=person,
context={'activity': activity,
Expand Down Expand Up @@ -124,9 +124,9 @@ def activity_send_on_waiting_listmail(participation):
invite = False
attachments = []

task = MailTask(from_=_('Inter-Activity') + ' <[email protected]>',
task = MailTask(from_=_l('Inter-Activity') + ' <[email protected]>',
template_name='activities/activity_enrolled_on_waiting_list.mail',
report_to=_('Inter-Activity') + ' <[email protected]>', report_always=False)
report_to=_l('Inter-Activity') + ' <[email protected]>', report_always=False)
task.add_recipient(PersonRecipient(
recipient=person,
context={'activity': activity,
Expand Down
Loading
Loading