[Mpuls-commits] r104 - in waska/trunk: . waskaweb/lib waskaweb/model waskaweb/templates/start
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat Aug 30 15:34:08 CEST 2008
Author: torsten
Date: 2008-08-30 15:34:06 +0200 (Sat, 30 Aug 2008)
New Revision: 104
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/lib/security.py
waska/trunk/waskaweb/model/news.py
waska/trunk/waskaweb/model/user.py
waska/trunk/waskaweb/templates/start/start.mako
Log:
Implemented listing news based on last logintime
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2008-08-29 16:35:38 UTC (rev 103)
+++ waska/trunk/ChangeLog.txt 2008-08-30 13:34:06 UTC (rev 104)
@@ -1,3 +1,14 @@
+2008-08-30 Torsten Irlaender <torsten.irlaender at intevation.de>
+
+ Implemented listing news based on last logintime
+
+ * waskaweb/model/news.py,
+ waskaweb/model/user.py,
+ waskaweb/lib/security.py,
+ waskaweb/templates/start/start.mako: News are now listed for 3 days
+ after the last login. TODO: Check why set_last_logintime function
+ does not set the logindate.
+
2008-08-29 Torsten Irlaender <torsten.irlaender at intevation.de>
Added newslisting on startpage.
Modified: waska/trunk/waskaweb/lib/security.py
===================================================================
--- waska/trunk/waskaweb/lib/security.py 2008-08-29 16:35:38 UTC (rev 103)
+++ waska/trunk/waskaweb/lib/security.py 2008-08-30 13:34:06 UTC (rev 104)
@@ -57,8 +57,8 @@
check_re = re.compile(r"^[a-z_0-9]+$")
ROLE_SQL = """select groname from pg_group where getOID() = ANY (grolist)"""
ROLE_SQL = """select where getOID() = ANY (grolist)"""
-FETCH_USER_DATA_SQL = """SELECT id, vorname, nachname, passwort_aendern, aktiviert, rolle, gid from ka_benutzer_tbl_view WHERE login = %(login)s"""
-
+FETCH_USER_DATA_SQL = """SELECT id, vorname, nachname, passwort_aendern, aktiviert, rolle, gid, last_login from ka_benutzer_tbl_view WHERE login = %(login)s"""
+UPDATE_LASTLOGIN_SQL = """SELECT set_last_logintime(%(user_id)s)"""
UNAUTHORIZED_DETAIL = \
"""Sie sind nicht authorisiert, das angeforderte Dokument anzuschauen.
"""
@@ -102,17 +102,19 @@
try:
result = cursor.fetchone()
data = {}
- data['id'] = result[0]
- data['firstname'] = unicode(str(result[1]), 'utf-8')
- data['lastname'] = unicode(str(result[2]), 'utf-8')
- data['newpass'] = result[3]
- data['activated'] = result[4]
- data['role'] = unicode(str(result[5]), 'utf-8')
- data['gid'] = result[6]
+ data['id'] = result[0]
+ data['firstname'] = unicode(str(result[1]), 'utf-8')
+ data['lastname'] = unicode(str(result[2]), 'utf-8')
+ data['newpass'] = result[3]
+ data['activated'] = result[4]
+ data['role'] = unicode(str(result[5]), 'utf-8')
+ data['gid'] = result[6]
+ data['last_login'] = result[7]
except:
data = None
finally:
db.recycleConnection(conn, cursor)
+
try:
from waskaweb.model.user import SessionUser, SessionSuperAdmin
if data:
@@ -122,10 +124,24 @@
userobject = SessionSuperAdmin(login, password)
else:
return None
+ # UPDATE last login time
+ try:
+ cursor = conn.cursor()
+ if data:
+ try:
+ fields = {'user_id': data.get('id')}
+ cursor.execute(UPDATE_LASTLOGIN_SQL, fields)
+ except StandardError, err:
+ traceback.print_exc(file=sys.stderr)
+ print "Error on setting last logintime: %s" % cursor.query
+ finally:
+ db.recycleConnection(conn, cursor)
+ except StandardError, err:
+ traceback.print_exc(file=sys.stderr)
+ print "Error on creating user Object: %s" % err
+
+ #RETURN userobject
return userobject
- except StandardError, err:
- traceback.print_exc(file=sys.stderr)
- print "Error on creating user Object: %s" % err
finally:
leave(mydb)
mydb.closeConnections()
Modified: waska/trunk/waskaweb/model/news.py
===================================================================
--- waska/trunk/waskaweb/model/news.py 2008-08-29 16:35:38 UTC (rev 103)
+++ waska/trunk/waskaweb/model/news.py 2008-08-30 13:34:06 UTC (rev 104)
@@ -33,7 +33,7 @@
import sys
from waskaweb.lib.db import db
-FETCH_ALL_NEWS = """SELECT id, datum, titel, nachricht, art_beschreibung FROM ka_nachrichten_tbl_view order by datum desc"""
+FETCH_ALL_NEWS = """SELECT id, datum, titel, nachricht, art_beschreibung FROM ka_nachrichten_tbl_view WHERE datum + interval '3 day' >= %(last_login)s order by datum desc"""
class NewsFactory:
def __init__(self):
@@ -50,7 +50,7 @@
try:
conn = db.getConnection()
cur = conn.cursor()
- cur.execute(FETCH_ALL_NEWS)
+ cur.execute(FETCH_ALL_NEWS, {'last_login': user.last_login})
for row in cur.fetchall():
self.list.append(factory.createByData(id=row[0], date=row[1], title=row[2], text=row[3], type=row[4]))
finally:
Modified: waska/trunk/waskaweb/model/user.py
===================================================================
--- waska/trunk/waskaweb/model/user.py 2008-08-29 16:35:38 UTC (rev 103)
+++ waska/trunk/waskaweb/model/user.py 2008-08-30 13:34:06 UTC (rev 104)
@@ -26,11 +26,12 @@
from waskaweb.lib.db import db
from pylons import config, session
+import datetime
import sys
FETCH_USER_LIST_SQL = """SELECT id, vorname, nachname, rolle, login, gid from ka_benutzer_tbl_view order by nachname"""
FETCH_USERGROUP_LIST_SQL = """SELECT id, name from ka_benutzergruppe_tbl_view order by name"""
FETCH_USERGROUP_DATA_SQL = """SELECT id, name from ka_benutzergruppe_tbl_view WHERE id = %(id)s"""
-FETCH_USER_DATA_SQL = """SELECT id, vorname, nachname, telefon, aktiviert, passwort_aendern, login, raumnummer, filiale, usesysid, vertreter, rolle, gid from ka_benutzer_tbl_view WHERE id = %s"""
+FETCH_USER_DATA_SQL = """SELECT id, vorname, nachname, telefon, aktiviert, passwort_aendern, login, raumnummer, filiale, usesysid, vertreter, rolle, gid, last_login from ka_benutzer_tbl_view WHERE id = %s"""
FETCH_USER_SYS_ID_SQL = """SELECT usesysid FROM pg_user WHERE usename = '%s'"""
STORE_USERGROUP_DATA_SQL = """UPDATE ka_benutzergruppe_tbl_view SET name = %(name)s WHERE id = %(id)s"""
CREATE_USERGROUP_DATA_SQL = """SELECT create_benutzergruppe_ds(%(name)s)"""
@@ -330,6 +331,7 @@
self.activated = data.get('activated', False)
self.needs_passrefresh = data.get('newpass', True)
self.role = data.get('role', '')
+ self.last_login = data.get('last_login') or datetime.now()
class SessionSuperAdmin(User):
def __init__(self, lname, password):
@@ -426,6 +428,7 @@
self.standin = ud[10]
self.role = ud[11]
self.gid = ud[12] # id usergroup of the user
+ self.last_login = ud[13] # timestamp
tok = self.full_login.split('_')
self.login = "_".join(tok[2:])
self.agency = tok[1]
Modified: waska/trunk/waskaweb/templates/start/start.mako
===================================================================
--- waska/trunk/waskaweb/templates/start/start.mako 2008-08-29 16:35:38 UTC (rev 103)
+++ waska/trunk/waskaweb/templates/start/start.mako 2008-08-30 13:34:06 UTC (rev 104)
@@ -35,10 +35,12 @@
<p>Es wurden ${c.num_error_cases} Fallakte(n) mit unvollständigen oder widersprüchlichen Angaben gefunden. Fallakten deren Daten nicht plausibel sind werden in der Auswertung zu Problemen führen. Bitte nutzen Sie die Funktion zum <a href="${h.url_for(controller='/case_overview', action='listBadCases')}">Aufspüren von inkonsistenten Fallakten.</a></p>
</div>
%endif
+ %if c.news.getList():
<div class="news">
<h2>Aktuelle Hinweise</h2>
<%include file="/start/newslist.mako"/>
</div>
+ % endif
<h2>Automatisierte Wiedervorlagen</h2>
<%include file="/start/remindlist.mako"/>
%if h.hasRole('cm_ka'):
More information about the Mpuls-commits
mailing list