Closed nickovs closed 1 year ago
@greyli @PanderMusubi Any chance someone could approve the workflow, so that the build tests can run, and then look into merging this?
Only greyli has merge rights
Patch coverage has no change and project coverage change: +2.98
:tada:
Comparison is base (
9b066cb
) 97.01% compared to head (aa3dd43
) 100.00%.
:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Looks good! Can you add some tests for this fix?
@greyli I have added a variation of your test_render_table_with_actions()
test case to perform all the same tests but with no database and the data passed as a list of dict
s instead of Model
instances.
I updated tests to reuse the existing test function (https://github.com/helloflask/bootstrap-flask/pull/284/commits/1b850645ccff349e0ffc0706778c6bbbe33fcebb).
Merged, thanks!
This PR fixes issue #268 to allow table actions when the table data is not taken from SQLAlchemy.
Currently each action URLs is formed by looking up the row record in SQLAlchemy, using the row's primary key and the provided
model
class. Not only does this mean that the URL creation fails for records that are not taken from SQLAlchemy (or something with the same API) but it also means that there is an additional database fetch for every action on every row.The fix here makes the
model
parameter optional, even when actions are required. If no model is provided then any fields needed for building the URL are taken from the original row data. If a model class is provided then the functionality should be identical to before, complete with the extra database queries. This allows the record used to find URL arguments to be taken from a different model to that of the row data, as long as that table is indexed with the same primary key.fixes #268