[Mpuls-commits] r1494 - in wasko/branches/2.0: mpulsweb/controllers waskaweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 11 08:45:41 CET 2010


Author: torsten
Date: 2010-02-11 08:45:40 +0100 (Thu, 11 Feb 2010)
New Revision: 1494

Added:
   wasko/branches/2.0/mpulsweb/controllers/document.py
Removed:
   wasko/branches/2.0/waskaweb/controllers/document.py
Log:
Moved controller for documents to base.


Copied: wasko/branches/2.0/mpulsweb/controllers/document.py (from rev 1490, wasko/branches/2.0/waskaweb/controllers/document.py)
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/document.py	2010-02-11 07:40:02 UTC (rev 1490)
+++ wasko/branches/2.0/mpulsweb/controllers/document.py	2010-02-11 07:45:40 UTC (rev 1494)
@@ -0,0 +1,169 @@
+# -*- 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:
+# Sascha L. Teichmann <teichmann at intevation.de>
+#
+
+import sys
+import logging
+import traceback
+
+import paste
+from pylons import config
+
+from mpulsweb.lib.security import checkRole
+from mpulsweb.model.document import Document, listDocuments, deleteDocument
+
+from mpulsweb.lib.base import BaseController, c, h, redirect_to, render, request
+
+
+log = logging.getLogger(__name__)
+
+
+SET_DOCUMENT_SUCCESS_HEADER = u"""Dokument hinzugefügt!"""
+SET_DOCUMENT_SUCCESS_TEXT = u"""Bitte klicken Sie auf "OK", um fortzufahren."""
+SET_DOCUMENT_FAILED_HEADER = u"""Kein Dokument hinzugefügt!"""
+SET_DOCUMENT_FAILED_TEXT = u"""\
+Vergewissern Sie sich, ob der angegebene Pfad korrekt ist. Dokumente
+können direkt über den "Browse" bzw. "Durchsuchen" Button ausgewählt werden.
+Bitte klicken Sie auf "OK", um fortzufahren.
+"""
+SET_DOCUMENT_SUCCESS_DELETE_HEADER = u"""Dokument gelöscht! """
+SET_DOCUMENT_SUCCESS_DELETE_TEXT = u"""\
+Bitte klicken Sie auf "OK", um fortzufahren."""
+SET_DOCUMENT_CONFIRM_DELETE_HEADER = u"""Dokument löschen?"""
+SET_DOCUMENT_CONFIRM_DELETE_TEXT = u"""\
+Wollen Sie das Dokument wirklich löschen und die Daten unwiederbringlich
+verlieren?"""
+
+SET_ATTACHMENT_SUCCESS_HEADER = u"""Anlage hinzugefügt!"""
+SET_ATTACHMENT_SUCCESS_TEXT = u"""\
+Bitte klicken Sie auf "OK", um fortzufahren."""
+SET_ATTACHMENT_FAILED_HEADER = u"""Keine Anlage hinzugefügt!"""
+SET_ATTACHMENT_FAILED_TEXT = u"""\
+Vergewissern Sie sich, ob der angegebene Pfad korrekt ist.
+Anlagen können direkt über den "Browse" bzw. "Durchsuchen" Button ausgewählt
+werden. Bitte klicken Sie auf "OK", um fortzufahren."""
+SET_ATTACHMENT_SUCCESS_DELETE_HEADER = u"""Anlage gelöscht!"""
+SET_ATTACHMENT_SUCCESS_DELETE_TEXT = u"""\
+Bitte klicken Sie auf "OK", um fortzufahren."""
+SET_ATTACHMENT_CONFIRM_DELETE_HEADER = u"""Anlage löschen?"""
+SET_ATTACHMENT_CONFIRM_DELETE_TEXT = u"""\
+Wollen Sie die Anlage wirklich löschen und die Daten unwiederbringlich
+verlieren?"""
+
+class DocumentController(BaseController):
+
+    @checkRole(('admin_ka', 'cm_ka'))
+    def index(self):
+        redirect_to(action='globalOverview')
+
+    @checkRole(('admin_ka', 'cm_ka'))
+    def globalOverview(self):
+        try:
+            c.files = listDocuments()
+        except:
+            traceback.print_exc(file=sys.stderr)
+            c.files = []
+            #return render('/tests/trace.mako')
+        return render('/documents/global_overview.mako')
+
+    @checkRole('admin_ka')
+    def globalUpload(self):
+        return render('/documents/global_upload.mako')
+
+    @checkRole('admin_ka')
+    def globalUploadAction(self):
+        try:
+            doc = Document()
+            myfile = None
+            try:
+                myfile = request.POST.get('file')
+                if not myfile is None:
+                    doc.create(myfile.filename, myfile.file)
+                    c.success_for = SET_DOCUMENT_SUCCESS_HEADER
+                    c.success_text = SET_DOCUMENT_SUCCESS_TEXT
+                    c.url_ok = h.url_for(controller="document",
+                                         action="globalOverview")
+                    return render('/documents/dialogs/success_documents.mako')
+            finally:
+                if not myfile is None:
+                    try:
+                        myfile.file.close()
+                    except:
+                        pass
+        except:
+            traceback.print_exc(file=sys.stderr)
+            c.failed_for = SET_DOCUMENT_FAILED_HEADER
+            c.failed_text = SET_DOCUMENT_FAILED_TEXT
+            c.url_ok = h.url_for(controller="document", action="globalUpload")
+            return render('/documents/dialogs/failed_document.mako')
+
+            return self.globalUpload()
+
+
+    @checkRole(('admin_ka', 'cm_ka'))
+    def globalShow(self, id):
+        id = self._checkInt(id)
+        try:
+            document = Document(id)
+            document.load()
+            data = paste.fileapp.DataApp(document.data,
+                                         content_type=document.mime,
+                                         cache_control='must-revalidate',
+                                         pragma='public')
+            return data(request.environ, self.start_response)
+        except:
+            traceback.print_exc(file=sys.stderr)
+            redirect_to(controller="case", action="documents", id=case)
+            #return render('/tests/trace.mako')
+
+    @checkRole('admin_ka')
+    def globalDelete(self, id, confirmed='0'):
+        id = self._checkInt(id)
+        confirmed = self._checkBool(confirmed)
+        if confirmed == 1:
+            try:
+                deleteDocument(id)
+            except:
+                traceback.print_exc(file=sys.stderr)
+                return self.globalOverview()
+                #return render('/tests/trace.mako')
+            c.url_ok = h.url_for(controller="/document",
+                                 action="globalOverview")
+            c.success_for = SET_DOCUMENT_SUCCESS_DELETE_HEADER
+            c.success_text = SET_DOCUMENT_SUCCESS_DELETE_TEXT
+            return render('/documents/dialogs/delete_document_success.mako')
+        else:
+            c.context = "../main.mako"
+            c.confirm_for = SET_DOCUMENT_CONFIRM_DELETE_HEADER
+            c.question = SET_DOCUMENT_CONFIRM_DELETE_TEXT
+            c.url_yes = "/document/globalDelete/%d/1" % id
+            c.url_no = "/document/globalOverview/"
+            return render('/documents/dialogs/confirm.mako')
+
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:


Property changes on: wasko/branches/2.0/mpulsweb/controllers/document.py
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: wasko/branches/2.0/waskaweb/controllers/document.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/document.py	2010-02-11 07:41:16 UTC (rev 1493)
+++ wasko/branches/2.0/waskaweb/controllers/document.py	2010-02-11 07:45:40 UTC (rev 1494)
@@ -1,171 +0,0 @@
-# -*- 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:
-# Sascha L. Teichmann <teichmann at intevation.de>
-#
-
-import sys
-import logging
-import traceback
-
-import paste
-from pylons import config
-
-from mpulsweb.lib.security import checkRole
-from mpulsweb.model.document import Document, listDocuments, deleteDocument
-
-from waskaweb.lib.base import BaseController, c, h, redirect_to, render, request
-
-
-log = logging.getLogger(__name__)
-
-
-SET_DOCUMENT_SUCCESS_HEADER = u"""Dokument hinzugefügt!"""
-SET_DOCUMENT_SUCCESS_TEXT = u"""Bitte klicken Sie auf "OK", um fortzufahren."""
-SET_DOCUMENT_FAILED_HEADER = u"""Kein Dokument hinzugefügt!"""
-SET_DOCUMENT_FAILED_TEXT = u"""\
-Vergewissern Sie sich, ob der angegebene Pfad korrekt ist. Dokumente
-können direkt über den "Browse" bzw. "Durchsuchen" Button ausgewählt werden.
-Bitte klicken Sie auf "OK", um fortzufahren.
-"""
-SET_DOCUMENT_SUCCESS_DELETE_HEADER = u"""Dokument gelöscht! """
-SET_DOCUMENT_SUCCESS_DELETE_TEXT = u"""\
-Bitte klicken Sie auf "OK", um fortzufahren."""
-SET_DOCUMENT_CONFIRM_DELETE_HEADER = u"""Dokument löschen?"""
-SET_DOCUMENT_CONFIRM_DELETE_TEXT = u"""\
-Wollen Sie das Dokument wirklich löschen und die Daten unwiederbringlich
-verlieren?"""
-
-SET_ATTACHMENT_SUCCESS_HEADER = u"""Anlage hinzugefügt!"""
-SET_ATTACHMENT_SUCCESS_TEXT = u"""\
-Bitte klicken Sie auf "OK", um fortzufahren."""
-SET_ATTACHMENT_FAILED_HEADER = u"""Keine Anlage hinzugefügt!"""
-SET_ATTACHMENT_FAILED_TEXT = u"""\
-Vergewissern Sie sich, ob der angegebene Pfad korrekt ist.
-Anlagen können direkt über den "Browse" bzw. "Durchsuchen" Button ausgewählt
-werden. Bitte klicken Sie auf "OK", um fortzufahren."""
-SET_ATTACHMENT_SUCCESS_DELETE_HEADER = u"""Anlage gelöscht!"""
-SET_ATTACHMENT_SUCCESS_DELETE_TEXT = u"""\
-Bitte klicken Sie auf "OK", um fortzufahren."""
-SET_ATTACHMENT_CONFIRM_DELETE_HEADER = u"""Anlage löschen?"""
-SET_ATTACHMENT_CONFIRM_DELETE_TEXT = u"""\
-Wollen Sie die Anlage wirklich löschen und die Daten unwiederbringlich
-verlieren?"""
-
-
-
-class DocumentController(BaseController):
-
-    @checkRole(('admin_ka', 'cm_ka'))
-    def index(self):
-        redirect_to(action='globalOverview')
-
-    @checkRole(('admin_ka', 'cm_ka'))
-    def globalOverview(self):
-        try:
-            c.files = listDocuments()
-        except:
-            traceback.print_exc(file=sys.stderr)
-            c.files = []
-            #return render('/tests/trace.mako')
-        return render('/documents/global_overview.mako')
-
-    @checkRole('admin_ka')
-    def globalUpload(self):
-        return render('/documents/global_upload.mako')
-
-    @checkRole('admin_ka')
-    def globalUploadAction(self):
-        try:
-            doc = Document()
-            myfile = None
-            try:
-                myfile = request.POST.get('file')
-                if not myfile is None:
-                    doc.create(myfile.filename, myfile.file)
-                    c.success_for = SET_DOCUMENT_SUCCESS_HEADER
-                    c.success_text = SET_DOCUMENT_SUCCESS_TEXT
-                    c.url_ok = h.url_for(controller="document",
-                                         action="globalOverview")
-                    return render('/documents/dialogs/success_documents.mako')
-            finally:
-                if not myfile is None:
-                    try:
-                        myfile.file.close()
-                    except:
-                        pass
-        except:
-            traceback.print_exc(file=sys.stderr)
-            c.failed_for = SET_DOCUMENT_FAILED_HEADER
-            c.failed_text = SET_DOCUMENT_FAILED_TEXT
-            c.url_ok = h.url_for(controller="document", action="globalUpload")
-            return render('/documents/dialogs/failed_document.mako')
-
-            return self.globalUpload()
-
-
-    @checkRole(('admin_ka', 'cm_ka'))
-    def globalShow(self, id):
-        id = self._checkInt(id)
-        try:
-            document = Document(id)
-            document.load()
-            data = paste.fileapp.DataApp(document.data,
-                                         content_type=document.mime,
-                                         cache_control='must-revalidate',
-                                         pragma='public')
-            return data(request.environ, self.start_response)
-        except:
-            traceback.print_exc(file=sys.stderr)
-            redirect_to(controller="case", action="documents", id=case)
-            #return render('/tests/trace.mako')
-
-    @checkRole('admin_ka')
-    def globalDelete(self, id, confirmed='0'):
-        id = self._checkInt(id)
-        confirmed = self._checkBool(confirmed)
-        if confirmed == 1:
-            try:
-                deleteDocument(id)
-            except:
-                traceback.print_exc(file=sys.stderr)
-                return self.globalOverview()
-                #return render('/tests/trace.mako')
-            c.url_ok = h.url_for(controller="/document",
-                                 action="globalOverview")
-            c.success_for = SET_DOCUMENT_SUCCESS_DELETE_HEADER
-            c.success_text = SET_DOCUMENT_SUCCESS_DELETE_TEXT
-            return render('/documents/dialogs/delete_document_success.mako')
-        else:
-            c.context = "../main.mako"
-            c.confirm_for = SET_DOCUMENT_CONFIRM_DELETE_HEADER
-            c.question = SET_DOCUMENT_CONFIRM_DELETE_TEXT
-            c.url_yes = "/document/globalDelete/%d/1" % id
-            c.url_no = "/document/globalOverview/"
-            return render('/documents/dialogs/confirm.mako')
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list