Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 7
0
    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
Ejemplo n.º 8
0
    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
Ejemplo n.º 9
0
 def update_model(self, form, model):
     form.populate_obj(model)
     self.updated_models.append(model)
     return True