refactor: update document sequencing logic and refresh internationalization message catalogs
This commit is contained in:
parent
5f8a771277
commit
14ab4d15df
8 changed files with 3211 additions and 2775 deletions
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
|
@ -72,7 +72,7 @@ def get_sequenced_intervention_documents(intervention) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Organise les documents et photos de l'intervention en 3 blocs temporels :
|
Organise les documents et photos de l'intervention en 3 blocs temporels :
|
||||||
1. before_work : Avant réalisation (préparation, constat, signalement)
|
1. before_work : Avant réalisation (préparation, constat, signalement)
|
||||||
2. during_work : Exécution du chantier (pendant les travaux)
|
2. during_work : Exécution de l'intervention (pendant les travaux)
|
||||||
3. after_work : Après réalisation (contrôle, levée de réserves, clôture)
|
3. after_work : Après réalisation (contrôle, levée de réserves, clôture)
|
||||||
|
|
||||||
Retourne un dictionnaire :
|
Retourne un dictionnaire :
|
||||||
|
|
@ -165,7 +165,7 @@ def get_sequenced_intervention_documents(intervention) -> Dict[str, Any]:
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'key': 'during_work',
|
'key': 'during_work',
|
||||||
'title': _("Exécution du chantier"),
|
'title': _("Exécution de l'intervention"),
|
||||||
'subtitle': _("Travaux en cours et constat d'achèvement"),
|
'subtitle': _("Travaux en cours et constat d'achèvement"),
|
||||||
'icon': 'bi-tools',
|
'icon': 'bi-tools',
|
||||||
'badge_class': 'bg-primary text-white',
|
'badge_class': 'bg-primary text-white',
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ class DocumentSequencingViewsTests(TestCase):
|
||||||
self.User = get_user_model()
|
self.User = get_user_model()
|
||||||
self.user = self.User.objects.create_user(username='admin_user', password='password')
|
self.user = self.User.objects.create_user(username='admin_user', password='password')
|
||||||
self.role_admin = Role.objects.create(name='admin')
|
self.role_admin = Role.objects.create(name='admin')
|
||||||
self.user_config = UserConfig.objects.create(user=self.user, is_intern=True)
|
self.user_config = UserConfig.objects.create(user=self.user, is_intern=True, preferred_language='fr')
|
||||||
self.user_config.roles.add(self.role_admin)
|
self.user_config.roles.add(self.role_admin)
|
||||||
|
|
||||||
self.thematic = Thematic.objects.create(code='road', name_fr='Route', name_nl='Weg')
|
self.thematic = Thematic.objects.create(code='road', name_fr='Route', name_nl='Weg')
|
||||||
|
|
@ -171,25 +171,48 @@ class DocumentSequencingViewsTests(TestCase):
|
||||||
InterventionDocument.objects.filter(id=doc2.id).update(upload_date=self.now - timedelta(hours=1))
|
InterventionDocument.objects.filter(id=doc2.id).update(upload_date=self.now - timedelta(hours=1))
|
||||||
|
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
|
self.client.cookies['django_language'] = 'fr'
|
||||||
|
|
||||||
def test_desktop_detail_view_contains_sequenced_blocks(self):
|
def test_desktop_detail_view_contains_sequenced_blocks(self):
|
||||||
url = reverse('interventions:intervention_detail', args=[self.intervention.id])
|
from django.utils import translation
|
||||||
response = self.client.get(url + '?force_desktop=1')
|
with translation.override('fr'):
|
||||||
self.assertEqual(response.status_code, 200)
|
url = reverse('interventions:intervention_detail', args=[self.intervention.id])
|
||||||
self.assertIn('document_blocks', response.context)
|
response = self.client.get(url + '?force_desktop=1')
|
||||||
self.assertEqual(response.context['total_documents_count'], 2)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertIn('document_blocks', response.context)
|
||||||
|
self.assertEqual(response.context['total_documents_count'], 2)
|
||||||
|
|
||||||
content = response.content.decode('utf-8')
|
import html
|
||||||
self.assertIn('Avant réalisation', content)
|
content = html.unescape(response.content.decode('utf-8'))
|
||||||
self.assertIn('Exécution du chantier', content)
|
self.assertIn('Avant réalisation', content)
|
||||||
|
self.assertIn("Exécution de l'intervention", content)
|
||||||
|
|
||||||
def test_mobile_detail_view_contains_sequenced_blocks(self):
|
def test_mobile_detail_view_contains_sequenced_blocks(self):
|
||||||
url = reverse('interventions:intervention_detail_mobile', args=[self.intervention.id])
|
from django.utils import translation
|
||||||
response = self.client.get(url)
|
with translation.override('fr'):
|
||||||
self.assertEqual(response.status_code, 200)
|
url = reverse('interventions:intervention_detail_mobile', args=[self.intervention.id])
|
||||||
self.assertIn('document_blocks', response.context)
|
response = self.client.get(url)
|
||||||
self.assertEqual(response.context['total_documents_count'], 2)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertIn('document_blocks', response.context)
|
||||||
|
self.assertEqual(response.context['total_documents_count'], 2)
|
||||||
|
|
||||||
content = response.content.decode('utf-8')
|
import html
|
||||||
self.assertIn('Avant réalisation', content)
|
content = html.unescape(response.content.decode('utf-8'))
|
||||||
self.assertIn('Exécution du chantier', content)
|
self.assertIn('Avant réalisation', content)
|
||||||
|
self.assertIn("Exécution de l'intervention", content)
|
||||||
|
|
||||||
|
def test_translations_nl_and_en(self):
|
||||||
|
from django.utils import translation
|
||||||
|
with translation.override('nl'):
|
||||||
|
res_nl = get_sequenced_intervention_documents(self.intervention)
|
||||||
|
titles_nl = [b['title'] for b in res_nl['blocks']]
|
||||||
|
self.assertIn('Vóór uitvoering', titles_nl)
|
||||||
|
self.assertIn('Uitvoering van de interventie', titles_nl)
|
||||||
|
self.assertIn('Na uitvoering', titles_nl)
|
||||||
|
|
||||||
|
with translation.override('en'):
|
||||||
|
res_en = get_sequenced_intervention_documents(self.intervention)
|
||||||
|
titles_en = [b['title'] for b in res_en['blocks']]
|
||||||
|
self.assertIn('Before realization', titles_en)
|
||||||
|
self.assertIn('Execution of the intervention', titles_en)
|
||||||
|
self.assertIn('After realization', titles_en)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue