def prevsamplelist(request, pagenum=1): api = MetPet("*****@*****.**", "24809ab2c593b544a491748094ed10d3cbffc699") user = "******" api_key = "24809ab2c593b544a491748094ed10d3cbffc699" if pagenum > 1: pagenum -= 20 data = api.getAllSamples(pagenum, user, api_key) else: data = api.getAllSamples() nextlist = data.data['meta']['next'] samplelist =[] offsets = [] total_count = data.data['meta']['total_count'] # print offset print dir(samplelist) for sample in data.data['objects']: print sample['sample_id'] samplelist.append([sample['sample_id'],sample['number']] ) #CREATE PAGINATION if total_count > 20: pages = total_count / 20 for x in range(0,pages): offsets.append(x*20) pagenum = int(nextlist.split('=')[-1]) pageprev = pagenum - 20 return render(request,'samplelist.html', {'samples':samplelist, 'nextURL': nextlist, 'total': total_count, 'offsets': offsets, 'pagenum':pagenum, 'pageprev': pageprev})
def previous(request, pagenum=1, optional=''): # cursor=con.cursor() # cursor.execute("SELECT DISTINCT sample_id, number FROM samples ORDER BY sample_id, number") # samplelist=cursor.fetchall() # for sample in samplelist: # print sample[1] pagenum = int(pagenum) - 40 api = MetPet("*****@*****.**", "24809ab2c593b544a491748094ed10d3cbffc699") user = "******" api_key = "24809ab2c593b544a491748094ed10d3cbffc699" if pagenum > 1: data = api.getAllSamples(pagenum, user, api_key) else: data = api.getAllSamples() nextlist = data.data['meta']['next'] samplelist =[] offsets = [] total_count = data.data['meta']['total_count'] # print offset print dir(samplelist) for sample in data.data['objects']: print sample['sample_id'] samplelist.append([sample['sample_id'],sample['number']] ) #CREATE PAGINATION if total_count > 20: pages = total_count / 20 for x in range(0,pages): offsets.append(x*20) pagenum = int(nextlist.split('=')[-1]) pageprev = pagenum - 20 return render(request,'samplelist.html', {'samples':samplelist, 'nextURL': nextlist, 'total': total_count, 'offsets': offsets, 'pagenum':pagenum, 'pageprev': pageprev})