def table(request, repo_base, repo, table): ''' return a page indicating how many ''' current_page = 1 if request.POST.get('page'): current_page = request.POST.get('page') username = request.user.get_username() url_path = reverse('browser-table', args=(repo_base, repo, table)) manager = DataHubManager(user=username, repo_base=repo_base) query = manager.select_table_query(repo, table) res = manager.paginate_query(query=query, current_page=current_page, rows_per_page=50) # get annotation to the table: annotation, created = Annotation.objects.get_or_create(url_path=url_path) annotation_text = annotation.annotation_text data = { 'login': username, 'repo_base': repo_base, 'repo': repo, 'table': table, 'annotation': annotation_text, 'current_page': current_page, 'next_page': current_page + 1, # the template should relaly do this 'prev_page': current_page - 1, # the template should relaly do this 'url_path': url_path, 'column_names': res['column_names'], 'tuples': res['rows'], 'total_pages': res['total_pages'], 'pages': range(res['start_page'], res['end_page'] + 1), # template 'num_rows': res['num_rows'], 'time_cost': res['time_cost'] } data.update(csrf(request)) # and then, after everything, hand this off to table-browse. It turns out # that this is all using DataTables anyhow, so the template doesn't really # use all of the data we prepared. ARC 2016-01-04 return render_to_response("table-browse.html", data)
def table(request, repo_base, repo, table): ''' return a page indicating how many ''' current_page = 1 if request.POST.get('page'): current_page = request.POST.get('page') username = request.user.get_username() url_path = reverse('browser-table', args=(repo_base, repo, table)) manager = DataHubManager(user=username, repo_base=repo_base) query = manager.select_table_query(repo, table) res = manager.paginate_query( query=query, current_page=current_page, rows_per_page=50) # get annotation to the table: annotation, created = Annotation.objects.get_or_create(url_path=url_path) annotation_text = annotation.annotation_text data = { 'login': username, 'repo_base': repo_base, 'repo': repo, 'table': table, 'annotation': annotation_text, 'current_page': current_page, 'next_page': current_page + 1, # the template should relaly do this 'prev_page': current_page - 1, # the template should relaly do this 'url_path': url_path, 'column_names': res['column_names'], 'tuples': res['rows'], 'total_pages': res['total_pages'], 'pages': range(res['start_page'], res['end_page'] + 1), # template 'num_rows': res['num_rows'], 'time_cost': res['time_cost'] } data.update(csrf(request)) # and then, after everything, hand this off to table-browse. It turns out # that this is all using DataTables anyhow, so the template doesn't really # use all of the data we prepared. ARC 2016-01-04 return render_to_response("table-browse.html", data)