Ejemplo n.º 1
0
def create_recommendations(recommendation_id):
    """ Create Recommendation View """
    data = request.get_json()
    rec = Recommendation()
    rec.deserialize(data)
    rec.save()
    message = rec.serialize()

    return render_template('manage.html', name="Manage",
                           result=message), status.HTTP_201_CREATED
Ejemplo n.º 2
0
    def post(self):
        """ Creates a Recommendation

        This endpoint will create a Recommendations based the data in the body that is posted.
        We assume when a user ask for a recommendation they will provide a Product Id
        And a Type in the following format:
            { 'product_id': <int>, 'type': '<[up-sell|accessory|cross-sell]>' }
        """

        #data = request.get_json()
        rec = Recommendation()
        rec.deserialize(api.payload)
        rec.save()

        location_url = api.url_for(RecommendationResource,
                                   recommendation_id=rec.id,
                                   _external=True)

        return rec.serialize(), status.HTTP_201_CREATED, {
            'Location': location_url
        }