You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
Maybe I did not get the whole picture here, but I am a bit confused by the way Streams are attached and which context they get.
My setup is a simple listview that lists items (name changed for simplification), and anoter page with a form to add items. Whenever an item is saved, a ModelStream adds a item line to the site that is subscripting the stream, like in the room/message tutorial. So far, so good, as long as no permissions are needed.
Next to each item, I have a delete button, that points to /items/<pk>/delete, which deletes via a TurboStreamDeleteView the requested model instance. The ModelStream then removes the HTML of that instance from the list.
This works too as intended.
But, I want the delete button displayed only when the user has the delete_item permission. Within the ItemListView this is easy. But when it comes to adding an item by ModelStream (which renders the same included partial), perms is not available, so the button always is gone.
This is clear, as the Stream context does not know about the user attached to it.
But how can I handle this? Using HTML-over-the-wire, I have to know something about the recipient, right?
How do I achieve this? I am struggling with too many knots in my head since I know TurboDjango ;-) It's always thinking "the other way round".
Any hints?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Maybe I did not get the whole picture here, but I am a bit confused by the way Streams are attached and which context they get.
My setup is a simple listview that lists
items
(name changed for simplification), and anoter page with a form to add items. Whenever an item is saved, aModelStream
adds a item line to the site that is subscripting the stream, like in the room/message tutorial. So far, so good, as long as no permissions are needed.Next to each item, I have a delete button, that points to
/items/<pk>/delete
, which deletes via a TurboStreamDeleteView the requested model instance. TheModelStream
then removes the HTML of that instance from the list.This works too as intended.
But, I want the delete button displayed only when the user has the
delete_item
permission. Within the ItemListView this is easy. But when it comes to adding an item by ModelStream (which renders the same included partial),perms
is not available, so the button always is gone.This is clear, as the Stream context does not know about the user attached to it.
But how can I handle this? Using HTML-over-the-wire, I have to know something about the recipient, right?
How do I achieve this? I am struggling with too many knots in my head since I know TurboDjango ;-) It's always thinking "the other way round".
Any hints?
Beta Was this translation helpful? Give feedback.
All reactions