diff --git a/coinmanager/coinc/cache.py b/coinmanager/coinc/cache.py index 92eeabd..79a5ef0 100644 --- a/coinmanager/coinc/cache.py +++ b/coinmanager/coinc/cache.py @@ -24,13 +24,7 @@ from random import random from django.core.cache import cache from django.http import Http404 -#todo we dont need this, no db queries from .models import Coin -from .models import Country - - -def get_etag_index(request): - return cache.get(f'etag_index', set_etag_index()) def get_last_modified_index(request): @@ -46,6 +40,7 @@ def set_last_modified_index(): cache.set(f'last_modified_index', last_modified) return last_modified + def get_last_modified_country(request, name_iso): return cache.get(f'last_modified_{name_iso}', set_last_modified_country(name_iso)) @@ -58,28 +53,3 @@ def set_last_modified_country(name_iso): raise Http404(f'Das Land "{name_iso}" existiert nicht') cache.set(f'last_modified_{name_iso}', last_modified) return last_modified - - -def set_etag_index(): - etag = '' - for country in Country.objects.order_by('name_iso'): - etag += get_etag_country_(country.name_iso) - etag = sha256(etag.encode('utf-8')).hexdigest()[0:9] - cache.set(f'etag_index', etag) - return etag - - -def get_etag_country_(name_iso): - return cache.get(f'etag_{name_iso}', set_etag_country(name_iso)) - - -def get_etag_country(request, name_iso): - return get_etag_country_(name_iso) - - -def set_etag_country(name_iso): - print(name_iso, end='') - print(cache.get(f'etag_{name_iso}', f'error {name_iso}')) - etag = sha256(str(random()).encode('utf-8')).hexdigest()[0:9] - cache.set(f'etag_{name_iso}', etag) - return etag diff --git a/coinmanager/coinc/templates/coinc/controlbar.html b/coinmanager/coinc/templates/coinc/controlbar.html index 0dd940f..d46291e 100644 --- a/coinmanager/coinc/templates/coinc/controlbar.html +++ b/coinmanager/coinc/templates/coinc/controlbar.html @@ -1,9 +1,11 @@ +{% load cache %} +{% csrf_token %} +{% cache None controlbar user %}
- {% csrf_token %} {% if user.is_authenticated %} @@ -14,7 +16,6 @@
- +{% endcache %} {% if not user.is_authenticated %}