def show_source_page(id): source = fetch_single_source(id) output = wtemplate('index', source=source, bibtex=cm.source_to_bibtex([source], include_abstract=False), title='%s' %source['citekey'], view='source') return output
def refetch_source_action(): query = unicode(request.POST.get('query', '').strip(),'utf_8') id = request.POST.get('id','').strip() source = populate_new_source_from_pubmed_query(query) source['id'] = id #Need if before we can generate citekey source['citekey'] = generate_citekey(source) source['nid'] = request.POST.get('nid', None)#We need the note id output = wtemplate('index', source=source, source_bibtex=cm.source_to_bibtex([source]), title='Editing %s' %source['citekey'], view='editsource') return output
def save_source_action(): source = get_empty_source() source_bibtex = request.POST.get('bibtex', None).decode("UTF-8") source = cm.parse_bibtex_to_source(source_bibtex, source=source) source['id'] = request.POST.get('id', None) save_source(source) #source = fetch_single_source(source['id']) #We need the note id source['nid'] = request.POST.get('nid', None)#We need the note id output = wtemplate('index', source=source, bibtex=cm.source_to_bibtex([source], include_abstract=False), title='Saved %s' %source['citekey'], view='source') return output
def show_source_page_citekey(citekey): source = fetch_single_source_by_citekey(citekey) if source is not None: title = '%s' %source['citekey'] output = wtemplate('index', source=source, bibtex=cm.source_to_bibtex([source], include_abstract=False), title=title, view='source') else: ntitle = citekey[:-4] + ' ' + citekey[-4:] output = wtemplate('index', title = "New entry", ntitle = ntitle, #sets up a title for the note ispaper = 'CHECKED', #Checks the "this is a paper" checkbox view='new', message='No such source in database. Create?') return output
def edit_source(id=None): source = dbq('SELECT sources.*,notes.id AS nid FROM sources,notes WHERE sources.id LIKE ? AND notes.source_id = sources.id', (id,))[0] output = wtemplate('index', source=source, source_bibtex=cm.source_to_bibtex([source]), title='Editing %s' %source['citekey'], view='editsource') return output