Ejemplo n.º 1
0
def createStory():
    content = request.get_json(silent=True)

    story = Story()
    story.storyName = content.get("storyName")
    story.intentName = content.get("intentName")
    story.speechResponse = content.get("speechResponse")

    if content.get("apiTrigger") is True:
        story.apiTrigger = True
        apiDetails = ApiDetails()
        isJson = content.get("apiDetails").get("isJson")
        apiDetails.isJson = isJson
        if isJson:
            apiDetails.jsonData = content.get("apiDetails").get("jsonData")

        apiDetails.url = content.get("apiDetails").get("url")
        apiDetails.requestType = content.get("apiDetails").get("requestType")
        story.apiDetails = apiDetails
    else:
        story.apiTrigger = False

    if content.get("parameters"):
        for param in content.get("parameters"):
            parameter = Parameter()
            update_document(parameter,param)
            story.parameters.append(parameter)
    try:
        story.save()
    except Exception as e:
        return buildResponse.buildJson({"error": str(e)})
    return buildResponse.sentOk()
Ejemplo n.º 2
0
def updateBot(botId):
    jsondata = loads(request.get_data())
    
    bot = Bot.objects.get(id=ObjectId(botId))
    bot = update_document(bot, jsondata)
    bot.save()
    return 'success', 200
Ejemplo n.º 3
0
def updateStory(storyId):
    print("Inside update story")
    jsondata = loads(request.get_data())
    story = Story.objects.get(id=ObjectId(storyId))
    story = update_document(story, jsondata)
    story.save()
    return 'success', 200
Ejemplo n.º 4
0
def updateStory(storyId):
    jsondata = loads(request.get_data())
    story = Story.objects.filter(id=ObjectId(storyId))
    if g.botId:
      story=story.filter(bot=g.botId)
    story = update_document(story.get(), jsondata)
    story.save()
    return 'success', 200
Ejemplo n.º 5
0
def createStory():
    content = request.get_json(silent=True)

    story = Story()
    story.storyName = content.get("storyName")
    story.intentName = content.get("intentName")
    story.speechResponse = content.get("speechResponse")

    if content.get("parameters"):
        for param in content.get("parameters"):
            parameter = Parameter()
            update_document(parameter,param)
            story.parameters.append(parameter)
    try:
        story.save()
    except Exception as e:
        return {"error": e}
    return buildResponse.sentOk()
Ejemplo n.º 6
0
def createStory():
    if (session.__getattribute__('loginstat') == 'login'):

        content = request.get_json(silent=True)

        story = Story()
        story.storyName = content.get("storyName")
        story.intentName = content.get("intentName")
        story.speechResponse = content.get("speechResponse")
        story.botId=content.get("botId")

        if content.get("apiTrigger") is True:
            story.apiTrigger = True
            apiDetails = ApiDetails()
            isJson = content.get("apiDetails").get("isJson")
            isHeader= content.get("apiDetails").get("isHeader")
            print("Is header",isHeader)
            apiDetails.isJson = isJson
            apiDetails.isHeader=isHeader
            if isJson:
                apiDetails.jsonData = content.get("apiDetails").get("jsonData")
            if isHeader:
                print("Is header data",content.get("apiDetails").get("headerData"))
                apiDetails.headerData = content.get("apiDetails").get("headerData")


            apiDetails.url = content.get("apiDetails").get("url")
            apiDetails.requestType = content.get("apiDetails").get("requestType")
            story.apiDetails = apiDetails
        else:
            story.apiTrigger = False

        if content.get("parameters"):
            for param in content.get("parameters"):
                parameter = Parameter()
                update_document(parameter, param)
                story.parameters.append(parameter)

        story.save()
        print("Story Saved")
        return buildResponse.sentOk()
    else:
        return render_template('index.html')
Ejemplo n.º 7
0
def updateStory(storyId):
    if (session.__getattribute__('loginstat') == 'login'):

        print("Inside update story")
        jsondata = loads(request.get_data())
        story = Story.objects.get(id=ObjectId(storyId))
        story = update_document(story, jsondata)
        story.save()
        return 'success', 200
    else:
        return render_template('index.html')
Ejemplo n.º 8
0
def updateStory(storyId):
    jsondata = loads(request.get_data())
    story = Story.objects.get(id=ObjectId(storyId))
    story = update_document(story,jsondata)
    story.save()
    return 'success', 200
Ejemplo n.º 9
0
def updateStory(storyId):
    jsondata = loads(request.get_data().decode('utf-8'))
    story = Story.objects.get(id=ObjectId(storyId))
    story = update_document(story, jsondata)
    story.save()
    return 'success', 200