示例#1
0
def card(request, cardid):
    if request.method == 'POST':
        data = JSONDeserializer().deserialize(request.body)
        if data:
            card = Card(data)
            card.save()
            return JSONResponse(card)
            
    if request.method == 'GET':
        try:
            card = Card.objects.get(cardid=cardid)
        except(Card.DoesNotExist):
            # assume this is a graph id
            card = Card.objects.get(cardid=Graph.objects.get(graphid=cardid).get_root_card().cardid)
        datatypes = models.DDataType.objects.all()
        widgets = models.Widget.objects.all()
        return render(request, 'views/graph/card-configuration.htm', {
            'main_script': 'views/graph/card-configuration',
            'graphid': card.graph_id,
            'graphs': JSONSerializer().serialize(models.GraphModel.objects.all()),
            'card': JSONSerializer().serialize(card),
            'datatypes': JSONSerializer().serialize(datatypes),
            'widgets': widgets,
            'widgets_json': JSONSerializer().serialize(widgets),
        })

    return HttpResponseNotFound()
示例#2
0
文件: graph.py 项目: mrcnc/arches
    def post(self, request, cardid):
        data = JSONDeserializer().deserialize(request.body)
        if data:
            card = Card(data)
            card.save()
            return JSONResponse(card)

        return HttpResponseNotFound()
示例#3
0
文件: graph.py 项目: fargeo/arches
    def post(self, request, cardid):
        data = JSONDeserializer().deserialize(request.body)
        if data:
            card = Card(data)
            card.save()
            return JSONResponse(card)

        return HttpResponseNotFound()
示例#4
0
    def post(self, request, cardid=None):
        data = JSONDeserializer().deserialize(request.body)
        if self.action == "update_card":
            if data:
                card = Card(data)
                card.save()
                return JSONResponse(card)

        if self.action == "reorder_cards":
            if "cards" in data and len(data["cards"]) > 0:
                with transaction.atomic():
                    for card_data in data["cards"]:
                        card = models.CardModel.objects.get(pk=card_data["id"])
                        card.sortorder = card_data["sortorder"]
                        card.save()
                return JSONResponse(data["cards"])

        return HttpResponseNotFound()