Skip to content
Snippets Groups Projects
Commit 08c46998 authored by Emir İşman's avatar Emir İşman
Browse files

Move caching to views

parent cca75ec1
No related branches found
No related tags found
1 merge request!69WIP: Implement caching
Pipeline #61937 failed
from django.urls import path
from django.views.decorators.cache import cache_page
from . import views
urlpatterns = [
path('list/', cache_page(60 * 15)(views.list_categories), name='list'),
path('listwithmeta/', cache_page(60 * 15)(views.list_categories_with_meta), name='listwithmeta'),
path('list/', views.list_categories, name='list'),
path('listwithmeta/', views.list_categories_with_meta, name='listwithmeta'),
path('listonlyadmin/', views.list_categories_only_admin, name='listonlyadmin'),
path('listonlypayment/', views.list_categories_only_payment, name='listonlypayment'),
path('add/', views.add_category, name='add'),
......@@ -15,7 +14,7 @@ urlpatterns = [
path('addusertoset/<slug:slug>/', views.add_user_to_set, name='addusertoset'),
path('removeuserfromset/<slug:slug>/', views.remove_user_from_set, name='removeuserfromset'),
path('listexams/<slug:slug>/', views.list_exams, name='listexams'),
path('listmetacategories/', cache_page(60 * 15)(views.list_metacategories), name='list_metacategories'),
path('listmetacategories/', views.list_metacategories, name='list_metacategories'),
path('addmetacategory/', views.add_metacategory, name='addmetacategory'),
path('removemetacategory/', views.remove_metacategory, name='removemetacategory'),
path('setmetacategoryorder/', views.set_metacategory_order, name='setmetacategoryorder'),
......
......@@ -7,7 +7,7 @@ from myauth.models import get_my_user, MyUser
from categories.models import Category, MetaCategory
from django.conf import settings
from django.shortcuts import get_object_or_404
from django.views.decorators.cache import cache_page
@response.request_get()
@auth_check.require_login
......@@ -17,6 +17,7 @@ def list_categories(request):
@response.request_get()
@auth_check.require_login
@cache_page(15 * 60)
def list_categories_with_meta(request):
categories = Category.objects.select_related('meta').order_by('displayname').all()
res = [
......@@ -218,6 +219,7 @@ def remove_user_from_set(request, slug):
@response.request_get()
@auth_check.require_login
@cache_page(15 * 60)
def list_metacategories(request):
categories = MetaCategory.objects.select_related('parent').prefetch_related('metacategory_set', 'category_set').all()
tree = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment