techcollective/issuetest — Issue #104: ajax_select can_add isn't thread safe
Author: 3point2
Created: 2012-01-16 16:10:32+00:00
State: open

see #93 for how this started. the django admin always renders a green + regardless of user permissions.

ajax_select wants to be smart and hide it if it's not applicable.

i could either copy the admin approach (which would actually help keep things consistent and be nice and easy), or fix the ajax_select code to do this in a thread safe way.

storing can_add on the widget instance has to go.

the correct approach would be to have the widget always calculate the add URL, and leave it up to the template to show the green + or not by calling a template tag (i think the form, model and current user are all available in the widget template (autocompleteselect.html), and those are what the check_can_add function needs).

the template tag could then do this in a thread safe way (i'm not sure if render_context will have to be used or not, i'll have to read http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/#thread-safety-considerations again)

probably the best way to go for now is simply always show the + like the rest of the site. if the admin gets smarter or if i move away from it (#103), i can reconsider.