Ejemplo n.º 1
0
def detail(request, pkginfo_path):
    if request.method == 'GET':
        print "Got read request for %s" % pkginfo_path
        pkginfo = Pkginfo.read(pkginfo_path)
        if pkginfo is None:
            raise Http404("%s does not exist" % pkginfo_path)
        c = {'plist_text': pkginfo, 'pathname': pkginfo_path}
        return render(request, 'pkgsinfo/detail.html', context=c)
    if request.method == 'POST':
        # 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" % pkginfo_path
                if not request.user.has_perm('pkgsinfo.delete_pkginfofile'):
                    raise PermissionDenied
                json_data = json.loads(request.body)
                Pkginfo.delete(pkginfo_path,
                               request.user,
                               delete_pkg=json_data.get('deletePkg', False))
                return HttpResponse(json.dumps('success'),
                                    content_type='application/json')
        # regular POST (update/change)
        print "Got write request for %s" % pkginfo_path
        if not request.user.has_perm('pkgsinfo.change_pkginfofile'):
            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')
                Pkginfo.write(json_data['plist_data'], pkginfo_path,
                              request.user)
                return HttpResponse(json.dumps('success'),
                                    content_type='application/json')
Ejemplo n.º 2
0
def list(request):
    print "Got list request for pkgsinfo"
    pkgsinfo = Pkginfo.list()
    c = {
        'pkgsinfo': pkgsinfo,
    }
    return render(request, 'pkgsinfo/list.html', context=c)
Ejemplo n.º 3
0
def detail(request, pkginfo_path):
    if request.method == 'GET':
        print "Got read request for %s" % pkginfo_path
        pkginfo = Pkginfo.read(pkginfo_path)
        if pkginfo is None:
            raise Http404("%s does not exist" % pkginfo_path)
        c = {'plist_text': pkginfo,
             'pathname': pkginfo_path}
        return render(request, 'pkgsinfo/detail.html', context=c)
    if request.method == 'POST':
        # 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" % pkginfo_path
                if not request.user.has_perm('pkgsinfo.delete_pkginfofile'):
                    raise PermissionDenied
                json_data = json.loads(request.body)
                Pkginfo.delete(
                    pkginfo_path, request.user,
                    delete_pkg=json_data.get('deletePkg', False)
                )
                return HttpResponse(
                    json.dumps('success'), content_type='application/json')
        # regular POST (update/change)
        print "Got write request for %s" % pkginfo_path
        if not request.user.has_perm('pkgsinfo.change_pkginfofile'):
            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')
                Pkginfo.write(
                    json_data['plist_data'], pkginfo_path, request.user)
                return HttpResponse(
                    json.dumps('success'), content_type='application/json')
Ejemplo n.º 4
0
def list(request):
    print "Got list request for pkgsinfo"
    pkgsinfo = Pkginfo.list()
    c = {'pkgsinfo': pkgsinfo,} 
    return render(request, 'pkgsinfo/list.html', context=c)
Ejemplo n.º 5
0
def getjson(request):
    print "Got json request for pkgsinfo"
    pkginfo_list = Pkginfo.list()
    # send it back in JSON format
    return HttpResponse(json.dumps(pkginfo_list),
                        content_type='application/json')
Ejemplo n.º 6
0
def getjson(request):
    print "Got json request for pkgsinfo"
    pkginfo_list = Pkginfo.list()
    # send it back in JSON format
    return HttpResponse(json.dumps(pkginfo_list),
                        content_type='application/json')