def title(self): title = get_field(self, 'title', '') if self.code: title = '(' + self.code + ')' + title if not title: field = get_field(self, 'file', None) if field: title = splitext(field.filename)[0] return title
def get_files(self, field_name): files = [] for item in getattr(self.context, field_name): titles = {} if item.to_object: code = item.to_object.code title = get_field(item.to_object, 'title', '') description = get_field(item.to_object, 'description', '') languages = [] if not title: title = item.to_object.id _file = { 'code': code, 'title': title, 'description': description, 'uid': item.to_object.UID(), 'url': item.to_object.absolute_url(), } if item.to_object.en_file: languages.append('en') if item.to_object.es_file: languages.append('es') if item.to_object.fr_file: languages.append('fr') titles['en'] = titles['es'] = titles['fr'] = None if item.to_object.en_title: titles['en'] = item.to_object.en_title if item.to_object.es_title: titles['es'] = item.to_object.es_title if item.to_object.fr_title: titles['fr'] = item.to_object.fr_title _file['languages'] = languages _file['titles'] = titles files.append(_file) return files
def description(self): return get_field(self, 'description', '')
def title(self): return get_field(self, 'title', '')