website updates and fix to sessions

This commit is contained in:
Rushabh Mehta 2012-12-19 10:14:58 +05:30
parent cedc481fd0
commit d3410a25b9
2 changed files with 19 additions and 7 deletions

View file

@ -133,14 +133,14 @@ wn.get_shade = function(color, factor) {
var get_int = function(hex) {
return parseInt(hex,16);
}
return get_hex(get_int(color.substr(0,2)) * factor)
+ get_hex(get_int(color.substr(2,2)) * factor)
+ get_hex(get_int(color.substr(4,2)) * factor)
return get_hex(get_int(color.substr(0,2)) + factor)
+ get_hex(get_int(color.substr(2,2)) + factor)
+ get_hex(get_int(color.substr(4,2)) + factor)
}
wn.get_gradient_css = function(col) {
var col1 = wn.get_shade(col, 1.05);
var col2 = wn.get_shade(col, 0.95);
var col1 = wn.get_shade(col, 10);
var col2 = wn.get_shade(col, -10);
return "\nbackground-color: " + col + " !important;"
+"\nbackground: -moz-linear-gradient(top, #"+col1+" 0%, #"+col2+" 99%) !important;"
+"\nbackground:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#"+col1+"), color-stop(99%,#"+col2+")) !important;"

View file

@ -208,12 +208,24 @@ class Session:
"""extend session expiry"""
self.data['data']['last_updated'] = webnotes.utils.now()
if webnotes.session['user'] != 'Guest' and (self.time_diff and \
self.time_diff > 1800):
# update session in db
time_diff = None
last_updated = webnotes.cache().get_value("last_db_session_update:" + self.sid)
if last_updated:
time_diff = webnotes.utils.time_diff_in_seconds(webnotes.utils.now(),
last_updated)
if webnotes.session['user'] != 'Guest' and \
((not time_diff) or (time_diff > 1800)):
# database persistence is secondary, don't update it too often
webnotes.conn.sql("""update tabSessions set sessiondata=%s,
lastupdate=NOW() where sid=%s""" , (str(self.data['data']),
self.data['sid']))
# update timestamp of update
webnotes.cache().set_value("last_db_session_update:" + self.sid,
webnotes.utils.now())
if webnotes.request.cmd!="webnotes.sessions.clear":
webnotes.cache().set_value("session:" + self.sid, self.data)