Files
mayan-edms/mayan/apps/file_caching/tasks.py
Roberto Rosario 88bc29e4d7 Update the file caching app
- Add view to list available caches.
- Add links to view and purge caches.
- Add permissions.
- Add events.
- Add purge task.
- Remove document image clear link and view.
  This is now handled by the file caching app.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
2019-07-25 02:24:33 -04:00

26 lines
613 B
Python

from __future__ import unicode_literals
import logging
from django.apps import apps
from django.contrib.auth import get_user_model
from mayan.celery import app
logger = logging.getLogger(__name__)
@app.task(ignore_result=True)
def task_cache_purge(cache_id, user_id=None):
Cache = apps.get_model(
app_label='file_caching', model_name='Cache'
)
User = get_user_model()
cache = Cache.objects.get(pk=cache_id)
user = User.objects.get(pk=user_id)
logger.info('Starting cache id %s purge', cache)
cache.purge(_user=user)
logger.info('Finished cache id %s purge', cache)