WiseEarthTechnology / CrisisCommunicator

http://WiseEarthTechnology.com
5 stars 7 forks source link

Unable to create "Assess Road" Database #22

Closed tinvaan closed 10 years ago

tinvaan commented 10 years ago

I working on the bug that I had reported earlier but now I've stumbled upon this new issue . Earlier I was able to create a database but unable to delete the same after creation. Now I'm unable to create a "Asses Road" database , let alone delete one .

swiftarrow commented 10 years ago

Interesting... Can anyone verify that this is a regression in the code? Varrun, perhaps :) ?

varrunr commented 10 years ago

Could you please list the exact steps you used to reproduce this issue?

tinvaan commented 10 years ago

Well , I made changes in the assessment/views.py that removed the syntax error that @swiftarrow had pointed out . Then I tried running the app and I faced this error . I then switched to my other git branches and again got the same error. I finally ran a git pull from the repo and once again tried running the application but I still got the same error.

varrunr commented 10 years ago

Can you confirm that this is the same issue you faced? (Note: for future reference - exact steps means, commands, URLs navigated, stacktrace etc.)

  1. Navigate to http://127.0.0.1:8000/crisis

The following stacktrace is observed Environment:

Request Method: GET Request URL: http://127.0.0.1:8000/crisis/

Django Version: 1.4.3 Python Version: 2.7.3 Installed Applications: ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'crisis', 'refugeecenter', 'person', 'assessment', 'resources', 'bootstrap_toolkit', 'haystack') Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware')

Traceback: File "/home/varrunr/.virtualenvs/CrisisComm/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/home/varrunr/CrisisCommunicator/webapp/crisis/views.py" in home
  2. if request.session['loggedInside'] == True: File "/home/varrunr/.virtualenvs/CrisisComm/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in getitem
  3. return self._session[key]

Exception Type: KeyError at /crisis/ Exception Value: 'loggedInside'

varrunr commented 10 years ago

OK, so here is the issue. The app behaves in such a way that once a user logs in, the key "loggedInside" is set to True. On subsequent views, the key "loggedInside" is being checked with the statement

if request.session['loggedInside'] == True: .... ....

If the session is invalidated and the key no longer exists, trying to access the value of that non-existent key generates a KeyError. This must either be

  1. Replaced to
loginVar = request.session.get('loggedInside');
if not (loginVar == None) and loginVar == "True":
....
....

(OR)

  1. Enclosed in an exception handler
try:
    if request.session['loggedInside'] == True:
    .....
    .....
except KeyError:
     return HttpResponseRedirect('/')
varrunr commented 10 years ago

Pushed fix, reopen if issue is different or fix is insufficient.

swiftarrow commented 10 years ago

Varrun, thanks for the detailed explanation!

tinvaan commented 10 years ago

@varrunr , I never encountered the error that you mentioned . Here are the exact steps .

1.Navigate to the project directory/webapp (locally) . 2.Switch to 'bash' (I use zsh) 3.Then run the server by entering the commands (i) workon crisis (ii)python manage.py runserver

4.Navigate to http://127.0.0.1:8000/crisis 5.Click any random point and choose "Assess Road" from the menu that pops up . 6.In the Road Assessment form , the "latitude" and "longitude" are filled in by default . Now fill in the "Assessment Level" and comments. 7.Click on "Enter" 8.Now , I'm navigated to a blank Road Assessment form . Even if I try to fill the form manually , it again redirects me to a blank Road Assessment form . 9.To be doubly sure , I did a git pull using -> "git pull upstream master" where upstream is https://github.com/WiseEarthTechnology/CrisisCommunicator.git

10.I tried running again , following the same procedure mentioned above but I still encounter the same glitch .

I don't get any error messages , I believe it's a bug .

Is anyone else facing this issue ? I hope this was clear enough :)

Thanks

varrunr commented 10 years ago

@harishnavnit Thanks for the clarification, looks like the issue I found was different. I am unable to reproduce the issue as you stated. I followed steps 1-7, but after step 7 I see a balloon created on the map with the info I put into the form, i.e. it does not redirect me to a blank form as you said(screenshot attached). Can you paste the ouput of git reflog and git branch? screen shot 2014-01-05 at 9 37 45 am

However, if I do click on the "Road Assessment" link again, it redirects me to a blank form, which I suspect should not happen. The user must be allowed to "edit" the assessment instead of adding a new one. I'm not sure if @bithin and @seshagiriprabhu implemented an edit feature, have you?

tinvaan commented 10 years ago

Okay , here's the output of "git reflog" : http://pastebin.ubuntu.com/6704232/ and "git branch" : http://pastebin.ubuntu.com/6704272/ .

And No , I could've never implemented an edit feature ! :-)

varrunr commented 10 years ago

Ok since your fix issue #17 was not actually merged into master, it's probably a problem in your branch. From the output of your git reflog, I see you didn't take my suggestion of starting off on a new clone. Can you paste the stack trace of the error you are facing?

tinvaan commented 10 years ago

Oh , I didn't start off from a new clone . What I did was just creating a new git branch and then ran a git pull from upstream master . I thought that would give me the latest code anyway . So , you want me to clone the entire code and build again ??

varrunr commented 10 years ago

Yes, if possible. If you face the same problem on a fresh clone then there is an issue, else it's some change you made that is causing the problem. If you still see an error, paste the stack trace.

On Monday, January 6, 2014, R.Harish Navnit wrote:

Oh , I didn't start off from a new clone . What I did was just creating a new git branch and then ran a git pull from upstream master . I thought that would give me the latest code anyway . So , you want me to clone the entire code and build again ??

— Reply to this email directly or view it on GitHubhttps://github.com/WiseEarthTechnology/CrisisCommunicator/issues/22#issuecomment-31669228 .

Sent from Mobile device, Pardon any typos

tinvaan commented 10 years ago

Sure , I'll try it out ASAP :+1:

tinvaan commented 10 years ago

I did a fresh install on another system and checked the problem . It still exists for me . I'm listing the exact steps here :

test2

1.Navigate to http://127.0.0.1:8000 2.Click on any random point and choose the Road Assessment option from the menu that pops up. 3.Fill the Road Assessment form

blank

P.S : Sometimes when I follow these steps I'm lead back to the running app. Sorry for posting the entire page screenshot , did it in a hurry.

So I guess , there's an Issue .

varrunr commented 10 years ago

Well, I just did a fresh install myself, and I am not facing any issue, I'm able to add a road assessment just fine. It looks like there is no bug. Maybe, @swiftarrow can verify as well. @harishnavnit , what environment are you using - OS, Django, python etc.?

tinvaan commented 10 years ago

Here are the details . OS : Ubuntu 12.04 LTS Python : python 2.7.3

and when I try to check my django version , I get the following error message : http://pastebin.ubuntu.com/6731894/

But ofcourse , django version mentioned in the webapp/requirements.txt is 1.4.3

swiftarrow commented 10 years ago

@harishnavnit are you using virtualenv for Django? I didn't see the virtualenv in that terminal output.

swiftarrow commented 10 years ago

I had just verified that there are no problems creating or deleting Assess Road in Harish's Issue#17 branch.

tinvaan commented 10 years ago

Oh yes , @swiftarrow , thanks for correcting me . I am indeed using virtualenv and now I get the output "1.4.3" , as expected . http://pastebin.ubuntu.com/6732073/

swiftarrow commented 10 years ago

Cool! :thumbsup:

tinvaan commented 10 years ago

Can I close this issue ? Has anyone verified this ?

swiftarrow commented 10 years ago

@Harish, I verified on your ISSUE #17 branch that creating the Assess Road object did work, as did deleting it.

Thanks, Love, Peace, Link

On Sun, Jan 12, 2014 at 7:40 AM, R.Harish Navnit notifications@github.comwrote:

Can I close this issue ? Has anyone verified this ?

— Reply to this email directly or view it on GitHubhttps://github.com/WiseEarthTechnology/CrisisCommunicator/issues/22#issuecomment-32116553 .

tinvaan commented 10 years ago

Thanks . I'm closing this . If any issue pops up , do reopen this :)