Skip to content

Commit

Permalink
[translations]Updated BE translations keys [en], comment #247
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrocha committed Dec 10, 2024
1 parent 6ff75ab commit 7dd89ed
Show file tree
Hide file tree
Showing 13 changed files with 623 additions and 112 deletions.
34 changes: 20 additions & 14 deletions governanceplatform/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.contrib.auth.models import Group
from django.contrib.sites.models import Site
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q, Count
from django.db.models import Count, Q
from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _
from django_otp import devices_for_user, user_has_device
Expand Down Expand Up @@ -422,9 +422,9 @@ class CompanySectorListFilter(SimpleListFilter):
parameter_name = "companyuser_set__sectors"

def lookups(self, request, model_admin):
sectors = Sector.objects.annotate(
child_count=Count('children')
).exclude(parent=None, child_count__gt=0)
sectors = Sector.objects.annotate(child_count=Count("children")).exclude(
parent=None, child_count__gt=0
)
sectors_list = []
user = request.user
# Operator Admin
Expand Down Expand Up @@ -556,7 +556,7 @@ def delete_queryset(self, request, queryset):
messages.add_message(
request,
messages.WARNING,
"Some Companies havn't been deleted because they contains users",
"Some companies haven't been deleted because they contains users",
)
queryset.delete()

Expand All @@ -578,8 +578,12 @@ def save_related(self, request, form, formsets, change):
sectors = dict()
# Access and modify inline objects
for formset in formsets:
if isinstance(formset, CompanyUserInline.formset) and user_in_group(user, "RegulatorUser"):
ru = RegulatorUser.objects.get(user=user, regulator=user.regulators.first())
if isinstance(formset, CompanyUserInline.formset) and user_in_group(
user, "RegulatorUser"
):
ru = RegulatorUser.objects.get(
user=user, regulator=user.regulators.first()
)
for obj in formset.save(commit=False): # Inline objects are here
sects = []
for sect in obj.sectors.all():
Expand All @@ -589,7 +593,9 @@ def save_related(self, request, form, formsets, change):
super().save_related(request, form, formsets, change)
# re assign sectors which are not assigned to the current regulatoruser
for formset in formsets:
if isinstance(formset, CompanyUserInline.formset) and user_in_group(user, "RegulatorUser"):
if isinstance(formset, CompanyUserInline.formset) and user_in_group(
user, "RegulatorUser"
):
for obj in formset.save(commit=False): # Inline objects are here
if sectors[obj] is not None:
obj.sectors.add(*sectors[obj])
Expand Down Expand Up @@ -719,7 +725,7 @@ def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "sectors":
# exclude parent with children from the list
kwargs["queryset"] = Sector.objects.annotate(
child_count=Count('children')
child_count=Count("children")
).exclude(parent=None, child_count__gt=0)

return super().formfield_for_manytomany(db_field, request, **kwargs)
Expand Down Expand Up @@ -814,7 +820,7 @@ def reset_2FA(modeladmin, request, queryset):


class UserRegulatorsListFilter(SimpleListFilter):
title = _("Competent authorities")
title = _("Regulators")
parameter_name = "regulators"

def lookups(self, request, model_admin):
Expand Down Expand Up @@ -852,7 +858,7 @@ def queryset(self, request, queryset):


class UserCompaniesListFilter(SimpleListFilter):
title = _("Companies")
title = _("Operators")
parameter_name = "companies"

def lookups(self, request, model_admin):
Expand All @@ -879,9 +885,9 @@ class UserSectorListFilter(SimpleListFilter):
parameter_name = "sectors"

def lookups(self, request, model_admin):
sectors = Sector.objects.annotate(
child_count=Count('children')
).exclude(parent=None, child_count__gt=0)
sectors = Sector.objects.annotate(child_count=Count("children")).exclude(
parent=None, child_count__gt=0
)
sectors_list = []
user = request.user
# Platform Admin
Expand Down
2 changes: 1 addition & 1 deletion governanceplatform/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CustomUserManager(BaseUserManager):

def create_user(self, email, password, **extra_fields):
if not email:
raise ValueError(_("Users must have an email address"))
raise ValueError(_("User must have an email address"))
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Generated by Django 5.1.2 on 2024-12-10 12:16

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("governanceplatform", "0037_alter_sector_parent"),
]

operations = [
migrations.AlterModelOptions(
name="company",
options={"verbose_name": "Operator", "verbose_name_plural": "Operators"},
),
migrations.AlterModelOptions(
name="regulator",
options={"verbose_name": "Regulator", "verbose_name_plural": "Regulators"},
),
migrations.AlterModelOptions(
name="regulatortranslation",
options={
"default_permissions": (),
"managed": True,
"verbose_name": "Regulator Translation",
},
),
migrations.AlterField(
model_name="company",
name="email",
field=models.CharField(
blank=True,
default=None,
max_length=100,
null=True,
verbose_name="Email address",
),
),
migrations.AlterField(
model_name="companyuser",
name="company",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="governanceplatform.company",
verbose_name="Operator",
),
),
migrations.AlterField(
model_name="observer",
name="is_receiving_all_incident",
field=models.BooleanField(
default=False, verbose_name="Receives all incident notifications"
),
),
migrations.AlterField(
model_name="observerregulation",
name="regulation",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="governanceplatform.regulation",
verbose_name="Legal basis",
),
),
migrations.AlterField(
model_name="regulation",
name="regulators",
field=models.ManyToManyField(
blank=True,
default=None,
to="governanceplatform.regulator",
verbose_name="Regulators",
),
),
migrations.AlterField(
model_name="regulatoruser",
name="regulator",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="governanceplatform.regulator",
verbose_name="Regulator",
),
),
migrations.AlterField(
model_name="sector",
name="parent",
field=models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="children",
to="governanceplatform.sector",
verbose_name="Parent Sector",
),
),
migrations.AlterField(
model_name="user",
name="companies",
field=models.ManyToManyField(
through="governanceplatform.CompanyUser",
to="governanceplatform.company",
verbose_name="Operators",
),
),
migrations.AlterField(
model_name="user",
name="email",
field=models.EmailField(
error_messages={
"unique": "An account with this email address already exists."
},
max_length=254,
unique=True,
verbose_name="Email address",
),
),
migrations.AlterField(
model_name="user",
name="is_staff",
field=models.BooleanField(
default=False,
help_text="Determines if the user can log in via the administration interface.",
verbose_name="Administrator",
),
),
migrations.AlterField(
model_name="user",
name="regulators",
field=models.ManyToManyField(
through="governanceplatform.RegulatorUser",
to="governanceplatform.regulator",
verbose_name="Regulators",
),
),
]
32 changes: 16 additions & 16 deletions governanceplatform/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Sector(TranslatableModel):
on_delete=models.CASCADE,
blank=True,
default=None,
verbose_name=_("Parent"),
verbose_name=_("Parent Sector"),
related_name="children",
)
acronym = models.CharField(verbose_name=_("Acronym"), max_length=4)
Expand Down Expand Up @@ -143,7 +143,7 @@ class Company(models.Model):
blank=True,
null=True,
default=None,
verbose_name=_("e-mail address"),
verbose_name=_("Email address"),
)
phone_number = PhoneNumberField(
verbose_name=_("Phone number"),
Expand Down Expand Up @@ -180,8 +180,8 @@ def get_sectors(self):
return sectors

class Meta:
verbose_name = _("Company")
verbose_name_plural = _("Companies")
verbose_name = _("Operator")
verbose_name_plural = _("Operators")


# Regulator
Expand Down Expand Up @@ -219,8 +219,8 @@ def __str__(self):
return name_translation or ""

class Meta:
verbose_name = _("Competent authority")
verbose_name_plural = _("Competent authorities")
verbose_name = _("Regulator")
verbose_name_plural = _("Regulators")


# Observer
Expand Down Expand Up @@ -248,7 +248,7 @@ class Observer(TranslatableModel):
null=True,
)
is_receiving_all_incident = models.BooleanField(
default=False, verbose_name=_("Receives all incidents")
default=False, verbose_name=_("Receives all incident notifications")
)
functionalities = models.ManyToManyField(
Functionality,
Expand Down Expand Up @@ -318,10 +318,10 @@ class Meta:
class User(AbstractUser, PermissionsMixin):
username = None
email = models.EmailField(
verbose_name=_("e-mail address"),
verbose_name=_("Email address"),
unique=True,
error_messages={
"unique": _("An account with this email already exists"),
"unique": _("An account with this email address already exists."),
},
)
phone_number = PhoneNumberField(
Expand All @@ -334,12 +334,12 @@ class User(AbstractUser, PermissionsMixin):
companies = models.ManyToManyField(
Company,
through="CompanyUser",
verbose_name=_("Companies"),
verbose_name=_("Operators"),
)
regulators = models.ManyToManyField(
Regulator,
through="RegulatorUser",
verbose_name=_("Competent authorities"),
verbose_name=_("Regulators"),
)
observers = models.ManyToManyField(
Observer,
Expand All @@ -351,7 +351,7 @@ class User(AbstractUser, PermissionsMixin):
verbose_name=_("Administrator"),
default=False,
help_text=_(
"Specifies whether a user can log in via the administration interface."
"Determines if the user can log in via the administration interface."
),
)
accepted_terms = models.BooleanField(default=False)
Expand Down Expand Up @@ -429,7 +429,7 @@ class CompanyUser(models.Model):
company = models.ForeignKey(
Company,
on_delete=models.CASCADE,
verbose_name=_("Company"),
verbose_name=_("Operator"),
)
user = models.ForeignKey(
User,
Expand Down Expand Up @@ -468,7 +468,7 @@ class RegulatorUser(models.Model):
regulator = models.ForeignKey(
Regulator,
on_delete=models.CASCADE,
verbose_name=_("Competent authority"),
verbose_name=_("Regulator"),
)
is_regulator_administrator = models.BooleanField(
default=False, verbose_name=_("is administrator")
Expand Down Expand Up @@ -529,7 +529,7 @@ class Regulation(TranslatableModel):
Regulator,
default=None,
blank=True,
verbose_name=_("Competent authorities"),
verbose_name=_("Regulators"),
)

@admin.display(description="regulators")
Expand Down Expand Up @@ -571,7 +571,7 @@ class ObserverRegulation(models.Model):
regulation = models.ForeignKey(
Regulation,
on_delete=models.CASCADE,
verbose_name=_("Regulation"),
verbose_name=_("Legal basis"),
)
observer = models.ForeignKey(
Observer,
Expand Down
Loading

0 comments on commit 7dd89ed

Please sign in to comment.