markup: do xls generation on webdav pdf save
This commit is contained in:
@ -22,6 +22,8 @@ from django.conf import settings
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'procat2.settings')
|
||||
django.setup()
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from .utils import clean_path, ensure_dir, set_file_perms, WORKDIR
|
||||
from .email import reply, reply_missing, reply_no_matches, send_error_email
|
||||
from .matching import find_marked_products
|
||||
@ -90,11 +92,13 @@ def process_attachment(from_address, subject, attachment):
|
||||
|
||||
|
||||
@shared_task(on_failure=on_fail_handler)
|
||||
def process_markup_pdf(pdf_path, user):
|
||||
def process_markup_pdf(pdf_path, username):
|
||||
if not Path(pdf_path).is_file():
|
||||
print(f'No pdf - exiting ({pdf_path})')
|
||||
return
|
||||
|
||||
user = User.objects.get(username=username)
|
||||
|
||||
pdf_stem = Path(pdf_path).stem
|
||||
workdir = os.path.join(WORKDIR, clean_path(user.username), clean_path(pdf_stem))
|
||||
ensure_dir(workdir)
|
||||
|
||||
@ -28,6 +28,7 @@ from procat2.models import Catalog
|
||||
from procat2.settings import ASSET_DIR
|
||||
|
||||
from .utils import clean_path, ensure_dir, set_file_perms, WORKDIR
|
||||
from .tasks import process_markup_pdf
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -262,6 +263,7 @@ class MarkupResource(MarkupDavResource, DummyFSDAVResource):
|
||||
|
||||
def write(self, request, temp_file=None, range_start=None):
|
||||
super().write(request, temp_file=temp_file, range_start=range_start)
|
||||
process_markup_pdf.delay(self.get_abs_path(), self.user.username)
|
||||
|
||||
def get_acl(self):
|
||||
return FullAcl()
|
||||
|
||||
Reference in New Issue
Block a user