Esempio n. 1
0
    def delete(self, name):
        store = StoreModel.find_by_name(name)

        if store:
            store.delete_from_db()

        return {'message': 'store deleted'}
Esempio n. 2
0
    def get(self, name):
        """

        :param name:
        :return:
        """
        store = StoreModel.find_by_name(name)
        if store:
            return store.json()
        return {'message': 'Store not found'}, 404
Esempio n. 3
0
    def post(self, name):
        if StoreModel.find_by_name(name):
            return {
                'message': 'The store with name {} already exists'.format(name)
            }, 400
        store = StoreModel(name)
        try:
            store.save_to_db()
        except:
            return {'message': 'Internal server error creating store'}, 500

        return store.json(), 200
Esempio n. 4
0
    def post(self, name):
        if StoreModel.find_by_name(name):
            return {
                'message':
                "A store with name '{}' already exists.".format(name)
            }, 400
        store = StoreModel(name)

        try:
            store.save_to_db()
        except:
            {'message': 'An error occured while creating the store.'}, 500

        return store.json(), 201
Esempio n. 5
0
def create_model():
    if request.method == "POST":
        name = request.form['name']
        if StoreModel.find_by_name(name):
            return "Model already exists with name. Try another name"

        store = StoreModel(name=name, username=session['username'])
        try:
            store.save_to_db()
        except:
            return "Error creating model"

        return redirect(url_for(".index"))

    return render_template("models/new_model.html")
 def post(self, name):
     if StoreModel.find_by_name(name):
         return {"message": "store already exists"}
     store = StoreModel(name)
     store.save_to_db()
     return store.json()
 def get(self, name):
     return StoreModel.find_by_name(name)
Esempio n. 8
0
 def get(self, name):
     store = StoreModel.find_by_name(name)
     return store.json() if store else {'message': 'Store not found'}, 404