Exemplo n.º 1
0
def ajax_delete_layer_row(request):
	layer_id = request.POST.get('layer_id')
	row_id = request.POST.get('row_id')
	
	layer = WorkspaceLayer.objects.get(pk=layer_id)
	table_columns = TableColumnDescriptor.objects.filter(table=layer.table)
	
	table_model = get_table_model(layer.table)
	row_obj = table_model.objects.get(pk=row_id)
	
	row_obj.delete();
	
	return HttpResponse('')
Exemplo n.º 2
0
def ajax_update_layer_row(request):
	layer_id = request.POST.get('layer_id')
	row_id = request.POST.get('row_id')
	
	layer = WorkspaceLayer.objects.get(pk=layer_id)
	table_columns = TableColumnDescriptor.objects.filter(table=layer.table)
	
	table_model = get_table_model(layer.table)
	row_obj = table_model.objects.get(pk=row_id)
	
	for column in table_columns:
		data = request.POST.get(str(column.id))
		setattr(row_obj, column.db_column_name, data)
	
	row_obj.save()
	
	return HttpResponse()
Exemplo n.º 3
0
def ajax_insert_layer_row(request):
	"""
	Note:
	Use column id as a key to data in request.POST
	"""
	layer_id = request.POST.get('layer_id')
	spatial_data = request.POST.get('spatial')
	
	layer = WorkspaceLayer.objects.get(pk=layer_id)
	table_columns = TableColumnDescriptor.objects.filter(table=layer.table)
	
	table_model = get_table_model(layer.table)
	row_obj = table_model()
	setattr(row_obj, settings.TABLE_SPATIAL_COLUMN_NAME, spatial_data)
	
	for column in table_columns:
		data = request.POST.get(str(column.id))
		setattr(row_obj, column.db_column_name, data)
	
	row_obj.save()
	
	return HttpResponse(row_obj.id)