def __light_attach_author(bibliography, author, role, position): d = { 'bibliography_author': author, 'bibliography_entry': bibliography, 'role': role, 'position': position } bar = BibliographyAuthorRole(**d) bar.save()
def attach_author_to_bibliography(entry): print(term.green("\tAttaching author {0} to bibliography {1}".format(entry.alauthorkey, entry.bibliographykey))) author = BibliographyAuthor.objects.get(pk=entry.alauthorkey) bibliography = Bibliography.objects.get(pk=entry.bibliographykey) role = __determine_person_role(entry) exists = BibliographyAuthorRole.objects.filter(bibliography_author=author, bibliography_entry=bibliography, role=role).exists() if exists: # Don't re-attach this record if it already exists. print(term.red("\t\tThis author relationship already exists. Bailing.")) return None d = { 'bibliography_author': author, 'bibliography_entry': bibliography, 'role': role, 'position': 1 # Authors listed here are assumed to be in first position... } bar = BibliographyAuthorRole(**d) bar.save()