mit-eecs / issue-tracker

Scripts Issue Tracker
0 stars 0 forks source link

No feedback when uploading data #59

Closed samanamarasinghe closed 11 years ago

samanamarasinghe commented 11 years ago

When data file is uploaded from eduoffice->setup there is no feedback, the page refreshes. Not even sure if the data file gets uploaded.

samanamarasinghe commented 11 years ago

I tried to debug it (changed from just a submit to a javascript call submit1) but still have bugs. Can you take a look?

pluskid commented 11 years ago

@samanamarasinghe I'm confused how is this feature working before? Because after some googling, I think that jQuery AJAX cannot post a form containing a file uploading field.

pluskid commented 11 years ago

I found some plugin (http://www.malsup.com/jquery/form/) that support uploading a form with file field (via some iFrame hacking I guess). But our form is kind of dynamically generated (the "submit" field change when you click different buttons), thus it is not easy to use with that plugin. We might need an alternative way to solve this.

samanamarasinghe commented 11 years ago

Strange, it used to work before.

samanamarasinghe commented 11 years ago

What worked before was...

{% csrf_token %} {{ form.as_p }}
pluskid commented 11 years ago

@samanamarasinghe I guess directly submitting should work, but using jquery to submit through AJAX would fail?

samanamarasinghe commented 11 years ago

I put the wrong "previous" code there. Now I restored it (see file). It seems to do the post, but I think to the wrong page (I think might be to the top page instead of setup page). Now sure how to fix this.... Do you have a better idea of what is going on?

pluskid commented 11 years ago

The HTML form can be specified with an action attribute indicating where we want to submit to. I tried to modify that, and I think now the submitting works (use the first-row buttons there). However, in order to get back to the setup page after submitting, I added an explicit HTTPRedirect in the views.py for the setup function when the request is a POST. This should be OK for all the buttons that uploading a files. But I noticed there CalcAve and UpdatePay also under POST. I'm not sure whether they are OK with the HTTPRedirect.

pluskid commented 11 years ago

fixed in revision 289.