Skip to content

Commit

Permalink
Change multiple method in mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
danjac committed Sep 6, 2021
1 parent 5411516 commit bfcc066
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/turbo_response/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
class TurboStreamMixin:
turbo_stream_action: Optional[Action] = None
turbo_stream_target: Optional[str] = None
is_multiple: bool = False
turbo_stream_multiple: bool = False

def is_turbo_stream_targets(self) -> bool:
return self.is_multiple
def is_turbo_stream_multiple(self) -> bool:
return self.turbo_stream_multiple

def get_turbo_stream(self) -> TurboStreamAction:

Expand All @@ -38,9 +38,10 @@ def get_turbo_stream(self) -> TurboStreamAction:
f"turbo stream action not defined in {self.__class__}.get_turbo_stream_action"
)

return TurboStream(target, is_multiple=self.is_turbo_stream_targets()).action(
action
)
return TurboStream(
target,
is_multiple=self.is_turbo_stream_multiple(),
).action(action)

def get_turbo_stream_action(self) -> Optional[Action]:
"""Returns the turbo-stream action parameter
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_response_content(self):
resp = MyView.as_view(
turbo_stream_target=".test",
turbo_stream_action=Action.REPLACE,
is_multiple=True,
turbo_stream_multiple=True,
)(req)
assert resp.status_code == http.HTTPStatus.OK
assert "text/vnd.turbo-stream.html;" in resp["Content-Type"]
Expand Down

0 comments on commit bfcc066

Please sign in to comment.