dokterbob/django-portfolio — pull request #4 by littlepea (2013-03-19 10:03:13+00:00)
Title: Added pluggable Editor functionality

This fixes #1

I did as you suggested, took your django-newsletter code and used almost exactly the same approach.

A few things I did differently for some reason:

1. I moved all that import magic into a separate file editor.py so it's doesn't create a mess in admin.py

2. I don't just check importability but also if 'imperavi' or 'tinymce is in INSTALLED_APPS. Bacause first of all non of them would work anyway if they are not in INSTALLED_APPS and urls.py, and second - this way it's possible to write tests for this whole functionality. Otherwise it's practically impossible, or the test could cover only one of 3 cases: 'imperavi', 'tinymce' or nothing. The way I did it I can test all three cases at the same time.

3. Created my own pluggable class EditorWidget to avoid conditions in admin.py (+ EditorAdmin, EditorStackedAdmin, they can be used with equal success in admin.py)

4. I've also created a separate package https://github.com/littlepea/django-editor that implements all the same functionality and it could be used in portfolio as a dependency instead of editor.py file. But I didn't do it, because I think you didn't want new hard dependencies...

Let me know what you think.