1
2

I'm trying to accomplish two task:

  1. Take some action when a question is posted.
  2. 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?

asked 13 Aug '11, 15:28

flowx's gravatar image

flowx
21125
accept rate: 0%


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
  • map URLs
  • 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 forum.views.admin.admin_tools_page and forum.views.admin.admin_page

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.

link

answered 13 Aug '11, 18:33

Jordan's gravatar image

Jordan ♦♦
3.4k619
accept rate: 40%

Perfect, very clean answer and suggested solution, much thanks.

(13 Aug '11, 19:36) flowx
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×12

Asked: 13 Aug '11, 15:28

Seen: 1,630 times

Last updated: 13 Aug '11, 19:41

powered by OSQA