dialog after editing paper

main
Fabien C. Y. Benureau 7 years ago
parent 1b59aefc08
commit 4b1717b7fd
No known key found for this signature in database
GPG Key ID: C3FB5E831A249A9A

@ -54,10 +54,17 @@ def command(conf, args):
new_paper = Paper(paper.citekey, paper.bibdata,
metadata=content)
rp.push_paper(new_paper, overwrite=True, event=False)
ui.info(('The metadata of paper `{}` was successfully '
'edited.'.format(citekey)))
else:
new_paper = Paper.from_bibentry(content,
metadata=paper.metadata)
rp.rename_paper(new_paper, old_citekey=paper.citekey)
if rp.rename_paper(new_paper, old_citekey=paper.citekey):
ui.info(('Paper `{}` was successfully edited and renamed '
'as `{}`.'.format(citekey, new_paper.citekey)))
else:
ui.info(('Paper `{}` was successfully edited.'.format(
citekey)))
break
except repo.CiteKeyCollision:
@ -71,6 +78,7 @@ def command(conf, args):
break
elif choice == 'overwrite':
paper = rp.push_paper(paper, overwrite=True)
ui.info(('Paper `{}` was overwritten.'.format(citekey)))
break
# else edit again
# Also handle malformed bibtex and metadata

@ -141,6 +141,13 @@ class Repository(object):
pass
def rename_paper(self, paper, new_citekey=None, old_citekey=None):
"""Move a paper from a citekey to another one.
Even if the new and old citekey are the same, the paper instance is
pushed to disk.
:return: True if a rename happened, False if not.
"""
if old_citekey is None:
old_citekey = paper.citekey
if new_citekey is None:
@ -149,6 +156,7 @@ class Repository(object):
# check if new_citekey is not the same as paper.citekey
if old_citekey == new_citekey:
self.push_paper(paper, overwrite=True, event=False)
return False
else:
# check if new_citekey does not exists
if new_citekey in self:
@ -171,6 +179,7 @@ class Repository(object):
self.remove_paper(old_citekey, event=False)
# send event
events.RenameEvent(paper, old_citekey).send()
return True
def push_doc(self, citekey, docfile, copy=None):
p = self.pull_paper(citekey)

Loading…
Cancel
Save