def delete_share(request):
  
  return_dict = {}
  try:
    if request.method == "GET":
      #Return the conf page
      share_id = request.GET["share_id"]
      name = request.GET["name"]
      return_dict["share_id"] = share_id
      return_dict["name"] = name
      return django.shortcuts.render_to_response("delete_share_conf.html", return_dict, context_instance = django.template.context.RequestContext(request))
    else:
      share_id = request.POST["share_id"]
      name = request.POST["name"]
      #logger.debug("Delete share request for name %s"%name)
      try :
        samba_settings.delete_share(share_id)
        samba_settings.generate_smb_conf()
      except Exception, e:
        return_dict["error"] = "Error deleting share - %s" %e
        return django.shortcuts.render_to_response('logged_in_error.html', return_dict, context_instance=django.template.context.RequestContext(request))
  
      audit_str = "Deleted Samba share %s"%name
      audit.audit("delete_share", audit_str, request.META["REMOTE_ADDR"])
      return django.http.HttpResponseRedirect('/display_shares?action=deleted')
  except Exception, e:
    s = str(e)
    if "Another transaction is in progress".lower() in s.lower():
      return_dict["error"] = "An underlying storage operation has locked a volume so we are unable to process this request. Please try after a couple of seconds"
    else:
      return_dict["error"] = "An error occurred when processing your request : %s"%s
    return django.shortcuts.render_to_response("logged_in_error.html", return_dict, context_instance=django.template.context.RequestContext(request))
def delete_share(request):

    return_dict = {}
    try:
        if request.method == "GET":
            #Return the conf page
            share_id = request.GET["share_id"]
            name = request.GET["name"]
            return_dict["share_id"] = share_id
            return_dict["name"] = name
            return django.shortcuts.render_to_response(
                "delete_share_conf.html",
                return_dict,
                context_instance=django.template.context.RequestContext(
                    request))
        else:
            share_id = request.POST["share_id"]
            name = request.POST["name"]
            #logger.debug("Delete share request for name %s"%name)
            try:
                samba_settings.delete_share(share_id)
                samba_settings.generate_smb_conf()
            except Exception, e:
                return_dict["error"] = "Error deleting share - %s" % e
                return django.shortcuts.render_to_response(
                    'logged_in_error.html',
                    return_dict,
                    context_instance=django.template.context.RequestContext(
                        request))

            audit_str = "Deleted Samba share %s" % name
            audit.audit("delete_share", audit_str, request.META["REMOTE_ADDR"])
            return django.http.HttpResponseRedirect(
                '/display_shares?action=deleted')
    except Exception, e:
        s = str(e)
        if "Another transaction is in progress".lower() in s.lower():
            return_dict[
                "error"] = "An underlying storage operation has locked a volume so we are unable to process this request. Please try after a couple of seconds"
        else:
            return_dict[
                "error"] = "An error occurred when processing your request : %s" % s
        return django.shortcuts.render_to_response(
            "logged_in_error.html",
            return_dict,
            context_instance=django.template.context.RequestContext(request))
def delete_share(request):

    return_dict = {}
    try:
        if request.method == "GET":
            # Return the conf page
            share_id = request.GET["share_id"]
            name = request.GET["name"]
            return_dict["share_id"] = share_id
            return_dict["name"] = name
            return django.shortcuts.render_to_response(
                "delete_share_conf.html", return_dict, context_instance=django.template.context.RequestContext(request)
            )
        else:
            share_id = request.POST["share_id"]
            name = request.POST["name"]
            # logger.debug("Delete share request for name %s"%name)
            try:
                samba_settings.delete_share(share_id)
                samba_settings.generate_smb_conf()
            except Exception, e:
                return_dict["error"] = "Error deleting share - %s" % e
                return django.shortcuts.render_to_response(
                    "logged_in_error.html",
                    return_dict,
                    context_instance=django.template.context.RequestContext(request),
                )

            audit_str = "Deleted CIFS share %s" % name
            audit.audit("delete_share", audit_str, request.META["REMOTE_ADDR"])
            return django.http.HttpResponseRedirect("/display_shares?action=deleted")
    except Exception, e:
        s = str(e)
        return_dict["error"] = "An error occurred when processing your request : %s" % s
        return django.shortcuts.render_to_response(
            "logged_in_error.html", return_dict, context_instance=django.template.context.RequestContext(request)
        )