Esempio n. 1
0
def getRelatedPaper(request):
    try:
        data = json.loads(request.body)
        try:
            token = Token.objects.filter(token=data['token']).first()
            user = token.user
        except:
            raise myError('Please Log In.')
        gene_name = data['gene_name']
        related_paper_list = search_papers(gene_name)
        result = {
            'successful': True,
            'data': related_paper_list,
            'error': {
                'id': '',
                'msg': '',
            },
        }
    except myError, e:
        result = {
            'successful': False,
            'error': {
                'id': '3',
                'msg': e.value,
            }
        }
Esempio n. 2
0
def getRelatedPaper(request):
	try:
		data = json.loads(request.body)
		try:
			token = Token.objects.filter(token=data['token']).first()
			user = token.user
		except:
			raise myError('Please Log In.')
		gene_name = data['gene_name']
		related_paper_list = search_papers(gene_name)
		result = {
			'successful': True,
			'data': related_paper_list,
			'error': {
				'id': '',
				'msg': '',
			},
		}
	except myError, e:
		result = {
			'successful': False,
			'error': {
				'id': '3',
				'msg': e.value,
			}
		}
Esempio n. 3
0
	def test_search_papers(self):
		search_result = search_papers('test')
		self.assertEqual(search_result, [])