INCF / biostar-central

DEPRECATED, please go to upstream on
http://github.com/ialbert/biostar-central
Other
4 stars 4 forks source link

Fix comments (post.edit.actions.html) #6

Closed brainstorm closed 10 years ago

brainstorm commented 10 years ago

Right now trying to post comments in neurostars results in the following (example) 404:

http://neurostars.org/new/comment/f2qIJx936eyyzGhioTajkxmlx10hGeGb/

Additionally, clicking repeatedly on "comment" generates several div=edit-action sections.

I suspect that Django's CSRF is getting in the way:

https://docs.djangoproject.com/en/1.6/ref/contrib/csrf/

Although it is correctly enabled in MIDDLEWARE_CLASSES in settings.py via 'django.middleware.csrf.CsrfViewMiddleware',...

@ialbert, sorry to bother you again, but if you have some insight in this matter, it would be very appreciated :)

ialbert commented 10 years ago

ok, this is a bit more complicated to fix, this is very likely due to modification of the HTML body, the javascript code needs a well defined nesting and order of element so that it is able to detect where to create the comment box. The javascript function that triggers will navigate relative to the element that is clicked and inserts the comment box.

I am traveling in the next few days so I can't look at it until later

brainstorm commented 10 years ago

Aha, thanks a lot @ialbert for the pointers!

Now I'm getting suspicious on the {browserid_js} include, it might have crippled some of the javascript nesting in main/server/templates/base.html...

ialbert commented 10 years ago

the browserid should not be the problem, the divs have to be nested and need to be named properly. Investigate the html structure before and after your edits

ialbert commented 10 years ago

it is actually simpler than I recalled, I took a look, this is the javascript that is responsible for the commenting

https://github.com/ialbert/biostar-central/blob/master/main/static/js/comment.js

this integrates with the html at

https://github.com/ialbert/biostar-central/blob/master/main/server/templates/widgets/post.edit.actions.html'

see how it needs to extract the post.id from the hidden input, in your case you seem to be passing the csfr token instead of the post.id into the submit action

brainstorm commented 10 years ago

Thanks a lot @ialbert for your input, I just fixed it, that was a weird one in commit https://github.com/brainstorm/biostar-central/commit/5cb6d84ec600eebc0a3a943d146a5b4b0789f9da

I don't understand how your site generates the display:none div with no additional code, since that widget is the same in both sites :-?

@satra, time to test :+1:

satra commented 10 years ago

@brainstorm - happy to test - should i be creating a new account? or can you link to incf or orcid?

brainstorm commented 10 years ago

It runs with Mozilla Persona, which accepts any arbitrary email account:

http://www.mozilla.org/en-US/persona/

If it's Gmail or Yahoo email account it's even easier (you only have to accept an OAuth token).

ialbert commented 10 years ago

the csfr_token should be rendered as a hidden input by default, this is a django internal template tag (maybe they changed it in 1.6) -