コード例 #1
0
ファイル: view.py プロジェクト: PrimeFactor7/cubesviewer
    def create(self, request, *args, **kwargs):

        #tview = None
        if (int(request.POST["id"]) > 0):
            tview = CubesView.objects.get(pk = request.POST["id"])
            if (tview.owner_id != request.user.id):
                raise Exception("Cannot save View belonging to other users.")
        else:
            tview = CubesView()

        # Update or delete as necessary
        if (str(request.POST["data"]) == ""):
            tview.delete()
        else:
            tview.name = request.POST["name"]
            tview.data = request.POST["data"]
            tview.owner = request.user
            if (request.POST["shared"] == "true"):
                tview.shared = True
            else:
                tview.shared = False

            tview.save()


        return tview
コード例 #2
0
ファイル: view.py プロジェクト: Lardeva/ostrova
    def post(self, request, *args, **kwargs):

        #tview = None

        if (int(request.data["id"]) > 0):
            tview = CubesView.objects.get(pk = request.data["id"])
            if (tview.owner_id != request.user.id):
                raise Exception("Cannot save View belonging to other users.")
        else:
            tview = CubesView()

        # Update or delete as necessary
        if (request.data["data"] == u""):
            tview.delete()
        else:
            tview.name = request.data["name"]
            tview.data = request.data["data"]
            tview.owner = request.user
            if (request.data["shared"] == True):
                tview.shared = True
            else:
                tview.shared = False

            tview.save()

        serializer = CubesViewSerializer(tview, many=False, context={'request': request})
        return Response(serializer.data)
コード例 #3
0
ファイル: view.py プロジェクト: pombredanne/cubesviewer
    def create(self, request, *args, **kwargs):

        #tview = None
        if (int(request.POST["id"]) > 0):
            tview = CubesView.objects.get(pk = request.POST["id"])
            if (tview.owner_id != request.user.id):
                raise Exception("Cannot save View belonging to other users.")
        else:
            tview = CubesView()

        # Update or delete as necessary
        if (str(request.POST["data"]) == ""):
            tview.delete()
        else:
            tview.name = request.POST["name"]
            tview.data = request.POST["data"]
            tview.owner = request.user
            if (request.POST["shared"] == "true"):
                tview.shared = True
            else:
                tview.shared = False

            tview.save()


        return tview