summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2008-04-07 00:55:50 +0200
committerGuillaume Seguin <guillaume@segu.in>2008-04-07 00:55:50 +0200
commit4e25007b4fbac2b0b3e9fe94a2ff878e949810b9 (patch)
treefdf2d02ff969a19c27f2a6a212af6287d28181de
parent802fa51031b40f3fca82261b00717d2b0c429638 (diff)
downloadmarks-4e25007b4fbac2b0b3e9fe94a2ff878e949810b9.tar.gz
marks-4e25007b4fbac2b0b3e9fe94a2ff878e949810b9.tar.bz2
* Add set_user_data, reset_user_data and improve get_user_data helper
-rw-r--r--main/shared.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/main/shared.py b/main/shared.py
index d36abce..6be5645 100644
--- a/main/shared.py
+++ b/main/shared.py
@@ -20,14 +20,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.template import RequestContext, loader
from django.http import HttpResponse, HttpResponseRedirect
from django import newforms as forms
-from django.utils.translation import ugettext as _
+
+def make_initial_user_data ():
+ '''Builds a basic dict handling user data'''
+ return {
+ "exams": [],
+ "ratings": {},
+ "marks": {},
+ }
def get_user_data (request):
'''Fetch user data from Session'''
if "user_data" in request.session:
return request.session["user_data"]
else:
- return None
+ return make_initial_user_data ()
+
+def set_user_data (request, data):
+ '''Set user data'''
+ request.session["user_data"] = data
+
+def reset_user_data (request):
+ '''Reset user data'''
+ if "user_data" in request.session:
+ del request.session["user_data"]
def get_header (request):
'''Get the header'''