dpgaspar / Flask-AppBuilder

Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/
BSD 3-Clause "New" or "Revised" License
4.7k stars 1.36k forks source link

actions on child/related views (multiple childs exist) not working properly #2181

Open schrecksim opened 10 months ago

schrecksim commented 10 months ago

Environment

Flask-Appbuilder version: 4.3.9

pip freeze output:

Describe the expected results

Actions on child list views should be handled correctly, when all records are selected, and only update its records. In addition, it should not only work on the first child view hats displayed but also the second and so on.

@action('set_ready', 'status ready', single=False)
    def set_ready(self, items):
        """
        set selected records status to 'ready'
        """
        for item in items:
            try:
                item.status = 'ready'
                self.datamodel.edit(item)
                self.update_redirect()
            except:
                pass
        return redirect(self.get_redirect())

The try addition in the code fixes the problem that if I'm selecting all records on the first related view, the records on the second view get selected as well. This causes an error in the application.

Describe the actual results

The records of the first related view get updated as expected when selecting all records. If I'm selecting all records of the second child and execute the action, the records of the first child get updated, but the ones of the second don't change.

Steps to reproduce

  1. Have a main view, with several child views
  2. select all records with the check bock on top
  3. execute the action to modify those records
ThomasP0815 commented 10 months ago

I think this problem is related to issue #1302

schrecksim commented 10 months ago

Thanks, I'll take a look on the possible solution provided and keep you up to date.