Skip to content

Commit

Permalink
glamr/tables: Fix checking if a table is meant for a export/download …
Browse files Browse the repository at this point in the history
…request
  • Loading branch information
robert102 committed Nov 22, 2024
1 parent 6cded67 commit 4c824e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 4 additions & 4 deletions mibios/glamr/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def is_for_export(self):
Use this method to branch into optimized code for paginated HTML vs.
whole dataset export.
"""
try:
return self.view.export_check() is not None
except Exception:
# not a view with ExportMixin
if hasattr(self.view, 'check_export_request'):
# View is ExportMixin
return self.view.check_export_request()
else:
return False

def get_extra_excludes(self):
Expand Down
6 changes: 1 addition & 5 deletions mibios/glamr/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ def get_format(self, fmt_name='tab'):
def get_export_queryset(self, export_option):
"""
Get the queryset corresponding to given export option.
The returned queryset needs to have all filters applied so it's
accurate when exist() is run on it, but is not expected to have
table-specific columns or annotations set yet.
"""
if export_option is self.EXPORT_TABLE:
return self.get_queryset()
Expand Down Expand Up @@ -240,7 +236,7 @@ def get_export_table(self):
except (AttributeError, KeyError):
# other views or model not listed
tab_cls = table_factory(qs.model, table=tables.Table)
return tab_cls(data=qs)
return tab_cls(data=qs, view=self)

def get_values(self):
"""
Expand Down

0 comments on commit 4c824e1

Please sign in to comment.