Merge branch 'main' into release

This commit is contained in:
Cayo Puigdefabregas 2024-03-19 12:41:22 +01:00
commit c6f534d2f8
5 changed files with 15 additions and 4 deletions

View file

@ -1021,7 +1021,10 @@ class SchemasImportAddView(SchemasMix):
def get_description(self): def get_description(self):
for des in json.loads(self.get_template_description()).get('description', []): for des in json.loads(self.get_template_description()).get('description', []):
if settings.LANGUAGE_CODE == des.get('lang'): lang = settings.LANGUAGE_CODE
if lang == 'ca':
lang = 'ca_ES'
if lang == des.get('lang'):
return des.get('value', '') return des.get('value', '')
return '' return ''

View file

@ -537,7 +537,7 @@ class Schemas(models.Model):
if request: if request:
language_code = request.LANGUAGE_CODE language_code = request.LANGUAGE_CODE
if self._is_catalan_code(language_code): if self._is_catalan_code(language_code):
language_code = 'ca' language_code = 'ca_ES'
return language_code return language_code
@ -549,7 +549,7 @@ class Schemas(models.Model):
return None return None
def _is_catalan_code(self, language_code): def _is_catalan_code(self, language_code):
return language_code == 'ca_ES' return language_code == 'ca'
@name.setter @name.setter
def name(self, value): def name(self, value):

View file

@ -36,6 +36,7 @@ class KeyFirstTimeTest(TestCase):
settings.DOMAIN = self.org.name settings.DOMAIN = self.org.name
settings.ENABLE_EMAIL = False settings.ENABLE_EMAIL = False
settings.LANGUAGE_CODE = 'en'
def set_cache(self): def set_cache(self):
cache.set("KEY_DIDS", '1234', None) cache.set("KEY_DIDS", '1234', None)
@ -94,6 +95,7 @@ class CredentialsViewTest(TestCase):
settings.DOMAIN = self.org.name settings.DOMAIN = self.org.name
settings.ENABLE_EMAIL = False settings.ENABLE_EMAIL = False
settings.LANGUAGE_CODE = 'en'
self.admin_login() self.admin_login()
self.create_schemas() self.create_schemas()

View file

@ -12,6 +12,7 @@ from django.core.exceptions import FieldError
from idhub_auth.models import User from idhub_auth.models import User
from idhub.admin.tables import DashboardTable, UserTable, TemplateTable from idhub.admin.tables import DashboardTable, UserTable, TemplateTable
from idhub.models import Event, Membership, Rol, UserRol, Service, Schemas from idhub.models import Event, Membership, Rol, UserRol, Service, Schemas
from oidc4vp.models import Organization
class AdminDashboardTableTest(TestCase): class AdminDashboardTableTest(TestCase):
@ -22,6 +23,10 @@ class AdminDashboardTableTest(TestCase):
password='adminpass12') password='adminpass12')
self.admin_user.accept_gdpr=True self.admin_user.accept_gdpr=True
self.admin_user.save() self.admin_user.save()
self.org = Organization.objects.create(name="testserver", main=True)
settings.LANGUAGE_CODE = 'en'
settings.DOMAIN = self.org.name
settings.ENABLE_EMAIL = False
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):

View file

@ -197,12 +197,13 @@ LOCALE_PATHS = [
] ]
# LANGUAGE_CODE="en" # LANGUAGE_CODE="en"
# LANGUAGE_CODE="es" # LANGUAGE_CODE="es"
LANGUAGE_CODE="en" LANGUAGE_CODE = config('LANGUAGE_CODE', "ca")
gettext = lambda s: s gettext = lambda s: s
LANGUAGES = ( LANGUAGES = (
('de', gettext('German')), ('de', gettext('German')),
('en', gettext('English')), ('en', gettext('English')),
('ca', gettext('Catalan')), ('ca', gettext('Catalan')),
('es', gettext('Spanish')),
) )
USE_I18N = True USE_I18N = True
USE_L10N = True USE_L10N = True