From 32785f321ac3d26754c64a071c8a5adc53436947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniele=20Vigan=C3=B2?= Date: Tue, 5 Nov 2024 22:43:15 +0100 Subject: [PATCH] Fix the logout to use a POST (introduced with Django 4.1) Also add an handy command to clear Django cache --- ram/portal/templates/includes/login.html | 7 ++++++- ram/ram/__init__.py | 2 +- ram/ram/management/commands/purge_cache.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 ram/ram/management/commands/purge_cache.py diff --git a/ram/portal/templates/includes/login.html b/ram/portal/templates/includes/login.html index 88a19d2..f9d69a7 100644 --- a/ram/portal/templates/includes/login.html +++ b/ram/portal/templates/includes/login.html @@ -18,7 +18,12 @@
  • Admin
  • Site configuration
  • -
  • Logout
  • +
  • +
    + {% csrf_token %} + +
    +
  • {% else %} Log in diff --git a/ram/ram/__init__.py b/ram/ram/__init__.py index 5f04d76..afce73c 100644 --- a/ram/ram/__init__.py +++ b/ram/ram/__init__.py @@ -1,4 +1,4 @@ from ram.utils import git_suffix -__version__ = "0.13.3" +__version__ = "0.13.4" __version__ += git_suffix(__file__) diff --git a/ram/ram/management/commands/purge_cache.py b/ram/ram/management/commands/purge_cache.py new file mode 100644 index 0000000..49edafc --- /dev/null +++ b/ram/ram/management/commands/purge_cache.py @@ -0,0 +1,13 @@ +from django.core.cache import cache +from django.core.management.base import BaseCommand, CommandError + + +class Command(BaseCommand): + help = "Clear the application cache" + + def handle(self, *args, **options): + try: + cache.clear() + self.stdout.write(self.style.SUCCESS("Cache cleared")) + except Exception: + raise CommandError("Cache is not active")