Commit fb3e1aa3 authored by Dylann Cordel's avatar Dylann Cordel

fix error if image are not anymore on the server

parent 93df343d
......@@ -18,6 +18,19 @@ class GraphvizPlugin(CMSPluginBase):
render_template = 'cms_graphviz/plugin.html'
cache = True
def render(self, context, instance, placeholder):
if instance.display_type in (instance.DISPLAY_TYPE_PNG, instance.DISPLAY_TYPE_SVG):
try:
instance.graph_image.file
if instance.mobile_graph_image:
try:
instance.mobile_graph_image.file
except:
instance.mobile_graph_image = None
except:
instance.display_type = instance.DISPLAY_TYPE_DOT
return super(GraphvizPlugin, self).render(context, instance, placeholder)
def save_model(self, request, obj, form, change):
"""
Given a model instance save it to the database.
......
{% if instance.name %}
<h2>{{ instance.name }} | {{ instance.display_type }}</h2>
<h2>{{ instance.name }}</h2>
{% endif %}
<div class="graphviz">
{% if instance.display_type == instance.DISPLAY_TYPE_SVG %}
{{ instance.graph.read|safe }}
{% if instance.graph %}
<div class="large">{{ instance.graph.read|safe }}</div>
{% endif %}
{% if instance.mobile_graph %}
<div class="mobile">{{ instance.mobile_graph.read|safe }}</div>
{% endif %}
{% elif instance.display_type == instance.DISPLAY_TYPE_PNG %}
<img src="{{ instance.graph.url }}" alt="{{ instance.name }}" />
<img class="large" src="{{ instance.graph.url }}" alt="{{ instance.name }}" />
{% if instance.mobile_graph %}
<img class="mobile" src="{{ instance.mobile_graph.url }}" alt="{{ instance.name }}" />
{% endif %}
{% else %}
<pre class="dot">{{ instance.graph }}</pre>
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment