def get_contacts(education_group_year, language_code): contacts = business.get_contacts_group_by_types(education_group_year, language_code) intro_content = business.get_contacts_intro_text(education_group_year, language_code) entity_version = education_group_year.publication_contact_entity_version return { 'id': business.CONTACTS_KEY, 'label': business.CONTACTS_KEY, 'content': { 'text': intro_content, 'entity': entity_version.acronym if entity_version else None, 'contacts': contacts } }
def test_get_contacts_intro_text_case_english_version(self): intro_text = business.get_contacts_intro_text(self.education_group_year, settings.LANGUAGE_CODE_EN) self.assertEqual(intro_text, self.contact_intro_en.text)
def test_get_contacts_intro_text_case_no_value(self): education_group_year = EducationGroupYearFactory() self.assertIsNone(business.get_contacts_intro_text(education_group_year, settings.LANGUAGE_CODE_FR))
def get_text(self, obj): text = get_contacts_intro_text(obj, self.context.get('lang')) return text if text else None