Commit f4ba0c92 by Kálmán Viktor

dashboard: fix store toplist refresh

parent f1063e30
...@@ -209,14 +209,15 @@ class IndexView(LoginRequiredMixin, TemplateView): ...@@ -209,14 +209,15 @@ class IndexView(LoginRequiredMixin, TemplateView):
# toplist # toplist
user_home = "u-%d" % user.pk user_home = "u-%d" % user.pk
cache_key = "toplist-%s" % user_home
cache = get_cache("default") cache = get_cache("default")
toplist = cache.get("toplist-%s" % user_home) toplist = cache.get(cache_key)
if not toplist: if not toplist:
try: try:
toplist = store_api.process_list(store_api.toplist(user_home)) toplist = store_api.process_list(store_api.toplist(user_home))
except Http404: except Http404:
toplist = [] toplist = []
cache.set("toplist-%s" % user_home, toplist, 300) cache.set(cache_key, toplist, 300)
context['toplist'] = toplist context['toplist'] = toplist
...@@ -3190,12 +3191,12 @@ def store_new_directory(request): ...@@ -3190,12 +3191,12 @@ def store_new_directory(request):
@login_required @login_required
def store_refresh_toplist(request): def store_refresh_toplist(request):
user_home = "u-%d" % request.user.pk user_home = "u-%d" % request.user.pk
cache_key = "toplist-%s" % user_home
cache = get_cache("default") cache = get_cache("default")
try: try:
toplist = store_api.process_list(store_api.toplist(user_home)) toplist = store_api.process_list(store_api.toplist(user_home))
except Http404: except Http404:
toplist = [] toplist = []
cache.set("toplist-test", toplist, 300) cache.set(cache_key, toplist, 300)
user_home = "u-%d" % request.user.pk
return redirect(reverse("dashboard.index")) return redirect(reverse("dashboard.index"))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment