mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Fix caching
This commit is contained in:
@@ -152,17 +152,19 @@ LOGGING = {
|
||||
}
|
||||
}
|
||||
|
||||
# Caching
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
||||
'LOCATION': 'cache_table',
|
||||
}
|
||||
}
|
||||
# Tests lock up SQLite otherwise
|
||||
if DEBUG or STAGING or CI:
|
||||
CACHES['default'] = {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
|
||||
}
|
||||
}
|
||||
else:
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
||||
'LOCATION': 'cache_table',
|
||||
}
|
||||
}
|
||||
|
||||
RAVEN_CONFIG = {
|
||||
|
||||
@@ -89,10 +89,7 @@ def screenshot_failure_cls(cls):
|
||||
|
||||
|
||||
# Checks if animation is done
|
||||
class animation_is_finished(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class animation_is_finished():
|
||||
def __call__(self, driver):
|
||||
numberAnimating = driver.execute_script('return $(":animated").length')
|
||||
finished = numberAnimating == 0
|
||||
|
||||
@@ -20,12 +20,11 @@ from RIGS import models, forms
|
||||
from assets import models as asset_models
|
||||
from functools import reduce
|
||||
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.decorators.cache import never_cache, cache_page
|
||||
from django.utils.decorators import method_decorator
|
||||
|
||||
|
||||
# Displays the current rig count along with a few other bits and pieces
|
||||
@method_decorator(never_cache, name='dispatch') # Disable browser based caching
|
||||
class Index(generic.TemplateView):
|
||||
template_name = 'index.html'
|
||||
|
||||
|
||||
@@ -141,8 +141,6 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
|
||||
|
||||
user_activated.connect(send_admin_awaiting_approval_email)
|
||||
|
||||
# TODO Move
|
||||
|
||||
|
||||
def update_cache(sender, instance, created, **kwargs):
|
||||
cache.clear()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{% load namewithnotes from filters %}
|
||||
{% load cache %}
|
||||
{% cache None event_table request.user %}
|
||||
<div class="table-responsive">
|
||||
<table class="table mb-0">
|
||||
<thead>
|
||||
@@ -102,3 +104,4 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endcache %}
|
||||
|
||||
@@ -32,4 +32,3 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
{% load humanize %}
|
||||
{% load paginator from filters %}
|
||||
{% load to_class_name from filters %}
|
||||
{% load cache %}
|
||||
|
||||
{% block content %}
|
||||
{% cache None feed_data request.user %}
|
||||
<div class="list-group-item">
|
||||
<div class="media">
|
||||
{% for version in object_list %}
|
||||
@@ -48,4 +50,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endcache %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -7,12 +7,11 @@ from PyRIGS.decorators import (api_key_required, has_oembed,
|
||||
permission_required_with_403)
|
||||
from RIGS import finance, ical, models, rigboard, views, hs
|
||||
from versioning import views
|
||||
from django.views.decorators.cache import cache_page
|
||||
from django.apps import apps
|
||||
|
||||
urlpatterns = [
|
||||
path('rigboard/activity/feed/',
|
||||
cache_page(60 * 10)(permission_required_with_403('RIGS.view_event')(views.ActivityFeed.as_view())),
|
||||
permission_required_with_403('RIGS.view_event')(views.ActivityFeed.as_view()),
|
||||
name='activity_feed'),
|
||||
]
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.apps import apps
|
||||
from reversion import revisions as reversion
|
||||
from versioning.versioning import RIGSVersion
|
||||
|
||||
from django.views.decorators.cache import never_cache
|
||||
from django.views.decorators.cache import never_cache, cache_page
|
||||
from django.utils.decorators import method_decorator
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ class ActivityTable(generic.ListView):
|
||||
return context
|
||||
|
||||
|
||||
@method_decorator(never_cache, name='dispatch') # Disable browser based caching
|
||||
class ActivityFeed(generic.ListView): # Appears on homepage
|
||||
model = RIGSVersion
|
||||
template_name = "activity_feed_data.html"
|
||||
|
||||
Reference in New Issue
Block a user