def clear_boa_cache(event): """Delete the cached book of abstract""" path = boa_settings.get(event, 'cache_path') if path: try: os.remove(os.path.join(Config.getInstance().getXMLCacheDir(), path)) except OSError as e: if e.errno != errno.ENOENT: raise boa_settings.delete(event, 'cache_path')
def clear_boa_cache(event): """Delete the cached book of abstract""" path = boa_settings.get(event, 'cache_path') if path: try: os.remove(os.path.join(config.CACHE_DIR, path)) except OSError as e: if e.errno != errno.ENOENT: raise boa_settings.delete(event, 'cache_path')
def create_boa(event): """Create the book of abstracts if necessary :return: The path to the PDF file """ path = boa_settings.get(event, 'cache_path') if path and os.path.exists(path): return path pdf = AbstractBook(event) tmp_path = pdf.generate() path = os.path.join(Config.getInstance().getXMLCacheDir(), 'boa-{}.pdf'.format(event.id)) shutil.move(tmp_path, path) boa_settings.set(event, 'cache_path', path) return path
def __init__(self, event, user, contribs=None, tz=None, sort_by=""): super(ContributionBook, self).__init__() tz = tz or event.timezone contribs = self._sort_contribs(contribs or event.contributions, sort_by) affiliation_contribs = {} corresp_authors = {} for contrib in contribs: affiliations, author_mapping, coauthor_mapping = extract_affiliations(contrib) affiliation_contribs[contrib.id] = { 'affiliations': affiliations, 'authors_affil': author_mapping, 'coauthors_affil': coauthor_mapping } # figure out "corresponding author(s)" if boa_settings.get(event, 'corresponding_author') == BOACorrespondingAuthorType.submitter: corresp_authors[contrib.id] = [pl.person.email for pl in contrib.person_links if pl.is_submitter] if boa_settings.get(event, 'corresponding_author') == BOACorrespondingAuthorType.speakers: corresp_authors[contrib.id] = [speaker.person.email for speaker in contrib.speakers] self._args.update({ 'affiliation_contribs': affiliation_contribs, 'corresp_authors': corresp_authors, 'contribs': contribs, 'event': event, 'tz': timezone(tz or event.timezone), 'url': event.url, 'fields': [f for f in event.contribution_fields if f.is_active], 'sorted_by': sort_by, 'user': user, 'boa_text': boa_settings.get(event, 'extra_text') }) self._args['logo_img'] = create_event_logo_tmp_file(event).name if event.logo else None
def create_boa(event): """Create the book of abstracts if necessary :return: The path to the PDF file """ path = boa_settings.get(event, 'cache_path') if path: path = os.path.join(config.CACHE_DIR, path) if os.path.exists(path): # update file mtime so it's not deleted during cache cleanup os.utime(path, None) return path pdf = AbstractBook(event) tmp_path = pdf.generate() filename = 'boa-{}.pdf'.format(event.id) full_path = os.path.join(config.CACHE_DIR, filename) shutil.move(tmp_path, full_path) boa_settings.set(event, 'cache_path', filename) return full_path
def clear_boa_cache(event): """Delete the cached book of abstract""" path = boa_settings.get(event, 'cache_path') if path: os.remove(path) boa_settings.delete(event, 'cache_path')
def __init__(self, event, tz=None): sort_by = boa_settings.get(event, 'sort_by') super(AbstractBook, self).__init__(event, None, sort_by=sort_by) self._args['show_ids'] = boa_settings.get(event, 'show_abstract_ids') self._args['url'] = None