Skip to content

Commit

Permalink
Fix logout as POST on django 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodiegoss committed Oct 27, 2024
1 parent b6ebb4c commit 489fd17
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ playwright = "^1.41.2"
pytest = "^7.2.0"
pytest-xdist = "^3.0.2"
flake8 = "^7.1.1"
Flake8-pyproject = "^1.2.3"
black = "^22.10.0"
isort = "^5.10.1"
pytest-django = "^4.5.2"
Expand All @@ -57,4 +58,8 @@ exclude = '''
[tool.isort]
profile = "black"
src_paths = ["src"]
skip_glob = "*/migrations/*.py"
skip_glob = "*/migrations/*.py"

[tool.flake8]
max-line-length = 200
exclude="**/migrations/"
7 changes: 6 additions & 1 deletion src/users/jinja2/users/components/userbox.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
</div>
<div class="editProf sm-full lg-one-third">
<a class="option-link" href="{{ url('edit-profile')}}">{{ _('Edit profile') }}</a>
<a class="option-link" href="{{ url('logout') }}">{{ _('Log out') }}</a>
<form id="logout-form" method="post" action="{{ url('logout') }}" style="display: none;">
{{ csrf_input }}
</form>
<a href="#" class="option-link" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
{{ _('Log out') }}
</a>
</div>
{%if artworks_qty %}
<div class="bdgArt half">
Expand Down
7 changes: 6 additions & 1 deletion src/users/jinja2/users/profile-edit.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
<div class="container">

<section class="account-options flex">
<a href="{{ url('logout') }}">{{ _('Log out') }}</a>
<form id="logout-form" method="post" action="{{ url('logout') }}" style="display: none;">
{{ csrf_input }}
</form>
<a href="#" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
{{ _('Log out') }}
</a>
<a href="#" onclick="return confirm('Are you sure you want to remove your account?')">{{ _('Remove account') }}</a>
</section>
<div class="password-form">
Expand Down
2 changes: 1 addition & 1 deletion src/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def profile(request):
"markers": markers,
"objects": objects,
"profile": True,
"button_enable": False if user else True,
"button_enable": True if user else False,
}
return render(request, "users/profile.jinja2", ctx)

Expand Down
1 change: 1 addition & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
directory = os.path.dirname(__file__)
sys.path.append("jandig")


#
# Call python manage.py in a more robust way
#
Expand Down

0 comments on commit 489fd17

Please sign in to comment.