def blocks_config(request, uuid):
  block_ref = Block.get(uuid=uuid)
  model = Block
  form_class = block_ref.get_block_form()
  form = form_class(instance=block_ref)
  if request.method == 'POST':
    form = form_class(request.POST, instance=block_ref)
    if form.is_valid():
      block_ref = form.save()
      util.success(request, "Config saved successfully")
      return http.HttpResponseRedirect(Block.admin_url())

  c = template.RequestContext(request, locals())
  return render_to_response('blocks_config.html', c)
def blocks_unpublish(request, uuid):
  block_ref = Block.get(uuid=uuid)
  block_ref.unpublish()
  return http.HttpResponseRedirect(Block.admin_url())
def blocks_edit(request, uuid):
  return content_edit(request, uuid, 'blocks', Block, BlockForm, tpl='blocks_edit.html', redirect_to=Block.admin_url())
def blocks_new(request):
  return content_new(request, 'blocks', BlockNewForm, redirect_to=Block.admin_url(), model=Block, tpl='blocks_new.html',)