-
Notifications
You must be signed in to change notification settings - Fork 15
add logout modal button to global context #1361
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| {% include logout_modal.template_name with modal=logout_modal %} | ||
|
Contributor
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. this looks weird. would be much better if it was possible to just write
Contributor
Author
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. That's my ultimate goal but I've been struggling to make the csrf token/context outside of the modal itself available to the template. Therefore I'm working to finish everything else while doing the occasional web search for clues.
Contributor
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. How does django forms do this?
Contributor
Author
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. The form way is what I've been doing so far, which is why I inherit from |
||
| <form class="flex" action="{% url "htmx:logout" %}" method="post"> | ||
| {% csrf_token %} | ||
| <button class="flex-1 text-start" type="submit">Log out</button> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """ | ||
| How to use: | ||
|
|
||
| Append the "context_processors" list for the TEMPLATES-backend | ||
| ``django.template.backends.django.DjangoTemplates`` with the full dotted path. | ||
|
|
||
| See django settings for ``TEMPLATES``. | ||
| """ | ||
|
Comment on lines
+1
to
+8
Contributor
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. Do we need something to indicate that if you're using
Contributor
Author
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. Hmm.. this is copypasted from another context processor so there would be more places to change. Separate PR I think. |
||
|
|
||
| from django.urls import reverse | ||
|
|
||
| from .views import LogoutModal | ||
|
|
||
|
|
||
| def logout_context(request): | ||
| return { | ||
| "logout_modal": LogoutModal( | ||
| endpoint=reverse("htmx:logout"), | ||
| dialog_id="logout-dialog", | ||
| ), | ||
| } | ||
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.
Nice, I like how the context processor is automatically added through appconfig