begin most recent function
This commit is contained in:
parent
f4ad6cb924
commit
b6bd4c1390
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ Pipfile.lock
|
||||
**/__pycache__/*
|
||||
coinmanager/static/*
|
||||
*.sqlite3
|
||||
**/pyenv/*
|
||||
|
@ -2,6 +2,10 @@
|
||||
{% if countrys %}
|
||||
<p><h5>Gesamtwert {{ coin_sum }}</h5></p>
|
||||
{% include 'coinc/filter_country.html' with countrys=countrys %}
|
||||
<p><h5>Zuletzt hinzugefügt</h5></p>
|
||||
{% for coin in recent_coins %}
|
||||
<p>{{ coin.found_on|date:"d.m.Y" }}: {{ coin.value }}€ {{ coin.name }} von {{ coin.found_by }}</p>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<p>Trage zuerst Länder im Adminbereich ein.</p>{% endif %}
|
||||
{% include 'footer.html' %}
|
||||
|
@ -19,15 +19,15 @@
|
||||
|
||||
|
||||
from django.urls import path, include
|
||||
from django.views.decorators.cache import cache_page
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
app_name = 'coinc'
|
||||
urlpatterns = [
|
||||
path('', views.index, name='index'),
|
||||
#path('statistik', views.statistic, name='statistic'),
|
||||
path('<str:name_iso>', views.detail_country, name='country'),
|
||||
path('', cache_page(None)(views.index), name='index'),
|
||||
path('<str:name_iso>', cache_page(None)(views.detail_country), name='country'),
|
||||
path('add/user/<str:username>/color/<str:color>', views.add_user, name='add_user'),
|
||||
path('add/coin', views.add_coin, name='add_coin'),
|
||||
path('accounts/', include('django.contrib.auth.urls')),
|
||||
|
@ -41,10 +41,14 @@ def index(request):
|
||||
countrys = Country.objects.order_by('name')
|
||||
users = User.objects.order_by('id')
|
||||
coin_sum = total_coin_sum()
|
||||
recent_coins = Coin.objects.order_by('-found_on')[:10]
|
||||
for coin in recent_coins:
|
||||
recent_coins[coin][value] /= 100
|
||||
context = {
|
||||
'countrys': countrys,
|
||||
'users': users,
|
||||
'coin_sum': f'{coin_sum:.2f} €'
|
||||
'coin_sum': f'{coin_sum:.2f} €',
|
||||
'recent_coins': recent_coins,
|
||||
}
|
||||
|
||||
return HttpResponse(template.render(context, request))
|
||||
|
@ -43,9 +43,9 @@ INSTALLED_APPS = [
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.cache.UpdateCacheMiddleware',
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
# 'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.middleware.http.ConditionalGetMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
@ -136,12 +136,19 @@ LOGIN_REDIRECT_URL = './'
|
||||
# caching
|
||||
CACHES = {
|
||||
'default': {
|
||||
# file-based
|
||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
||||
'LOCATION': '/var/tmp/django_cache',
|
||||
'LOCATION': '/var/tmp/django-cache',
|
||||
'TIMEOUT': None,
|
||||
# memory-based
|
||||
#'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
#'LOCATION': 'coinc',
|
||||
#'TIMEOUT': None,
|
||||
}
|
||||
}
|
||||
|
||||
# caching
|
||||
CACHE_MIDDLEWARE_ALIAS = 'default'
|
||||
CACHE_MIDDLEWARE_SECONDS = 60*60*24*7
|
||||
# CACHE_MIDDLEWARE_ALIAS = 'default'
|
||||
CACHE_MIDDLEWARE_SECONDS = 60*60*24*365
|
||||
|
||||
CACHEOPS_REDIS = "unix://var/run/redis/redis-server.sock"
|
||||
|
Loading…
x
Reference in New Issue
Block a user