feat: dynamic regional get_usage_type_display method and get_usage_type_choices provider in PublicBuilding model
This commit is contained in:
parent
a1d9c2022c
commit
ca5d17261b
1 changed files with 30 additions and 10 deletions
|
|
@ -13,16 +13,26 @@ from common.storages import PrivateMediaStorage
|
|||
|
||||
private_storage = PrivateMediaStorage()
|
||||
|
||||
USAGE_TYPE_CHOICES = (
|
||||
('administrative', _('Administratif (Hôtel de Ville / Maison Communale / Mairie)')),
|
||||
('education', _('Enseignement / École / Crèche')),
|
||||
('sports', _('Sport & Équipement sportif')),
|
||||
('culture', _('Culture / Médiathèque / Musée')),
|
||||
('social', _('Social / Centre communautaire')),
|
||||
('technical', _('Technique / Ateliers / Stock')),
|
||||
('housing', _('Logement communal')),
|
||||
('other', _('Autre bâtiment public')),
|
||||
)
|
||||
def get_usage_type_choices(standard='BE'):
|
||||
"""
|
||||
Renvoie la liste des choix de type d'usage adaptés à la norme régionale active (BE, FR, INT).
|
||||
"""
|
||||
from common.utils import get_regional_terms
|
||||
terms = get_regional_terms(standard)
|
||||
admin_label = _("Administratif") + f" ({terms['admin_building']})"
|
||||
return (
|
||||
('administrative', admin_label),
|
||||
('education', _('Enseignement / École / Crèche')),
|
||||
('sports', _('Sport & Équipement sportif')),
|
||||
('culture', _('Culture / Médiathèque / Musée')),
|
||||
('social', _('Social / Centre communautaire')),
|
||||
('technical', _('Technique / Ateliers / Stock')),
|
||||
('housing', _('Logement communal')),
|
||||
('other', _('Autre bâtiment public')),
|
||||
)
|
||||
|
||||
|
||||
USAGE_TYPE_CHOICES = get_usage_type_choices('BE')
|
||||
|
||||
BUILDING_STATUS_CHOICES = (
|
||||
('in_service', _('En service')),
|
||||
|
|
@ -123,6 +133,16 @@ class PublicBuilding(AbstractGeoAsset):
|
|||
def get_absolute_url(self):
|
||||
return reverse('assets:publicbuilding_detail', kwargs={'pk': self.pk})
|
||||
|
||||
def get_usage_type_display(self, standard=None):
|
||||
"""
|
||||
Renvoie le libellé du type d'usage adapté dynamiquement à la norme régionale (BE, FR, INT).
|
||||
"""
|
||||
from common.utils import get_regional_terms
|
||||
if self.usage_type == 'administrative':
|
||||
terms = get_regional_terms(standard or getattr(self, '_regional_standard', 'BE'))
|
||||
return f"Administratif ({terms['admin_building']})"
|
||||
return dict(USAGE_TYPE_CHOICES).get(self.usage_type, self.usage_type)
|
||||
|
||||
|
||||
class BuildingLevel(models.Model):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue