Commits

Carl Meyer committed 2855ec6 Merge

Merged from shagi's branch; fixes #10.

Comments (0)

Files changed (30)

 ^dist/
+^build/
 ^django_adminfiles.egg-info/
 ^HGREV$
 ^TAGS$
 ^tests/media/adminfiles/.*_q
-^.tox/
+^tests/media/cache/.*
+^.tox/
+^.*.pyc$

adminfiles/media/adminfiles/adminfiles.css

-#content { margin:10px 0; }
-#container { min-width:0; }
-#user-tools { display:none; }
-#footer { display:none; }
-
-#adminfiles { 
-    list-style-type:none; 
-    padding:0; 
-    position:absolute; 
-    top:0px; 
-    left:110px; 
-}
-
-#adminfiles .nav {
-    list-style-type:none;
-    width:100%;
-    height: 2em;
-}
-
-#adminfiles .nav .next {
-    float:right;
-}
-
-#adminfiles .nav .prev {
-    float:left;
-}
-
-.item { 
-    float:left; 
-    overflow:hidden; 
-    border:1px solid #ccc; 
-    background:#fafafa url(mimetypes/empty.png) no-repeat 41px 70px; 
-    text-align:center; 
-    cursor:pointer; 
-    width:144px; 
-    height:150px; 
-    margin:0 11px 12px 0;
-}
-
-.upload-title { 
-    background:#fff; 
-    opacity:0.8;
-}
-
-.popup { 
-    position:absolute; 
-    z-index:100; 
-    opacity:0.9; 
-    background:#eee; 
-    width:126px; 
-    height:120px; 
-    padding:5px; 
-    display:none; 
-    text-align:left; 
-    margin:15px 0 0 3px; 
-    border:1px solid #aaa; 
-    border-top-color:#ddd; 
-    border-left-color:#ddd; 
-}
-
-.popup ul { padding:0; }
-.popup li { list-style-type:none; }
-.popup .close { float:right; color:#CC3434; }
-.popup input { width:116px; }
-.popup .deletelink { position: absolute; left: 5px; bottom: 10px; }
-.popup .changelink { position: absolute; right: 5px; bottom: 10px; }
-        
-#adminfiles-filter { 
-    position:fixed; 
-    left:0; 
-    width:100%; 
-    margin-left: -30px;
-}
-
-#adminfiles-filter li {
-    list-style-type:none;
-}
-
-#adminfiles-filter li.upload {
-    margin-top: 10px;
-}
-        
-/* mimetypes, icons from Nuvola */
-.image, .video { 
-    background-image:none; 
-    background-position:center center; 
-}
-
-.pdf { background-image:url(mimetypes/pdf.png); }
-.msword { background-image:url(mimetypes/doc.png); }
-.vndms-excel { background-image:url(mimetypes/xls.png); }
-.zip, .x-tar { background-image:url(mimetypes/zip.png); }
-    

adminfiles/media/adminfiles/adminfiles.js

-function insertAtCursor(myField, myValue) {
-    //IE support
-    if (document.selection) {
-        myField.focus();
-        sel = document.selection.createRange();
-        sel.text = myValue;
-    }
-    //MOZILLA/NETSCAPE support
-    else if (myField.selectionStart || myField.selectionStart == '0') {
-        var startPos = myField.selectionStart;
-        var endPos = myField.selectionEnd;
-        myField.value = myField.value.substring(0, startPos)
-        + myValue
-        + myField.value.substring(endPos, myField.value.length);
-    } else {
-        myField.value += myValue;
-    }
-}
-
-function showEditPopup(triggeringLink) {
-    var name = 'edit_popup';
-    var href = triggeringLink.href;
-    if (href.indexOf('?') == -1) {
-        href += '?_popup=1';
-    } else {
-        href  += '&_popup=1';
-    }
-    var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
-    win.focus();
-    return false;
-}
-
-function dismissEditPopup(win) {
-    location.reload(true);
-    win.close();
-}
-
-function showAddUploadPopup(triggeringLink) {
-    var name = 'add_upload_popup';
-    var href = triggeringLink.href;
-    if (href.indexOf('?') == -1) {
-        href += '?_popup=1';
-    } else {
-        href  += '&_popup=1';
-    }
-    var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
-    win.focus();
-    return false;
-}
-
-function dismissAddUploadPopup(win) {
-    location.reload(true);
-    win.close();
-}
-
-$(function(){
-      $('#adminfiles li').click(
-          function(){
-	      $(this).children('.popup').show();
-	  });
-      $('.popup .close').click(
-          function(){
-	      $(this).parent('.popup').hide();
-	      return false;
-	  });
-      $('.popup .select').click(
-          function(){
-	      for (i=0; i<FIELD.options.length; i++) {
-		  if (FIELD.options[i].value == this.rel) {
-                      FIELD.options[i].selected = true;
-                  }
-	      }
-	      $(this).parents('.popup').hide();
-	      return false;
-	  });
-      $('.popup .insert').click(
-          function(){
-              var insertText = this.rel;
-              if(!insertText.match('://')) {
-                  insertText = START + insertText + END;
-                  }
-              insertAtCursor(FIELD, insertText);
-	      $(this).parents('.popup').hide();
-	      return false;
-	});
-    $('#refresh').click(function(){
-	    location.reload(true);
-	    return false;
-	});
-});

adminfiles/media/adminfiles/icon_addlink.gif

Removed
Old image

adminfiles/media/adminfiles/icon_refreshlink.gif

Removed
Old image

adminfiles/media/adminfiles/mimetypes/doc.png

Removed
Old image

adminfiles/media/adminfiles/mimetypes/empty.png

Removed
Old image

adminfiles/media/adminfiles/mimetypes/pdf.png

Removed
Old image

adminfiles/media/adminfiles/mimetypes/xls.png

Removed
Old image

adminfiles/media/adminfiles/mimetypes/zip.png

Removed
Old image

adminfiles/media/adminfiles/model.js

-(function($) {
-     $(function(){
-           $('.adminfilespicker').each(
-               function(){
-	           var href = '/adminfiles/all/?field='+this.id;
-	           if (this.options) {
-		       $(this).siblings('a.add-another').remove();
-		       href += '&field_type=select';
-	           }
-	           $(this).after('<iframe frameborder="0" style="border:none; width:755px; height:210px;" src="' + href + '"></iframe>');
-	       });
-       });
- })(jQuery);

adminfiles/media/adminfiles/photo-edit.js

-$(function(){
-    $('#id_upload').after(' <a href="#" id="photo-edit">Edit this photo</a>');
-    $('#photo-edit').hide();
-    var ext = '';
-    //check if the upload field contains an image path or PDF
-    $('#id_upload').change(function(){
-        var image_ext = ['.jpg', '.jpeg', '.gif', '.png', '.pdf'];
-        var found = false;
-        for (var i=0; i<image_ext.length; i++) {
-            if ($(this).val().lastIndexOf(image_ext[i]) > 0) {
-                found = true;
-                ext = image_ext[i].replace('.','');
-                break;
-            }
-        }
-        if (found == true)
-            $('#photo-edit').show();
-        else
-            $('#photo-edit').hide();
-    });
-    //edit form to post to snipshot and submit
-    $('a#photo-edit').click(function(){
-        $(this).after('<input type="hidden" name="snipshot_input" value="upload"/>');
-        $(this).after('<input type="hidden" name="snipshot_callback" value="'+document.location.href+'"/>');
-        $(this).parents('form').attr('action', 'http://services.snipshot.com/');
-        $(this).parents('form').submit();
-        return false;
-    });
-});

adminfiles/static/adminfiles/adminfiles.css

+#content { margin:10px 0; }
+#container { min-width:0; }
+#user-tools { display:none; }
+#footer { display:none; }
+
+#adminfiles { 
+    list-style-type:none; 
+    padding:0; 
+    position:absolute; 
+    top:0px; 
+    left:110px; 
+}
+
+#adminfiles .nav {
+    list-style-type:none;
+    width:100%;
+    height: 2em;
+}
+
+#adminfiles .nav .next {
+    float:right;
+}
+
+#adminfiles .nav .prev {
+    float:left;
+}
+
+.item { 
+    float:left; 
+    overflow:hidden; 
+    border:1px solid #ccc; 
+    background:#fafafa url(mimetypes/empty.png) no-repeat 41px 70px; 
+    text-align:center; 
+    cursor:pointer; 
+    width:144px; 
+    height:150px; 
+    margin:0 11px 12px 0;
+}
+
+.upload-title { 
+    background:#fff; 
+    opacity:0.8;
+}
+
+.popup { 
+    position:absolute; 
+    z-index:100; 
+    opacity:0.9; 
+    background:#eee; 
+    width:126px; 
+    height:120px; 
+    padding:5px; 
+    display:none; 
+    text-align:left; 
+    margin:15px 0 0 3px; 
+    border:1px solid #aaa; 
+    border-top-color:#ddd; 
+    border-left-color:#ddd; 
+}
+
+.popup ul { padding:0; }
+.popup li { list-style-type:none; }
+.popup .close { float:right; color:#CC3434; }
+.popup input { width:116px; }
+.popup .deletelink { position: absolute; left: 5px; bottom: 10px; }
+.popup .changelink { position: absolute; right: 5px; bottom: 10px; }
+        
+#adminfiles-filter { 
+    position:fixed; 
+    left:0; 
+    width:100%; 
+    margin-left: -30px;
+}
+
+#adminfiles-filter li {
+    list-style-type:none;
+}
+
+#adminfiles-filter li.upload {
+    margin-top: 10px;
+}
+        
+/* mimetypes, icons from Nuvola */
+.image, .video { 
+    background-image:none; 
+    background-position:center center; 
+}
+
+.pdf { background-image:url(mimetypes/pdf.png); }
+.msword { background-image:url(mimetypes/doc.png); }
+.vndms-excel { background-image:url(mimetypes/xls.png); }
+.zip, .x-tar { background-image:url(mimetypes/zip.png); }
+    

adminfiles/static/adminfiles/adminfiles.js

+function insertAtCursor(myField, myValue) {
+    //IE support
+    if (document.selection) {
+        myField.focus();
+        sel = document.selection.createRange();
+        sel.text = myValue;
+    }
+    //MOZILLA/NETSCAPE support
+    else if (myField.selectionStart || myField.selectionStart == '0') {
+        var startPos = myField.selectionStart;
+        var endPos = myField.selectionEnd;
+        myField.value = myField.value.substring(0, startPos)
+        + myValue
+        + myField.value.substring(endPos, myField.value.length);
+    } else {
+        myField.value += myValue;
+    }
+}
+
+function showEditPopup(triggeringLink) {
+    var name = 'edit_popup';
+    var href = triggeringLink.href;
+    if (href.indexOf('?') == -1) {
+        href += '?_popup=1';
+    } else {
+        href  += '&_popup=1';
+    }
+    var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
+    win.focus();
+    return false;
+}
+
+function dismissEditPopup(win) {
+    location.reload(true);
+    win.close();
+}
+
+function showAddUploadPopup(triggeringLink) {
+    var name = 'add_upload_popup';
+    var href = triggeringLink.href;
+    if (href.indexOf('?') == -1) {
+        href += '?_popup=1';
+    } else {
+        href  += '&_popup=1';
+    }
+    var win = window.open(href, name, 'height=500,width=800,resizable=yes,scrollbars=yes');
+    win.focus();
+    return false;
+}
+
+function dismissAddUploadPopup(win) {
+    location.reload(true);
+    win.close();
+}
+
+$(function(){
+      $('#adminfiles li').click(
+          function(){
+	      $(this).children('.popup').show();
+	  });
+      $('.popup .close').click(
+          function(){
+	      $(this).parent('.popup').hide();
+	      return false;
+	  });
+      $('.popup .select').click(
+          function(){
+	      for (i=0; i<FIELD.options.length; i++) {
+		  if (FIELD.options[i].value == this.rel) {
+                      FIELD.options[i].selected = true;
+                  }
+	      }
+	      $(this).parents('.popup').hide();
+	      return false;
+	  });
+      $('.popup .insert').click(
+          function(){
+              var insertText = this.rel;
+              if(!insertText.match('://')) {
+                  insertText = START + insertText + END;
+                  }
+              insertAtCursor(FIELD, insertText);
+	      $(this).parents('.popup').hide();
+	      return false;
+	});
+    $('#refresh').click(function(){
+	    location.reload(true);
+	    return false;
+	});
+});

adminfiles/static/adminfiles/icon_addlink.gif

Added
New image

adminfiles/static/adminfiles/icon_refreshlink.gif

Added
New image

adminfiles/static/adminfiles/mimetypes/doc.png

Added
New image

adminfiles/static/adminfiles/mimetypes/empty.png

Added
New image

adminfiles/static/adminfiles/mimetypes/pdf.png

Added
New image

adminfiles/static/adminfiles/mimetypes/xls.png

Added
New image

adminfiles/static/adminfiles/mimetypes/zip.png

Added
New image

adminfiles/static/adminfiles/model.js

+(function($) {
+     $(function(){
+           $('.adminfilespicker').each(
+               function(){
+	           var href = '/adminfiles/all/?field='+this.id;
+	           if (this.options) {
+		       $(this).siblings('a.add-another').remove();
+		       href += '&field_type=select';
+	           }
+	           $(this).after('<iframe frameborder="0" style="border:none; width:755px; height:210px;" src="' + href + '"></iframe>');
+	       });
+       });
+ })(jQuery);

adminfiles/static/adminfiles/photo-edit.js

+$(function(){
+    $('#id_upload').after(' <a href="#" id="photo-edit">Edit this photo</a>');
+    $('#photo-edit').hide();
+    var ext = '';
+    //check if the upload field contains an image path or PDF
+    $('#id_upload').change(function(){
+        var image_ext = ['.jpg', '.jpeg', '.gif', '.png', '.pdf'];
+        var found = false;
+        for (var i=0; i<image_ext.length; i++) {
+            if ($(this).val().lastIndexOf(image_ext[i]) > 0) {
+                found = true;
+                ext = image_ext[i].replace('.','');
+                break;
+            }
+        }
+        if (found == true)
+            $('#photo-edit').show();
+        else
+            $('#photo-edit').hide();
+    });
+    //edit form to post to snipshot and submit
+    $('a#photo-edit').click(function(){
+        $(this).after('<input type="hidden" name="snipshot_input" value="upload"/>');
+        $(this).after('<input type="hidden" name="snipshot_callback" value="'+document.location.href+'"/>');
+        $(this).parents('form').attr('action', 'http://services.snipshot.com/');
+        $(this).parents('form').submit();
+        return false;
+    });
+});

adminfiles/templates/adminfiles/uploader/base.html

 <ul id="adminfiles">
 {% block files %}
 {% for f in files %}
-   <li class="item {{f.content_type}} {{f.sub_type}}" {% if f.is_image %}style="background-image:url({% thumbnail f.upload 144x150 %});"{% else %}{% if f.mime_image %}style="background-image:url({{ f.mime_image }});"{% endif %}{% endif %}>
+   <li class="item {{f.content_type}} {{f.sub_type}}" {% if f.is_image %}style="background-image:url({% thumbnail f.upload "144x150" as thumb %}{{ thumb.url }});"{% else %}{% if f.mime_image %}style="background-image:url({{ f.mime_image }});"{% endif %}{% endif %}>
        <div class="popup">
            <a href="#" class="close" title="Close">X</a>
            <ul>

adminfiles/urls.py

 for browser in get_enabled_browsers():
     slug = browser.slug()
     urlpatterns += patterns('',
-        url('%s/$' % slug, browser,
+        url('%s/$' % slug, browser.as_view(),
             name='adminfiles_%s' % slug))

adminfiles/views.py

 from django.core.urlresolvers import reverse
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.translation import ugettext_lazy as _
+from django.views.generic import View, TemplateView
 
 from adminfiles.models import FileUpload
 from adminfiles import settings
 class DisableView(Exception):
     pass
 
-class BaseView(object):
+class BaseView(TemplateView):
     template_name = 'adminfiles/uploader/base.html'
 
-    def slug(self):
+    def get_context_data(self, **kwargs):
+        context = super(BaseView, self).get_context_data(**kwargs)
+        context.update({
+            'browsers': get_enabled_browsers(),
+            'field_id': self.request.GET['field'],
+            'field_type': self.request.GET.get('field_type', 'textarea'),
+            'ADMINFILES_MEDIA_URL': settings.ADMINFILES_MEDIA_URL,
+            'ADMINFILES_REF_START': settings.ADMINFILES_REF_START,
+            'ADMINFILES_REF_END': settings.ADMINFILES_REF_END,
+            'JQUERY_URL': settings.JQUERY_URL
+        })
+
+        return context
+
+    @classmethod
+    def slug(cls):
         """
         Return slug suitable for accessing this view in a URLconf.
 
         """
-        slug = self.__class__.__name__.lower()
+        slug = cls.__name__.lower()
         if slug.endswith('view'):
             slug = slug[:-4]
         return slug
 
-    def link_text(self):
+    @classmethod
+    def link_text(cls):
         """
         Return link text for this view.
 
         """
-        link = self.__class__.__name__
+        link = cls.__name__
         if link.endswith('View'):
             link = link[:-4]
         return link
 
-    def url(self):
+    @classmethod
+    def url(cls):
         """
         Return URL for this view.
 
         """
-        return reverse('adminfiles_%s' % self.slug())
+        return reverse('adminfiles_%s' % cls.slug())
 
-    def check(self):
+    @classmethod
+    def check(cls):
         """
         Raise ``DisableView`` if the configuration necessary for this
         view is not active.
         """
         pass
 
-    def context(self, request):
-        return {'browsers': get_enabled_browsers(),
-                'field_id': request.GET['field'],
-                'field_type': request.GET.get('field_type', 'textarea'),
-                'ADMINFILES_MEDIA_URL': settings.ADMINFILES_MEDIA_URL,
-                'ADMINFILES_REF_START': settings.ADMINFILES_REF_START,
-                'ADMINFILES_REF_END': settings.ADMINFILES_REF_END,
-                'JQUERY_URL': settings.JQUERY_URL}
-
-    def __call__(self, request):
-        return render_to_response(self.template_name,
-                                  self.context(request),
-                                  context_instance=RequestContext(request))
-
 
 class AllView(BaseView):
     link_text = _('All Uploads')
     def files(self):
         return FileUpload.objects.all()
 
-    def context(self, request):
-        context = super(AllView, self).context(request)
-        context['files'] = self.files().order_by(
-            *settings.ADMINFILES_THUMB_ORDER)
+    def get_context_data(self, **kwargs):
+        context = super(AllView, self).get_context_data(**kwargs)
+        context.update({
+            'files': self.files().order_by(*settings.ADMINFILES_THUMB_ORDER)
+        })
         return context
 
 
         return super(FilesView, self).files().exclude(content_type__in=not_files)
 
 class OEmbedView(BaseView):
-    def check(self):
+    @classmethod
+    def check(cls):
         if 'oembed' not in django_settings.INSTALLED_APPS:
             raise DisableView('OEmbed views require django-oembed or djangoembed. '
                               '(http://pypi.python.org/pypi/django-oembed, '
 class YouTubeView(OEmbedView):
     template_name = 'adminfiles/uploader/video.html'
 
-    def check(self):
-        super(YouTubeView, self).check()
+    @classmethod
+    def check(cls):
+        super(YouTubeView, cls).check()
         try:
             from gdata.youtube.service import YouTubeService
         except ImportError:
             raise DisableView('YouTubeView requires '
                               'ADMINFILES_YOUTUBE_USER setting')
 
-
-    def context(self, request):
-        context = super(YouTubeView, self).context(request)
-        context['videos'] = self.videos()
+    def get_context_data(self, **kwargs):
+        context = super(YouTubeView, self).get_context_data(**kwargs)
+        context.update({
+            'videos': self.videos()
+        })
         return context
 
     def videos(self):
 class FlickrView(OEmbedView):
     template_name = 'adminfiles/uploader/flickr.html'
 
-    def check(self):
-        super(FlickrView, self).check()
+    @classmethod
+    def check(cls):
+        super(FlickrView, cls).check()
         try:
             import flickrapi
         except ImportError:
                               'ADMINFILES_FLICKR_USER and '
                               'ADMINFILES_FLICKR_API_KEY settings')
 
-    def context(self, request):
-        context = super(FlickrView, self).context(request)
+    def get_context_data(self, **kwargs):
+        context = super(FlickrView, self).get_context_data(**kwargs)
         page = int(request.GET.get('page', 1))
         base_path = '%s?field=%s&page=' % (request.path, request.GET['field'])
         context['next_page'] = base_path + str(page + 1)
 class VimeoView(OEmbedView):
     template_name = 'adminfiles/uploader/video.html'
 
-    def check(self):
-        super(VimeoView, self).check()
+    @classmethod
+    def check(cls):
+        super(VimeoView, cls).check()
         try:
             django_settings.ADMINFILES_VIMEO_USER
         except AttributeError:
             raise DisableView('VimeoView requires '
                               'ADMINFILES_VIMEO_USER setting')
         try:
-            self.pages = django_settings.ADMINFILES_VIMEO_PAGES
+            cls.pages = django_settings.ADMINFILES_VIMEO_PAGES
         except AttributeError:
-            self.pages = 1
-        if self.pages > 3:
-            self.pages = 3
+            cls.pages = 1
+        if cls.pages > 3:
+            cls.pages = 3
 
-    def context(self, request):
-        context = super(VimeoView, self).context(request)
-        context['videos'] = self.videos()
+    def get_context_data(self, **kwargs):
+        context = super(VimeoView, self).get_context_data(**kwargs)
+        context.update({
+            'videos':self.videos()
+        })
         return context
 
     def _get_videos(self, url):
             continue
         if not issubclass(view_class, BaseView):
             continue
-        browser = view_class()
+        browser = view_class
         try:
             browser.check()
         except DisableView:

test_project/settings.py

     }
 }
 
+STATIC_URL = ADMINFILES_MEDIA_URL = '/static/'
+STATIC_ROOT = os.path.join(BASE, 'static')
 MEDIA_ROOT = os.path.join(BASE, 'media')
 MEDIA_URL = '/media/'
-ADMIN_MEDIA_PREFIX = '/media/admin/'
+ADMIN_MEDIA_PREFIX = '/static/admin/'
 SECRET_KEY = '6wk#pb((9+oudihdco6m@#1hmr1qp#k+7a=p7c@#z91_^=en-!'
 
 ROOT_URLCONF = 'test_project.urls'
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.sites',
+    'django.contrib.staticfiles',
     'django.contrib.admin',
     'adminfiles',
     'sorl.thumbnail',

test_project/urls.py

 from django.conf.urls.defaults import *
 from django.conf import settings
 
+from django.contrib.staticfiles.urls import staticfiles_urlpatterns
+from django.conf.urls.static import static
+
 from django.contrib import admin
 admin.autodiscover()
 
 )
 
 if settings.DEBUG:
-    urlpatterns += patterns('',
-        (r'^media/(?P<path>.*)$', 'django.views.static.serve',
-            {'document_root': settings.MEDIA_ROOT}),
-    )
+    urlpatterns += staticfiles_urlpatterns()
+    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

tests/test_settings.py

File contents unchanged.
         self.admin.is_superuser = True
         self.admin.is_active = True
         self.admin.save()
-        self.failUnless(self.client.login(username='admin', password='testpw'))
+        self.assertTrue(self.client.login(username='admin', password='testpw'))
         
     def tearDown(self):
         admin.site.unregister(Post)
         response = self.client.get('/adminfiles/all/?field=test')
         self.assertContains(response, 'href="/media/adminfiles/tiny.png"')
         self.assertContains(response, 'href="/media/adminfiles/somefile.txt')
+
+    def test_browser_links(self):
+        """
+        Test correct rendering of browser links.
+
+        """
+        response = self.client.get('/adminfiles/all/?field=test')
+        self.assertContains(response, 'href="/adminfiles/images/?field=test')
             
     def test_images_picker_loads(self):
         response = self.client.get('/adminfiles/images/?field=test')
         response = self.client.get('/adminfiles/all/?field=test')
         image_index = response.content.find('tiny.png')
         file_index = response.content.find('somefile.txt')
-        self.failUnless(image_index > 0)
-        self.failUnless(image_index < file_index)
+        self.assertTrue(image_index > 0)
+        self.assertTrue(image_index < file_index)
 
         settings.ADMINFILES_THUMB_ORDER = _old_order
             
 
         reloaded_post = Post.objects.get(title='Some title')
         
-        self.failUnless('A New Title' in reloaded_post.content)
+        self.assertTrue('A New Title' in reloaded_post.content)
         
 class TemplateTestCase(TestCase):
     """
 
     def test_default_template_renders_image(self):
         html = render_uploads('<<<an-image>>>')
-        self.failUnless('<img src="/media/adminfiles/tiny.png"' in html)
+        self.assertTrue('<img src="/media/adminfiles/tiny.png"' in html)
 
     def test_default_template_renders_image_class(self):
         html = render_uploads('<<<an-image:class=some classes>>>')
-        self.failUnless('class="some classes"' in html)
+        self.assertTrue('class="some classes"' in html)
 
     def test_default_template_renders_image_alt(self):
         html = render_uploads('<<<an-image:alt=the alt text>>>')
-        self.failUnless('alt="the alt text"' in html)
+        self.assertTrue('alt="the alt text"' in html)
 
     def test_default_template_renders_image_title_as_alt(self):
         html = render_uploads('<<<an-image>>>')
-        self.failUnless('alt="An image"' in html)
+        self.assertTrue('alt="An image"' in html)
 
     def test_default_template_renders_link(self):
         html = render_uploads('<<<some-file>>>')
-        self.failUnless('<a href="/media/adminfiles/somefile.txt"' in html)
+        self.assertTrue('<a href="/media/adminfiles/somefile.txt"' in html)
         
     def test_default_template_renders_link_class(self):
         html = render_uploads(u'<<<some-file:class=other classes>>>')
-        self.failUnless('class="other classes"' in html)
+        self.assertTrue('class="other classes"' in html)
 
     def test_default_template_renders_link_title(self):
         html = render_uploads('<<<some-file>>>')
-        self.failUnless('Some file' in html)
+        self.assertTrue('Some file' in html)
 
     def test_default_template_renders_link_title(self):
         html = render_uploads('<<<some-file:title=Other name>>>')
-        self.failUnless('Other name' in html)
+        self.assertTrue('Other name' in html)
 
     def test_template_override(self):
         html = render_uploads('<<<an-image:as=default>>>')
-        self.failUnless('<a href="/media/adminfiles/tiny.png"' in html)
+        self.assertTrue('<a href="/media/adminfiles/tiny.png"' in html)
 
     def test_template_override_fallback(self):
         html = render_uploads('<<<some-file:as=image/jpeg>>>')
-        self.failUnless('<img src="/media/adminfiles/somefile.txt"' in html)
+        self.assertTrue('<img src="/media/adminfiles/somefile.txt"' in html)
 
     def test_template_override_with_nonexisting(self):
         html = render_uploads('<<<an-image:as=some/wonky>>>')
-        self.failUnless('<a href="/media/adminfiles/tiny.png"' in html)
+        self.assertTrue('<a href="/media/adminfiles/tiny.png"' in html)
 
     def test_render_uploads_template_filter(self):
         tpl = template.Template(u'{% load adminfiles_tags %}'
                                  content=u'<<<some-file>>>')}))
         self.assertEquals(self.templates[1].name,
                           'adminfiles/render/default.html')
-        self.failUnless('<a href' in html)
+        self.assertTrue('<a href' in html)
 
     def test_render_uploads_template_filter_alt_template(self):
         tpl = template.Template(
         html = tpl.render(template.Context({'img': self.animage}))
         self.assertEquals(self.templates[1].name,
                           'adminfiles/render/image/default.html')
-        self.failUnless('<img src' in html)
+        self.assertTrue('<img src' in html)
 
     def test_render_upload_template_filter_options(self):
         tpl = template.Template('{% load adminfiles_tags %}'
                                 '{{ img|render_upload:"alt=blah" }}')
         html = tpl.render(template.Context({'img': self.animage}))
-        self.failUnless('alt="blah"' in html)
+        self.assertTrue('alt="blah"' in html)
 
     def test_render_upload_template_filter_alt_template(self):
         tpl = template.Template(
             u'{{ f|render_upload:"template_path=alt:class=yo" }}')
         html = tpl.render(template.Context({'f': self.somefile}))
         self.assertEquals(self.templates[1].name, 'alt/default.html')
-        self.failUnless('class="yo"' in html)
+        self.assertTrue('class="yo"' in html)