Commit 7f6acb73 by benjaoming

#119 do not fail when deleting blank image and attachment fields

parent 51497ca2
......@@ -166,7 +166,11 @@ def on_revision_delete(instance, *args, **kwargs):
max_depth = 1
for depth in range(0, max_depth):
delete_path = "/".join(path[:-depth] if depth > 0 else path)
if len(os.listdir(os.path.join(django_settings.MEDIA_ROOT, delete_path))) == 0:
os.rmdir(delete_path)
try:
if len(os.listdir(os.path.join(django_settings.MEDIA_ROOT, delete_path))) == 0:
os.rmdir(delete_path)
except OSError:
# Raised by os.listdir if directory is missing
pass
signals.pre_delete.connect(on_revision_delete, AttachmentRevision)
......@@ -103,6 +103,8 @@ class ImageRevision(RevisionPluginRevision):
def on_image_revision_delete(instance, *args, **kwargs):
if not instance.image:
return
# Remove image file
path = instance.image.path.split("/")[:-1]
instance.image.delete(save=False)
......
......@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>{% block pagetitle %}{% endblock %} -- django-\/\/ i K |</title>
<title>{% block pagetitle %}{% endblock %} - django-\/\/ i K |</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="www.django-wiki.org">
......@@ -34,7 +34,7 @@
<span class="icon-bar"></span>
</a>
{% block wiki_header_branding %}
<a class="brand" href="{% url 'wiki:root' %}">django-wiki</a>
<a class="brand" href="{% url 'wiki:root' %}">django-\/\/ i K |</a>
{% endblock %}
<form class="navbar-search pull-right" id="navbar_wiki_search" method="GET" action="{% url 'wiki:search' %}">
<span class="icon-search"></span>
......
# -*- coding: utf-8 -*-
"""This is nothing but the usual handling of django user accounts, so
go ahead and replace it or disable it!"""
"""Here is a very basic handling of accounts."""
from django.conf import settings as django_settings
from django.contrib import messages
......
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