-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate table class definition and instantiation in MultiTableMixin #876 #885
Open
gb119
wants to merge
14
commits into
jieter:master
Choose a base branch
from
gb119:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9a6fef7
Modify MultiTableMixin api to be a bit more like SingleTableMixin wit…
gb119 42fe084
Tweak sourfce formatting to get actions to run
gb119 43323e8
Remove MultiTableMixin models attribute - not allowing tests to work.…
gb119 6459dd1
Reapply MultiTableMixin.get_tables_calsses
gb119 e071075
MultTable.get_tables_classes() tweaking
gb119 6aa6dbd
Update test with correct exception message
gb119 6824551
Missed f string change
gb119 1ae9a63
Add tables data to get_tables_classes test
gb119 bd51a8e
Merge branch 'master' of github.com:gb119/django-tables2
gb119 7907edb
Run tests through black
gb119 8873e7a
Remove long line in views.py
gb119 60fff48
Resync to remote/HEAD and reapply the get_tables_classes() change wit…
gb119 72292f2
Merge branch 'master' of github.com:gb119/django-tables2
gb119 09c7c72
Fix misnamed test
gb119 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -411,15 +411,42 @@ def test_without_tables(self): | |||||
class View(tables.MultiTableMixin, TemplateView): | ||||||
template_name = "multiple.html" | ||||||
|
||||||
message = "No tables were specified. Define View.tables" | ||||||
message = "You must either specify View.tables or override View.get_tables_classes()" | ||||||
with self.assertRaisesMessage(ImproperlyConfigured, message): | ||||||
View.as_view()(build_request("/")) | ||||||
|
||||||
def test_get_tables_classes_list(self): | ||||||
class View(tables.MultiTableMixin, TemplateView): | ||||||
tables_data = (Person.objects.all(), Region.objects.all()) | ||||||
template_name = "multiple.html" | ||||||
|
||||||
def get_tables_classes(self): | ||||||
return [TableA, TableB] | ||||||
|
||||||
response = View.as_view()(build_request("/")) | ||||||
response.render() | ||||||
|
||||||
html = response.rendered_content | ||||||
self.assertEqual(html.count("<table >"), 2) | ||||||
|
||||||
def test_with_empty_get_tables_list(self): | ||||||
class View(tables.MultiTableMixin, TemplateView): | ||||||
template_name = "multiple.html" | ||||||
|
||||||
def get_tables(self): | ||||||
def get_tables(self, **kwargs): | ||||||
return [] | ||||||
|
||||||
response = View.as_view()(build_request("/")) | ||||||
response.render() | ||||||
|
||||||
html = response.rendered_content | ||||||
self.assertIn("<h1>Multiple tables using MultiTableMixin</h1>", html) | ||||||
|
||||||
def test_with_empty_get_tables_clases_list(self): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
class View(tables.MultiTableMixin, TemplateView): | ||||||
template_name = "multiple.html" | ||||||
|
||||||
def get_tables_classes(self): | ||||||
return [] | ||||||
|
||||||
response = View.as_view()(build_request("/")) | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would one specify the
kwargs
passed through here?