queue cat render on save
This commit is contained in:
@ -6,7 +6,7 @@ import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
from django.db import models
|
||||
from django.db import models, connections
|
||||
|
||||
from products.models import Product
|
||||
|
||||
@ -178,3 +178,16 @@ class Catalog(models.Model):
|
||||
materials = materials.union(set(block.get('ids', [])))
|
||||
|
||||
return materials
|
||||
|
||||
|
||||
def queue_render(self):
|
||||
"""Create a pdf render job for us in the queue."""
|
||||
job_state = 'new'
|
||||
job_class = 'Appy::Queue::ProCatalogRenderJob'
|
||||
job_args = { 'id': self.id }
|
||||
|
||||
job_sql = 'insert into job_queue (state,job_class,job_args) values(%s,%s,%s)'
|
||||
job_params = [job_state, job_class, json.dumps(job_args)]
|
||||
|
||||
with connections['products'].cursor() as cursor:
|
||||
cursor.execute(job_sql, job_params)
|
||||
|
||||
Reference in New Issue
Block a user