mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-28 02:42:17 +00:00
@@ -150,6 +150,14 @@ LOGGING = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Caching
|
||||||
|
CACHES = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
|
||||||
|
'LOCATION': 'cache_table',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RAVEN_CONFIG = {
|
RAVEN_CONFIG = {
|
||||||
'dsn': os.environ.get('RAVEN_DSN'),
|
'dsn': os.environ.get('RAVEN_DSN'),
|
||||||
# If you are using git, you can also automatically configure the
|
# If you are using git, you can also automatically configure the
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from PyPDF2 import PdfFileReader, PdfFileMerger
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
from django.core.mail import EmailMessage, EmailMultiAlternatives
|
||||||
|
from django.core.cache import cache
|
||||||
from django.template.loader import get_template
|
from django.template.loader import get_template
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -18,6 +19,7 @@ from premailer import Premailer
|
|||||||
from z3c.rml import rml2pdf
|
from z3c.rml import rml2pdf
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models
|
||||||
|
from versioning.versioning import models_for_feed
|
||||||
|
|
||||||
|
|
||||||
def send_eventauthorisation_success_email(instance):
|
def send_eventauthorisation_success_email(instance):
|
||||||
@@ -138,3 +140,13 @@ def send_admin_awaiting_approval_email(user, request, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
user_activated.connect(send_admin_awaiting_approval_email)
|
user_activated.connect(send_admin_awaiting_approval_email)
|
||||||
|
|
||||||
|
# TODO Move
|
||||||
|
|
||||||
|
|
||||||
|
def update_cache(sender, instance, created, **kwargs):
|
||||||
|
cache.clear()
|
||||||
|
|
||||||
|
|
||||||
|
for model in models_for_feed():
|
||||||
|
post_save.connect(update_cache, sender=model)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{% extends 'base_rigs.html' %}
|
{% extends 'base_rigs.html' %}
|
||||||
|
|
||||||
{% block title %}RIGS{% endblock %}
|
{% block title %}RIGS{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from PyRIGS.decorators import (api_key_required, has_oembed,
|
|||||||
permission_required_with_403)
|
permission_required_with_403)
|
||||||
from RIGS import finance, ical, models, rigboard, views
|
from RIGS import finance, ical, models, rigboard, views
|
||||||
from versioning import versioning
|
from versioning import versioning
|
||||||
|
from django.views.decorators.cache import cache_page
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', login_required(views.Index.as_view()), name='index'),
|
path('', login_required(views.Index.as_view()), name='index'),
|
||||||
@@ -68,7 +69,7 @@ urlpatterns = [
|
|||||||
path('rigboard/activity/', permission_required_with_403('RIGS.view_event')(versioning.ActivityTable.as_view()),
|
path('rigboard/activity/', permission_required_with_403('RIGS.view_event')(versioning.ActivityTable.as_view()),
|
||||||
name='activity_table'),
|
name='activity_table'),
|
||||||
path('rigboard/activity/feed/',
|
path('rigboard/activity/feed/',
|
||||||
permission_required_with_403('RIGS.view_event')(versioning.ActivityFeed.as_view()),
|
cache_page(60 * 10)(permission_required_with_403('RIGS.view_event')(versioning.ActivityFeed.as_view())),
|
||||||
name='activity_feed'),
|
name='activity_feed'),
|
||||||
|
|
||||||
path('event/<int:pk>/', has_oembed(oembed_view="event_oembed")(rigboard.EventDetail.as_view()),
|
path('event/<int:pk>/', has_oembed(oembed_view="event_oembed")(rigboard.EventDetail.as_view()),
|
||||||
|
|||||||
@@ -21,12 +21,17 @@ from assets import models as asset_models
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from PyRIGS.views import GenericListView
|
from PyRIGS.views import GenericListView
|
||||||
|
from django.views.decorators.cache import never_cache
|
||||||
|
from django.utils.decorators import method_decorator
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Displays the current rig count along with a few other bits and pieces
|
Displays the current rig count along with a few other bits and pieces
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Disable browser based caching
|
||||||
|
|
||||||
|
|
||||||
|
@method_decorator(never_cache, name='dispatch')
|
||||||
class Index(generic.TemplateView):
|
class Index(generic.TemplateView):
|
||||||
template_name = 'index.html'
|
template_name = 'index.html'
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,10 @@ class ActivityTable(generic.ListView):
|
|||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
def models_for_feed():
|
||||||
|
return [models.Event, models.Venue, models.Person, models.Organisation, models.EventAuthorisation, models.RiskAssessment, asset_models.Asset, asset_models.Supplier]
|
||||||
|
|
||||||
|
|
||||||
# Appears on homepage
|
# Appears on homepage
|
||||||
class ActivityFeed(generic.ListView):
|
class ActivityFeed(generic.ListView):
|
||||||
model = RIGSVersion
|
model = RIGSVersion
|
||||||
@@ -243,7 +247,7 @@ class ActivityFeed(generic.ListView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
versions = RIGSVersion.objects.get_for_multiple_models(
|
versions = RIGSVersion.objects.get_for_multiple_models(
|
||||||
[models.Event, models.Venue, models.Person, models.Organisation, models.EventAuthorisation, models.RiskAssessment, asset_models.Asset, asset_models.Supplier])
|
models_for_feed())
|
||||||
return versions.order_by("-revision__date_created")
|
return versions.order_by("-revision__date_created")
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user