I'm trying to accomplish two task:
Take some action when a question is posted.
Add a custom form to the admin section of osqa.
To accomplish the first task I've modified the forum.views.writes "ask" function. Is there a better way to do this? Can I use a post_save signal for example?
Answer by jordan · Aug 13, 2011 at 06:33 PM
For sure there is a better way to extend OSQA than to edit the source code of the core. This approach will not allow you to update to the latest trunk version smoothly in future. For the purpose a separate package called
forum.modules exists and for better integration you should consider using it.
All OSQA modules are located in the forum_modules folder in the root of your installation. There is a bunch of modules you can use for a base and main learning resource during development. Modules allow you to:
create and override views
define new Django models
create and override OSQA templates
register authentication providers
define new settings objects
...and basically to completely modify your installations behavior
For the task you're trying to implement I would suggest you taking a look at the sximporter, updates and exporter modules. Consider using the decorators from the forum.views package and specifically
If you want to trigger a specific action after a question has been added, just create a startup.py file in your module root directory, import the AskAction and hook the function you need executed with a syntax similar to the one in the forum.subscriptions package.
You can also use decorators. I would say that you have a ready to use example in forum_modules.akismet.startup where the ask view is getting decorated.
And you can disable your module anytime. Just edit the DISABLED_MODULES setting from local_settings.py.