[Mpuls-commits] r103 - in waska/trunk: . waskaweb/controllers waskaweb/model waskaweb/public/styles waskaweb/templates/start

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Aug 29 18:35:39 CEST 2008


Author: torsten
Date: 2008-08-29 18:35:38 +0200 (Fri, 29 Aug 2008)
New Revision: 103

Added:
   waska/trunk/waskaweb/model/news.py
   waska/trunk/waskaweb/templates/start/newslist.mako
Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/controllers/waska.py
   waska/trunk/waskaweb/public/styles/all.css
   waska/trunk/waskaweb/templates/start/start.mako
Log:
Added newslisting on startpage.


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-08-28 14:08:46 UTC (rev 102)
+++ waska/trunk/ChangeLog.txt	2008-08-29 16:35:38 UTC (rev 103)
@@ -1,3 +1,14 @@
+2008-08-29	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Added newslisting on startpage.
+
+	* waskaweb/model/news.py,
+	  waskaweb/controllers/waska.py,
+	  waskaweb/public/styles/all.css,
+	  waskaweb/templates/start/start.mako,
+	  waskaweb/templates/start/newslist.mako: New template and style for
+	  newslisting. Added new model for news. 
+
 2008-08-28  Sascha L. Teichmann <sascha.teichmann at intevation.de>
 
 	* waskaweb/lib/needed.py: Open help in new window. using parent's

Modified: waska/trunk/waskaweb/controllers/waska.py
===================================================================
--- waska/trunk/waskaweb/controllers/waska.py	2008-08-28 14:08:46 UTC (rev 102)
+++ waska/trunk/waskaweb/controllers/waska.py	2008-08-29 16:35:38 UTC (rev 103)
@@ -35,6 +35,7 @@
 from waskaweb.lib.security import checkLogin, userIdentity, generateID, checkRole
 from waskaweb.model.user   import UserObject
 from waskaweb.model.case   import CaseOverview
+from waskaweb.model.news   import NewsList
 from waskaweb.model.appointment import MaxSaveTimeReminderOverview, \
                                        CaseAppointmentOverview, \
                                        GlobalAppointmentOverview, \
@@ -52,6 +53,7 @@
 
     @checkRole(('admin_ka', 'cm_ka', 'pb_ka', 'pt_dlr'))
     def start(self):
+        user = session['USER_AUTHORIZED']
         if config['evaluation_server'] == '1': 
         # On evaluation server do not try to find out which cases are saved
         # longer than allowed. This would be a real performance killer and
@@ -80,8 +82,10 @@
                 c.appointmentlist = caseapp
             c.globalappointmentlist = globalapp
 
+            # LOAD NEWS
+            c.news = NewsList(user)
+
         #find out if there are cases with errors
-        user = session['USER_AUTHORIZED']
         search_str = "state:1;state:2;state:3;state:4;state:5;bad:1;bad:2;bad:3;bad:4;bad:5;bad:6;own:%s" % user.id
         c.num_error_cases = len(CaseOverview().search(search_str))
         if c.num_error_cases > 0:

Added: waska/trunk/waskaweb/model/news.py
===================================================================
--- waska/trunk/waskaweb/model/news.py	2008-08-28 14:08:46 UTC (rev 102)
+++ waska/trunk/waskaweb/model/news.py	2008-08-29 16:35:38 UTC (rev 103)
@@ -0,0 +1,70 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
+# 
+# This file is part of mpuls WASKA (CoMPUter-based case fiLeS - 
+# Web-Anwendungs-Server fuer Kompetenzagenturen).
+# 
+# mpuls WASKA is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+# 
+# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
+# License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public
+# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
+# 
+# mpuls WASKA has been developed on behalf of the 
+# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
+# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
+# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and 
+# European Social Fund resources.
+#
+# Authors:
+# Torsten Irländer <torsten.irlaender at intevation.de>
+#
+import psycopg2.extras
+import os
+import traceback
+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"""
+
+class NewsFactory:
+    def __init__(self):
+        pass
+
+    def createByData(self, **attr):
+        return News(**attr)
+
+class NewsList:
+    '''List of news objects for the given user'''
+    def __init__(self, user):
+        self.list = []
+        factory = NewsFactory()
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            cur.execute(FETCH_ALL_NEWS)
+            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:
+            db.recycleConnection(conn, cur)
+
+    def getList(self):
+        return self.list
+
+class News:
+    def __init__(self, id=None, date=None, title=None, text=None, type=None):
+        self.id    = id
+        self.date  = date
+        self.title = title
+        self.text  = text
+        self.type  = type
+
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:

Modified: waska/trunk/waskaweb/public/styles/all.css
===================================================================
--- waska/trunk/waskaweb/public/styles/all.css	2008-08-28 14:08:46 UTC (rev 102)
+++ waska/trunk/waskaweb/public/styles/all.css	2008-08-29 16:35:38 UTC (rev 103)
@@ -7,6 +7,7 @@
 /*    3.2 Administration	*/
 /* 4. Grouping form elements 	*/
 /* 5. Appointments 		*/
+/* 6. News 			*/
 /*------------------------------*/
 
 
@@ -455,3 +456,39 @@
 	padding: 1.5em;
 }
 
+/*----------------------*/
+/* News			*/
+/*----------------------*/
+
+table.news {
+	margin: 0.3em 0.5em 0.3em 0.5em;
+}
+
+table.news td.date {
+	font-weight: bold;
+	text-align: left;
+	background : #D5D5D5;
+	width: 7em;
+}
+
+table.news td.action {
+	font-weight: normal;
+	text-align: right;
+	background : #D5D5D5;
+	width: 15em;
+}
+
+table.news td.title {
+	font-weight: bold;
+	text-align: left;
+	background : #D5D5D5;
+}
+
+table.news td.message {
+	background: #FFF;
+	padding: 2.5 !important; /* would be overwritten by global td-setting */
+}
+
+div.news {
+	margin-bottom: 1em;
+}

Added: waska/trunk/waskaweb/templates/start/newslist.mako
===================================================================
--- waska/trunk/waskaweb/templates/start/newslist.mako	2008-08-28 14:08:46 UTC (rev 102)
+++ waska/trunk/waskaweb/templates/start/newslist.mako	2008-08-29 16:35:38 UTC (rev 103)
@@ -0,0 +1,16 @@
+## -*- coding: utf-8 -*-
+<%!  import waskaweb.lib.filters as F %>
+%for news in c.news.getList():
+  <table class="news">
+    <tr>
+      <td class="date table_header_h">${h.dd_mm_YYYY(news.date)}</td>
+      <td class="title table_header_h">${news.title}</td>
+      <td class="action table_header_h"></td>
+    </tr>
+    <tr>
+      <td class="message" colspan="3">
+          ${news.text} 
+      </td>
+    </tr>
+  </table>
+%endfor

Modified: waska/trunk/waskaweb/templates/start/start.mako
===================================================================
--- waska/trunk/waskaweb/templates/start/start.mako	2008-08-28 14:08:46 UTC (rev 102)
+++ waska/trunk/waskaweb/templates/start/start.mako	2008-08-29 16:35:38 UTC (rev 103)
@@ -35,6 +35,10 @@
         <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
+    <div class="news">
+      <h2>Aktuelle Hinweise</h2>
+      <%include file="/start/newslist.mako"/>
+    </div>
     <h2>Automatisierte Wiedervorlagen</h2>
     <%include file="/start/remindlist.mako"/>
     %if h.hasRole('cm_ka'):



More information about the Mpuls-commits mailing list