示例#1
0
    def create_model(self, form):
        model = Model(self.last_id)
        self.last_id += 1

        form.populate_obj(model)
        self.created_models.append(model)
        self.all_models[model.id] = model

        return True
示例#2
0
    def update_model(self, form, model):
        try:
            form.populate_obj(model)
            self.on_model_change(form, model)
            model.save()

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)
        except Exception, ex:
            flash(gettext('Failed to update model. %(error)s', error=str(ex)), 'error')
            logging.exception('Failed to update model')
            return False
示例#3
0
    def create_model(self, form):
        try:
            model = self.model()
            form.populate_obj(model)
            model.save()

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)

            return True
        except Exception, ex:
            flash(gettext('Failed to create model. %(error)s', error=str(ex)), 'error')
            return False
示例#4
0
    def update_model(self, form, model):
        try:
            form.populate_obj(model)
            model.save()

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)

            self.on_model_change(form, model)

            return True
        except Exception, ex:
            flash(gettext("Failed to update model. %(error)s", error=str(ex)), "error")
            return False
示例#5
0
    def create_model(self, form):
        try:
            model = self.model()
            form.populate_obj(model)
            model.save()

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)

            return True
        except Exception, ex:
            flash(gettext('Failed to create model. %(error)s', error=str(ex)),
                  'error')
            return False
示例#6
0
    def update_model(self, form, model):
        print "---update_model called"
        try:
            form.populate_obj(model)
            print form.data
            # append set__ to all keys
            set_data = dict(map(lambda (key, value): ("set__"+str(key), value), form.data.items()))
            print set_data
            model.save(validate=False)

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)

            return True
        except Exception, ex:
            flash(gettext('Failed to update model. %(error)s', error=str(ex)), 'error')
            return False
示例#7
0
文件: view.py 项目: bvnp/flask-admin
    def create_model(self, form):
        try:
            model = self.model()
            form.populate_obj(model)
            self.on_model_change(form, model)
            model.save()

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)
        except Exception as ex:
            flash(gettext('Failed to create model. %(error)s', error=str(ex)), 'error')
            logging.exception('Failed to create model')
            return False
        else:
            self.after_model_change(form, model, True)

        return True
示例#8
0
文件: view.py 项目: ktmud/flask-admin
    def update_model(self, form, model):
        try:
            form.populate_obj(model)
            self._on_model_change(form, model, False)
            model.save()

            # For peewee have to save inline forms after model was saved
            save_inline(form, model)
        except Exception as ex:
            if self._debug:
                raise

            flash(gettext("Failed to update model. %(error)s", error=str(ex)), "error")
            logging.exception("Failed to update model")
            return False
        else:
            self.after_model_change(form, model, False)

        return True
示例#9
0
 def update_model(self, form, model):
     form.populate_obj(model)
     self.updated_models.append(model)
     return True