Appearance: Fix form CSS media rendering
Fix the way the form CSS contained in the media attribute is rendered. This is now an interator and not a single value. Replace the current method with a for loop. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import logging
|
||||
from graphviz import Digraph
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
from django.db import IntegrityError, models
|
||||
from django.db.models import F, Max, Q
|
||||
@@ -26,6 +27,7 @@ from .literals import (
|
||||
)
|
||||
from .managers import WorkflowManager
|
||||
from .permissions import permission_workflow_transition
|
||||
from .storages import storage_workflowimagecache
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -62,6 +64,22 @@ class Workflow(models.Model):
|
||||
def __str__(self):
|
||||
return self.label
|
||||
|
||||
def generate_image(self):
|
||||
cache_filename = '{}'.format(self.id)
|
||||
image = self.render()
|
||||
|
||||
# Since open "wb+" doesn't create files, check if the file
|
||||
# exists, if not then create it
|
||||
if not storage_workflowimagecache.exists(cache_filename):
|
||||
storage_workflowimagecache.save(
|
||||
name=cache_filename, content=ContentFile(content='')
|
||||
)
|
||||
|
||||
with storage_workflowimagecache.open(cache_filename, 'wb+') as file_object:
|
||||
file_object.write(image)
|
||||
|
||||
return cache_filename
|
||||
|
||||
def get_document_types_not_in_workflow(self):
|
||||
return DocumentType.objects.exclude(pk__in=self.document_types.all())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user