chrisvans / onbaristawebapp

Web App for Baristas to check in when they are on bar
0 stars 1 forks source link

Refactoring the Dictionary that passes messages in views.py, as a method. #44

Closed chrisvans closed 11 years ago

chrisvans commented 11 years ago

Consistent keys and values, changes when necessary via views. Will make reading the code a lot simpler, allow all changes to happen in one place, and prevent conflicts.

chrisvans commented 11 years ago

Simplified some values with methods, so they are no longer locally dependent.

chrisvans commented 11 years ago

Plan to use view_manager within the views.py as a source for all dictionary passing, and appending.

So, we call the database to refresh the user way too often. Is it a good method to constantly pass the user/userdetails variable through the pages until it changes, and only update it then? This is basically a workaround to not using cookies. It sounds like a pain to do, though.

chrisvans commented 11 years ago

Refactored the login_handler so that instead of requesting the user in session in order to validate the user, passing an if statement with it's return value, and then calling the session a second time to populate the user variable, it simple returns the user object into the user variable. If the test fails, it returns 'None' into the user variable, and then user is tested against being None.

This essentially reduces the amount of times the session is called by half, and I don't notice anymore lag on the checkin/checkout buttons.

AJLeonardi commented 11 years ago

moved the login stuff to the view_manager, so that we can get rid of those 3/4 lines from most views -- but now we get 403 instead of login page (which should be fixable).

Also build out the dictionary functionality. basically return the generic stuff, and the view specific stuff I either set like: dict_to_pass = dict(default_dict.items() + this_view_dict.items())

or the natural way of just setting the specific key -- if there are only a couple items for that specific view.