當前位置: 首頁>>代碼示例>>Python>>正文


Python Manifest.delete方法代碼示例

本文整理匯總了Python中models.Manifest.delete方法的典型用法代碼示例。如果您正苦於以下問題:Python Manifest.delete方法的具體用法?Python Manifest.delete怎麽用?Python Manifest.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Manifest的用法示例。


在下文中一共展示了Manifest.delete方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: delete

# 需要導入模塊: from models import Manifest [as 別名]
# 或者: from models.Manifest import delete [as 別名]
def delete(request, manifest_name=None):
    if request.method == 'POST':
        Manifest.delete(manifest_name, request.user)
        return HttpResponseRedirect('/manifest/')
    else:
        c = RequestContext(request, {'manifest_name': manifest_name})
        c.update(csrf(request))
        return render_to_response('manifests/delete.html', c)
開發者ID:grahampugh,項目名稱:munki-do,代碼行數:10,代碼來源:views.py

示例2: detail

# 需要導入模塊: from models import Manifest [as 別名]
# 或者: from models.Manifest import delete [as 別名]
def detail(request, manifest_path):
    if request.method == 'GET':
        print "Got read request for %s" % manifest_path
        manifest = Manifest.read(manifest_path)
        #autocomplete_data = Manifest.getAutoCompleteData(manifest_path)
        if manifest is None:
            raise Http404("%s does not exist" % manifest_path)
        c = {'plist_text': manifest,
             'pathname': manifest_path}
        return render(request, 'manifests/detail.html', context=c)
    if request.method == 'POST':
        # could be PUT, POST, or DELETE
        if request.META.has_key('HTTP_X_METHODOVERRIDE'):
            http_method = request.META['HTTP_X_METHODOVERRIDE']
            if http_method.lower() == 'delete':
                print "Got delete request for %s" % manifest_path
                if not request.user.has_perm('manifest.delete_manifestfile'):
                    raise PermissionDenied
                Manifest.delete(manifest_path, request.user)
                return HttpResponse(
                    json.dumps('success'), content_type='application/json')
            elif http_method.lower() == 'put':
                # regular POST (update/change)
                print "Got write request for %s" % manifest_path
                if not request.user.has_perm('manifest.change_manifestfile'):
                    raise PermissionDenied
                if request.is_ajax():
                    json_data = json.loads(request.body)
                    if json_data and 'plist_data' in json_data:
                        plist_data = json_data['plist_data'].encode('utf-8')
                        Manifest.write(
                            json_data['plist_data'], manifest_path,
                            request.user)
                        return HttpResponse(
                            json.dumps('success'),
                            content_type='application/json')
            else:
                print "Got unknown HTTP_X_METHODOVERRIDE for %s: %s" % (
                    manifest_path, http_method)
        else:
            # true POST request; create new resource
            print "Got create request for %s" % manifest_path
            try:
                json_data = json.loads(request.body)
            except ValueError:
                json_data = None
            if json_data and 'plist_data' in json_data:
                plist_data = json_data['plist_data'].encode('utf-8')
                Manifest.write(
                    json_data['plist_data'], manifest_path,
                    request.user)
            else:
                plist_data = Manifest.new(manifest_path, request.user)
            c = {'plist_text': plist_data,
                 'pathname': manifest_path,}
            return render(request, 'manifests/detail.html', context=c)
開發者ID:wollardj,項目名稱:mwa2,代碼行數:58,代碼來源:views.py

示例3: delete

# 需要導入模塊: from models import Manifest [as 別名]
# 或者: from models.Manifest import delete [as 別名]
def delete(request, manifest_name=None):
    if not request.user.has_perm('reports.delete_machine'):
        return HttpResponse(json.dumps('error'))
    if request.method == 'POST':
        Manifest.delete(manifest_name, request.user)
        return HttpResponseRedirect('/manifest/')
    else:
        c = RequestContext(request, {'manifest_name': manifest_name})
        c.update(csrf(request))
        return render_to_response('manifests/delete.html', c)
開發者ID:brianmickelson,項目名稱:munkiwebadmin,代碼行數:12,代碼來源:views.py

示例4: delete

# 需要導入模塊: from models import Manifest [as 別名]
# 或者: from models.Manifest import delete [as 別名]
def delete(request, manifest_name=None):
    if not request.user.has_perm("reports.delete_machine"):
        return HttpResponse(json.dumps("error"))
    if request.method == "POST":
        Manifest.delete(manifest_name, request.user)
        return HttpResponseRedirect("/%smanifest/" % SUB_PATH)
    else:
        c = RequestContext(request, {"manifest_name": manifest_name})
        c.update(csrf(request))
        return render_to_response("manifests/delete.html", c)
開發者ID:eahrold,項目名稱:munkiwebadmin,代碼行數:12,代碼來源:views.py


注:本文中的models.Manifest.delete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。