[cig-commits] r11801 - in cs/portal/trunk/seismo/SeismoWebPortal: . designs/plone templates/SeismoWebPortal

leif at geodynamics.org leif at geodynamics.org
Fri Apr 11 21:00:09 PDT 2008


Author: leif
Date: 2008-04-11 21:00:09 -0700 (Fri, 11 Apr 2008)
New Revision: 11801

Removed:
   cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/desktop.html
Modified:
   cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.html
   cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.py
   cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.css
   cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.py
   cs/portal/trunk/seismo/SeismoWebPortal/gui.py
   cs/portal/trunk/seismo/SeismoWebPortal/views.py
Log:
Began writing the admin interface.


Modified: cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.html	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.html	2008-04-12 04:00:09 UTC (rev 11801)
@@ -8,20 +8,12 @@
         #if $window is $desktop.activeWindow
             <li class="selected"><a href="$window.url">$window.icon $window.title</a></li>
         #else
-            <li class="plain"><a href="$window.url">$window.title</a></li>
+            <li class="plain"><a href="$window.url">$window.icon $window.title</a></li>
         #end if
     #end for
 </ul>
 
 <div id="portal-personaltools-wrapper"><ul id="portal-personaltools">
-
-        <li><a href="javascript:setActiveStyleSheet('Small Text',1);"
-               title="Small Text">Small</a></li>
-        <li><a href="javascript:setActiveStyleSheet('',1);"
-               title="Normal Text">Normal</a></li>
-        <li><a href="javascript:setActiveStyleSheet('Large Text', 1);"
-               title="Large Text">Large</a></li>
-
     #if $desktop.user
         <li class="portalUser">
             <!--<a id="user-name" href="">-->
@@ -47,7 +39,6 @@
             </a>
         </li>
     #end if
-
 </ul></div>
 
 

Modified: cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.py	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/Desktop.py	2008-04-12 04:00:09 UTC (rev 11801)
@@ -33,10 +33,10 @@
 currentTime=time.time
 __CHEETAH_version__ = '2.0rc7'
 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 7)
-__CHEETAH_genTime__ = 1206731980.3169739
-__CHEETAH_genTimestamp__ = 'Fri Mar 28 12:19:40 2008'
+__CHEETAH_genTime__ = 1207961506.174396
+__CHEETAH_genTimestamp__ = 'Fri Apr 11 17:51:46 2008'
 __CHEETAH_src__ = 'Desktop.html'
-__CHEETAH_srcLastModified__ = 'Fri Mar 28 12:19:33 2008'
+__CHEETAH_srcLastModified__ = 'Fri Apr 11 17:51:40 2008'
 __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -111,36 +111,31 @@
                 _v = VFFSL(SL,"window.url",True) # '$window.url' on line 11, col 40
                 if _v is not None: write(_filter(_v, rawExpr='$window.url')) # from line 11, col 40.
                 write('">')
-                _v = VFFSL(SL,"window.title",True) # '$window.title' on line 11, col 53
-                if _v is not None: write(_filter(_v, rawExpr='$window.title')) # from line 11, col 53.
+                _v = VFFSL(SL,"window.icon",True) # '$window.icon' on line 11, col 53
+                if _v is not None: write(_filter(_v, rawExpr='$window.icon')) # from line 11, col 53.
+                write(' ')
+                _v = VFFSL(SL,"window.title",True) # '$window.title' on line 11, col 66
+                if _v is not None: write(_filter(_v, rawExpr='$window.title')) # from line 11, col 66.
                 write('</a></li>\n')
         write('''</ul>
 
 <div id="portal-personaltools-wrapper"><ul id="portal-personaltools">
-
-        <li><a href="javascript:setActiveStyleSheet('Small Text',1);"
-               title="Small Text">Small</a></li>
-        <li><a href="javascript:setActiveStyleSheet('',1);"
-               title="Normal Text">Normal</a></li>
-        <li><a href="javascript:setActiveStyleSheet('Large Text', 1);"
-               title="Large Text">Large</a></li>
-
 ''')
-        if VFFSL(SL,"desktop.user",True): # generated from line 25, col 5
+        if VFFSL(SL,"desktop.user",True): # generated from line 17, col 5
             write('        <li class="portalUser">\n            <!--<a id="user-name" href="">-->\n                <span class="visualCaseSensitive">')
-            _v = VFFSL(SL,"desktop.user.first_name",True) # '$desktop.user.first_name' on line 28, col 51
-            if _v is not None: write(_filter(_v, rawExpr='$desktop.user.first_name')) # from line 28, col 51.
+            _v = VFFSL(SL,"desktop.user.first_name",True) # '$desktop.user.first_name' on line 20, col 51
+            if _v is not None: write(_filter(_v, rawExpr='$desktop.user.first_name')) # from line 20, col 51.
             write(' (')
-            _v = VFFSL(SL,"desktop.user.username",True) # '$desktop.user.username' on line 28, col 77
-            if _v is not None: write(_filter(_v, rawExpr='$desktop.user.username')) # from line 28, col 77.
+            _v = VFFSL(SL,"desktop.user.username",True) # '$desktop.user.username' on line 20, col 77
+            if _v is not None: write(_filter(_v, rawExpr='$desktop.user.username')) # from line 20, col 77.
             write(''')</span>
             <!--</a>-->
         </li>
    
         <li>
             <a href="''')
-            _v = VFFSL(SL,"root",True) # '$root' on line 33, col 22
-            if _v is not None: write(_filter(_v, rawExpr='$root')) # from line 33, col 22.
+            _v = VFFSL(SL,"root",True) # '$root' on line 25, col 22
+            if _v is not None: write(_filter(_v, rawExpr='$root')) # from line 25, col 22.
             write('''/profile/">
                 Profile
             </a>
@@ -148,34 +143,33 @@
     
         <li>
             <a href="''')
-            _v = VFFSL(SL,"root",True) # '$root' on line 39, col 22
-            if _v is not None: write(_filter(_v, rawExpr='$root')) # from line 39, col 22.
+            _v = VFFSL(SL,"root",True) # '$root' on line 31, col 22
+            if _v is not None: write(_filter(_v, rawExpr='$root')) # from line 31, col 22.
             write('''/logout/">
                 Log out
             </a>
         </li>
 ''')
-        else: # generated from line 43, col 5
+        else: # generated from line 35, col 5
             write('        <li>\n            <a href="')
-            _v = VFFSL(SL,"root",True) # '$root' on line 45, col 22
-            if _v is not None: write(_filter(_v, rawExpr='$root')) # from line 45, col 22.
+            _v = VFFSL(SL,"root",True) # '$root' on line 37, col 22
+            if _v is not None: write(_filter(_v, rawExpr='$root')) # from line 37, col 22.
             write('''/login/">
                Log in
             </a>
         </li>
 ''')
-        write('''
-</ul></div>
+        write('''</ul></div>
 
 
 ''')
         appWindow = VFFSL(SL,"desktop.activeWindow",True)
         write('\n\n')
         breadcrumbs = VFFSL(SL,"getattr",False)(VFFSL(SL,"appWindow",True), 'breadcrumbs', None)
-        if VFFSL(SL,"breadcrumbs",True): # generated from line 58, col 1
+        if VFFSL(SL,"breadcrumbs",True): # generated from line 49, col 1
             write('    <div id="portal-breadcrumbs">\n        <span id="breadcrumbs-you-are-here">You are here:</span> ')
-            _v = VFN(VFFSL(SL,"design",True),"renderBreadcrumbs",False)(VFFSL(SL,"breadcrumbs",True)) # '$design.renderBreadcrumbs($breadcrumbs)' on line 60, col 66
-            if _v is not None: write(_filter(_v, rawExpr='$design.renderBreadcrumbs($breadcrumbs)')) # from line 60, col 66.
+            _v = VFN(VFFSL(SL,"design",True),"renderBreadcrumbs",False)(VFFSL(SL,"breadcrumbs",True)) # '$design.renderBreadcrumbs($breadcrumbs)' on line 51, col 66
+            if _v is not None: write(_filter(_v, rawExpr='$design.renderBreadcrumbs($breadcrumbs)')) # from line 51, col 66.
             write('\n    </div>\n')
         write('''
 
@@ -188,7 +182,7 @@
     <tbody>
         <tr>
 ''')
-        if VFFSL(SL,"hasattr",False)(VFFSL(SL,"appWindow",True), 'renderNavTree'): # generated from line 73, col 13
+        if VFFSL(SL,"hasattr",False)(VFFSL(SL,"appWindow",True), 'renderNavTree'): # generated from line 64, col 13
             navTree = VFN(VFFSL(SL,"appWindow",True),"renderNavTree",False)(VFFSL(SL,"design",True))
             write('''            <td id="portal-column-one">
                 <div class="visualPadding">
@@ -199,8 +193,8 @@
                         <dd class="portletItem lastItem">
                             <ul class="portletNavigationTree navTreeLevel0">
                                 ''')
-            _v = VFFSL(SL,"navTree",True) # '$navTree' on line 83, col 33
-            if _v is not None: write(_filter(_v, rawExpr='$navTree')) # from line 83, col 33.
+            _v = VFFSL(SL,"navTree",True) # '$navTree' on line 74, col 33
+            if _v is not None: write(_filter(_v, rawExpr='$navTree')) # from line 74, col 33.
             write('''
                             </ul>
                         </dd>
@@ -209,20 +203,20 @@
             </td>
 ''')
         write('            <td id="portal-column-content">\n')
-        if VFFSL(SL,"appWindow.windowList",True): # generated from line 91, col 17
+        if VFFSL(SL,"appWindow.windowList",True): # generated from line 82, col 17
             write('                    <div id="content" class="documentEditable">\n                        <ul class="contentViews">\n')
-            if VFFSL(SL,"len",False)(VFFSL(SL,"appWindow.windowList",True)) > 1: # generated from line 94, col 29
-                for window in VFFSL(SL,"appWindow.windowList",True): # generated from line 95, col 33
+            if VFFSL(SL,"len",False)(VFFSL(SL,"appWindow.windowList",True)) > 1: # generated from line 85, col 29
+                for window in VFFSL(SL,"appWindow.windowList",True): # generated from line 86, col 33
                     klass = VFFSL(SL,"window",True) is VFFSL(SL,"appWindow.activeWindow",True) and "selected" or "plain"
                     write('                                    <li class="')
-                    _v = VFFSL(SL,"klass",True) # '$klass' on line 97, col 48
-                    if _v is not None: write(_filter(_v, rawExpr='$klass')) # from line 97, col 48.
+                    _v = VFFSL(SL,"klass",True) # '$klass' on line 88, col 48
+                    if _v is not None: write(_filter(_v, rawExpr='$klass')) # from line 88, col 48.
                     write('"><a href="')
-                    _v = VFFSL(SL,"window.url",True) # '$window.url' on line 97, col 65
-                    if _v is not None: write(_filter(_v, rawExpr='$window.url')) # from line 97, col 65.
+                    _v = VFFSL(SL,"window.url",True) # '$window.url' on line 88, col 65
+                    if _v is not None: write(_filter(_v, rawExpr='$window.url')) # from line 88, col 65.
                     write('">')
-                    _v = VFFSL(SL,"window.title",True) # '$window.title' on line 97, col 78
-                    if _v is not None: write(_filter(_v, rawExpr='$window.title')) # from line 97, col 78.
+                    _v = VFFSL(SL,"window.title",True) # '$window.title' on line 88, col 78
+                    if _v is not None: write(_filter(_v, rawExpr='$window.title')) # from line 88, col 78.
                     write('</a></li>\n')
             write('''                        </ul>
                         <div class="contentActions">
@@ -236,42 +230,42 @@
                                     </a>
                                 </li>
 ''')
-            for button in VFFSL(SL,"appWindow.activeWindow.buttons",True): # generated from line 111, col 33
+            for button in VFFSL(SL,"appWindow.activeWindow.buttons",True): # generated from line 102, col 33
                 write('                                    <li><a href="')
-                _v = VFFSL(SL,"button.url",True) # '$button.url' on line 112, col 50
-                if _v is not None: write(_filter(_v, rawExpr='$button.url')) # from line 112, col 50.
+                _v = VFFSL(SL,"button.url",True) # '$button.url' on line 103, col 50
+                if _v is not None: write(_filter(_v, rawExpr='$button.url')) # from line 103, col 50.
                 write('">')
-                _v = VFFSL(SL,"button.title",True) # '$button.title' on line 112, col 63
-                if _v is not None: write(_filter(_v, rawExpr='$button.title')) # from line 112, col 63.
+                _v = VFFSL(SL,"button.title",True) # '$button.title' on line 103, col 63
+                if _v is not None: write(_filter(_v, rawExpr='$button.title')) # from line 103, col 63.
                 write('</a></li>\n')
-            if VFFSL(SL,"appWindow.activeWindow.menuBar",True): # generated from line 114, col 33
+            if VFFSL(SL,"appWindow.activeWindow.menuBar",True): # generated from line 105, col 33
                 menuBar = VFN(VFFSL(SL,"appWindow.activeWindow",True),"menuBar",True)[:]
                 VFN(VFFSL(SL,"menuBar",True),"reverse",False)()
-                for menu in VFFSL(SL,"menuBar",True): # generated from line 117, col 37
+                for menu in VFFSL(SL,"menuBar",True): # generated from line 108, col 37
                     write('                                        <li>\n                                            <dl class="actionMenu" id="')
-                    _v = VFFSL(SL,"menu.id",True) # '$menu.id' on line 119, col 72
-                    if _v is not None: write(_filter(_v, rawExpr='$menu.id')) # from line 119, col 72.
+                    _v = VFFSL(SL,"menu.id",True) # '$menu.id' on line 110, col 72
+                    if _v is not None: write(_filter(_v, rawExpr='$menu.id')) # from line 110, col 72.
                     write('">\n                                                <dt class="actionMenuHeader"><a href="')
-                    _v = VFFSL(SL,"menu.url",True) # '$menu.url' on line 120, col 87
-                    if _v is not None: write(_filter(_v, rawExpr='$menu.url')) # from line 120, col 87.
+                    _v = VFFSL(SL,"menu.url",True) # '$menu.url' on line 111, col 87
+                    if _v is not None: write(_filter(_v, rawExpr='$menu.url')) # from line 111, col 87.
                     write('">')
-                    _v = VFFSL(SL,"menu.title",True) # '$menu.title' on line 120, col 98
-                    if _v is not None: write(_filter(_v, rawExpr='$menu.title')) # from line 120, col 98.
+                    _v = VFFSL(SL,"menu.title",True) # '$menu.title' on line 111, col 98
+                    if _v is not None: write(_filter(_v, rawExpr='$menu.title')) # from line 111, col 98.
                     write('''</a></dt>
                                                 <dd class="actionMenuContent">
                                                     <ul>
 ''')
-                    for item in VFFSL(SL,"menu.items",True): # generated from line 123, col 57
+                    for item in VFFSL(SL,"menu.items",True): # generated from line 114, col 57
                         klass = "visualIconPadding visualIcon"
                         write('                                                            <li><a href="')
-                        _v = VFFSL(SL,"item.url",True) # '$item.url' on line 125, col 74
-                        if _v is not None: write(_filter(_v, rawExpr='$item.url')) # from line 125, col 74.
+                        _v = VFFSL(SL,"item.url",True) # '$item.url' on line 116, col 74
+                        if _v is not None: write(_filter(_v, rawExpr='$item.url')) # from line 116, col 74.
                         write('" class="')
-                        _v = VFFSL(SL,"klass",True) # '$klass' on line 125, col 92
-                        if _v is not None: write(_filter(_v, rawExpr='$klass')) # from line 125, col 92.
+                        _v = VFFSL(SL,"klass",True) # '$klass' on line 116, col 92
+                        if _v is not None: write(_filter(_v, rawExpr='$klass')) # from line 116, col 92.
                         write('">')
-                        _v = VFFSL(SL,"item.title",True) # '$item.title' on line 125, col 100
-                        if _v is not None: write(_filter(_v, rawExpr='$item.title')) # from line 125, col 100.
+                        _v = VFFSL(SL,"item.title",True) # '$item.title' on line 116, col 100
+                        if _v is not None: write(_filter(_v, rawExpr='$item.title')) # from line 116, col 100.
                         write('</a></li>\n')
                     write('''                                                    </ul>
                                                 </dd>
@@ -282,37 +276,13 @@
                         </div>
                         <div class="documentContent" id="region-content">
                             ''')
-            _v = VFN(VFFSL(SL,"design",True),"render",False)(VFFSL(SL,"appWindow.activeWindow.content",True)) # '$design.render($appWindow.activeWindow.content)' on line 136, col 29
-            if _v is not None: write(_filter(_v, rawExpr='$design.render($appWindow.activeWindow.content)')) # from line 136, col 29.
+            _v = VFN(VFFSL(SL,"design",True),"render",False)(VFFSL(SL,"appWindow.activeWindow.content",True)) # '$design.render($appWindow.activeWindow.content)' on line 127, col 29
+            if _v is not None: write(_filter(_v, rawExpr='$design.render($appWindow.activeWindow.content)')) # from line 127, col 29.
             write('''
                         </div>
                     </div>
 ''')
         write('''            </td>
-
-<!--
-            <td id="portal-column-two">
-                <div class="visualPadding">
-                    <dl class="portlet" id="portlet-tomato">
-                        <dt class="portletHeader">
-                            Tomato
-                        </dt>
-                        <dd class="portletItem">
-                            Life is a tomato.
-                        </dd>
-                    </dl>
-                    <dl class="portlet" id="portlet-tomato">
-                        <dt class="portletHeader">
-                            Tomato
-                        </dt>
-                        <dd class="portletItem">
-                            Life is a tomato.
-                        </dd>
-                    </dl>
-                </div>
-            </td>
--->
-
         </tr>
     </tbody>
 </table>

Modified: cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.css
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.css	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.css	2008-04-12 04:00:09 UTC (rev 11801)
@@ -338,7 +338,7 @@
 /* infobars */
 
 .infobar {
-    border-bottom: medium double black;
+    border-bottom: medium double silver;
 }
 
 

Modified: cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.py	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/designs/plone/style.py	2008-04-12 04:00:09 UTC (rev 11801)
@@ -33,10 +33,10 @@
 currentTime=time.time
 __CHEETAH_version__ = '2.0rc7'
 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 7)
-__CHEETAH_genTime__ = 1207258017.1388161
-__CHEETAH_genTimestamp__ = 'Thu Apr  3 14:26:57 2008'
+__CHEETAH_genTime__ = 1207967402.526777
+__CHEETAH_genTimestamp__ = 'Fri Apr 11 19:30:02 2008'
 __CHEETAH_src__ = 'style.css'
-__CHEETAH_srcLastModified__ = 'Thu Apr  3 14:11:25 2008'
+__CHEETAH_srcLastModified__ = 'Fri Apr 11 19:29:56 2008'
 __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine'
 
 if __CHEETAH_versionTuple__ < RequiredCheetahVersionTuple:
@@ -423,7 +423,7 @@
 /* infobars */
 
 .infobar {
-    border-bottom: medium double black;
+    border-bottom: medium double silver;
 }
 
 

Modified: cs/portal/trunk/seismo/SeismoWebPortal/gui.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/gui.py	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/gui.py	2008-04-12 04:00:09 UTC (rev 11801)
@@ -1,5 +1,6 @@
 
 import config
+from StringIO import StringIO
 
 
 class WindowParent(object):
@@ -103,7 +104,10 @@
     def renderNavTree(self, urlRoot, path, level, design):
         return ""
 
+    def icon(self):
+        return '<img class="icon" src="%s">' % self.iconURL()
 
+
 class Directory(Node):
 
     def __init__(self, name, title, contents, url = None):
@@ -120,6 +124,11 @@
         self.contents.append(node)
         self.index[node.name] = node
 
+    def appendNodes(self, nodeList):
+        for node in nodeList:
+            self.appendNode(node)
+        return
+
     def xresolve(self, request, path):
         if not path:
             return [self]
@@ -148,7 +157,27 @@
             items += node.renderNavTree(urlRoot, path, level + 1, design)
         return items
 
+    def iconURL(self):
+        return "%s/icons/folder.gif" % config.root
 
+    def iconView(self, urlRoot):
+        html = StringIO()
+        print >>html, '<h2>%s</h2>' % self.title
+        print >>html, '<table width="100%"><tr>'
+        i = 0
+        for i, item in enumerate(self.contents):
+            if i and i % 4 == 0:
+                print >>html, '</tr><tr>'
+            print >>html, ('<td align=center><table><tr><td align=center><a href="%s">%s</a></td></tr><tr><td align=center><a href="%s">%s</a></td></tr></table></td>' %
+                           (item.url(urlRoot), item.icon(), item.url(urlRoot), item.title))
+        while (i % 4) != 3:
+            print >>html, '<td></td>'
+            i += 1
+        print >>html, '</tr></table>'
+    
+        return StaticContent(html.getvalue())
+
+
 class LeafNode(Node):
 
     def xresolve(self, request, path):
@@ -159,7 +188,9 @@
     def url(self, root):
         if self._url:
             return self._url
-        return root + self.name
+        if '.' in self.name:
+            return root + self.name
+        return root + self.name + '/'
 
     def renderNavTree(self, urlRoot, path, level, design):
         url = self.url(urlRoot)
@@ -167,7 +198,10 @@
         render = getattr(design, self.render)
         return render(self.title, url, selected)
 
+    def iconURL(self):
+        return "%s/icons/document.gif" % config.root
 
+
 class File(LeafNode):
     render = 'renderNavTreeFile'
 

Deleted: cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/desktop.html
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/desktop.html	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/templates/SeismoWebPortal/desktop.html	2008-04-12 04:00:09 UTC (rev 11801)
@@ -1,16 +0,0 @@
-
-<h2>desktop</h2>
-
-<table width="100%">
-
-    <tr>
-
-    <td align=center><table><tr><td align=center><a href="{{root}}/home/"><img src="{{root}}/icons/folder.gif"></a></td></tr><tr><td align=center><a href="{{root}}/home/">Home</a></td></tr></table></td>
-
-    <td align=center><table><tr><td align=center><a href="{{root}}/trash/"><img src="{{root}}/icons/folder.gif"></a></td></tr><tr><td align=center><a href="{{root}}/trash/">Trash</a></td></tr></table></td>
-
-    <td align=center><table><tr><td align=center><a href="{{root}}/events/"><img src="{{root}}/icons/eventfinder.gif"></a></td></tr><tr><td align=center><a href="{{root}}/events/">Event Finder</a></td></tr></table></td>
-
-    </tr>
-
-</table>

Modified: cs/portal/trunk/seismo/SeismoWebPortal/views.py
===================================================================
--- cs/portal/trunk/seismo/SeismoWebPortal/views.py	2008-04-11 23:05:15 UTC (rev 11800)
+++ cs/portal/trunk/seismo/SeismoWebPortal/views.py	2008-04-12 04:00:09 UTC (rev 11801)
@@ -78,7 +78,7 @@
     if not path:
         if request.user.is_anonymous():
             return httpResponse(about(desktop))
-        openFileBrowser(desktop)
+        openPrivateApps(request, desktop)
         return httpResponse(desktopFolder(request, desktop))
 
     # Plone expand/collapse icon redirect hack
@@ -116,7 +116,7 @@
         return HttpResponseRedirect(config.root + '/login?%s=%s' %
                                     (REDIRECT_FIELD_NAME, quote(request.get_full_path())))
 
-    openFileBrowser(desktop)
+    openPrivateApps(request, desktop)
 
     index = Index({
         "home": homeFolder,
@@ -128,6 +128,7 @@
         "logout": logout,
         "help": help,
         "readme": readme,
+        "admin": admin,
         })
     privateView = index.get(name)
     if privateView:
@@ -163,14 +164,22 @@
     return about, login, register
 
 
+def openPrivateApps(request, desktop):
+    openFileBrowser(desktop)
+    openEventFinder(desktop)
+    openEventViewers(request, desktop)
+    if request.user.is_staff:
+        openAdminApp(desktop)
+    return
+
+
 def openFileBrowser(desktop):
     navtree = gui.Directory("desktop", "Desktop", [
         gui.Directory("home", "Home", []),
         gui.Directory("shared", "Shared", []),
         gui.Directory("trash", "Trash", []),
-        gui.Search("events", "Event Finder", url = config.root + "/events/"),
         ])
-    fileBrowser = gui.FileBrowser(config.root + "/", "File Browser", navtree)
+    fileBrowser = gui.FileBrowser(config.root + "/", "Files", navtree)
     desktop.insertWindow(fileBrowser)
     desktop.selectWindow(fileBrowser)
 
@@ -208,8 +217,9 @@
 
 
 def desktopFolder(request, desktop):
-    child = gui.ChildWindow(config.root + "/", "View")
-    child.content = gui.StaticContent(loader.render_to_string('SeismoWebPortal/desktop.html', {'root': config.root}))
+    url = config.root + "/"
+    child = gui.ChildWindow(url, "View")
+    child.content = desktop.activeWindow.root.iconView(url)
     desktop.activeWindow.selectWindow(child)
     return desktop
 
@@ -542,6 +552,7 @@
     from django.contrib.auth.forms import AuthenticationForm
     from django.contrib.auth import LOGIN_URL, REDIRECT_FIELD_NAME
     from django.contrib.sites.models import Site
+    import datetime
 
     _, appWindow, _ = openPublicApps(desktop)
     desktop.selectWindow(appWindow)
@@ -568,6 +579,8 @@
             from django.contrib.auth import login
             user = manipulator.get_user()
             loginUser(request, user)
+            user.last_login = datetime.datetime.now()
+            user.save()
             request.session.delete_test_cookie()
             help_login_hook(request, user)
             return HttpResponseRedirect(redirect_to)
@@ -1159,6 +1172,16 @@
         wh = 'width=%d height=%d' % (width, height)
     return '<img src="%s"%s>' % (src, wh)
 
+def mailto(email, content=None):
+    if content is None:
+        content = email
+    return '<a href="mailto:%s">%s</a>' % (email, content)
+
+def yesNo(flag):
+    url = "%s/pics/icon-%s.gif" % (config.root, (flag and "yes" or "no"))
+    return img(url, width=10, height=10)
+
+
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # Events
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1189,24 +1212,34 @@
     return view, edit
 
 
+def openEventViewers(request, desktop):
+    desktop.eventViewers = {}
+    for workspace in EventWorkspace.objects.filter(fsNode__owner = request.user, fsNode__inTrash = False):
+        url = "%s/%d/" % (config.root, workspace.fsNode.id)
+        navtree = gui.Directory("events", "Events", [])
+        appWindow = gui.EventViewer(url, workspace.fsNode.name, navtree, workspace)
+        desktop.insertWindow(appWindow)
+        desktop.eventViewers[workspace.id] = appWindow
+    return
+
+
 def eventViewer(workspace, url, request, path, desktop):
 
-    workspaceName = workspace.fsNode.name
     event = workspace.event
     
     if event.singleSource:
         sources = gui.File("mechanism", "Source Mechanism", url = url + "sources/")
     else:
         sources = gui.Directory("sources", "Sources", [], url = url + "sources/")
-    navtree = gui.Directory("events", "Events", [
+
+    appWindow = desktop.eventViewers[workspace.id]
+    appWindow.root.appendNodes([
         gui.Directory("seismograms", "Seismograms", [], url = url),
         sources,
         gui.Directory("maps", "Maps", [], url = url + "maps/"),
         gui.File("settings", "Settings", url = url + "settings/"),
         gui.File("properties", "Properties", url = url + "properties/"),
         ])
-    appWindow = gui.EventViewer(url, workspaceName + " - Event Viewer", navtree, workspace)
-    desktop.insertWindow(appWindow)
     desktop.selectWindow(appWindow)
 
     if not path:
@@ -1221,7 +1254,7 @@
         return eventMaps(workspace, url, request, path, appWindow, desktop)
 
     if name == "settings":
-        appWindow.path.append(navtree.index['settings'])
+        appWindow.path.append(appWindow.root.index['settings'])
         settings = gui.ChildWindow(url + "settings/", "Settings")
         settings.buttons.append(helpButton(request))
         desktop.activeWindow.insertWindow(settings)
@@ -1234,7 +1267,7 @@
                              follow = EventWorkspace.follow,
                              )
     if name == "properties":
-        appWindow.path.append(navtree.index['properties'])
+        appWindow.path.append(appWindow.root.index['properties'])
         menuBar = [
             gui.Menu("actionMenu", "actions", "Actions",
                      [gui.MenuItem(url + "delete/", "Delete"),
@@ -1262,7 +1295,21 @@
     raise Http404
 
 
+def progressBar(percentage):
+    imageWidth = 154
+    offset = imageWidth - int(float(imageWidth) * percentage)
+    return '<img src="%s/pics/progress_box.gif"" style="background: white url(%s/pics/progress_bar.gif) top left no-repeat; background-position: -%dpx 0px;">' % (
+        config.root, config.root, offset)
 
+
+def runOutputList(run):
+    html = ''
+    for job in run.job_set.all():
+        for file in job.outputfile_set.all():
+            html += '<li><a href="%s">%s</a>' % (file.url(), file.name)
+    return '<ul class=output>%s</ul>' % html
+
+
 def seismogramTable(workspace, url, request, path, appWindow, desktop):
 
     event = workspace.event
@@ -1274,6 +1321,10 @@
 
     html = StringIO()
     print >>html, '<h2>%s - Seismograms</h2>' % workspace
+    if False:
+        print >>html, progressBar(0.25)
+        print >>html, progressBar(0.5)
+        print >>html, progressBar(1.0)
 
     parameterClasses = [MineosParameters, Specfem3DGlobeParameters]
 
@@ -1302,11 +1353,7 @@
                 if request.parameters == parameters:
                     run = request.run
                     status = '<td colspan=2>%s</td>' % run.status
-                    output = ''
-                    for job in run.job_set.all():
-                        for file in job.outputfile_set.all():
-                            output += '<li><a href="%s">%s</a>' % (file.url(), file.name)
-                    output = '<td><ul class=output>%s</ul></td>' % output
+                    output = '<td>%s</td>' % runOutputList(run)
                     break
             print >>html, '<tr class=%s><td><a href="%s">%s</a></td>%s%s</tr>' % (
                 (i % 2 and 'even' or 'odd'), ps.fsNode.url(), ps, status, output)
@@ -1552,6 +1599,15 @@
     shutil.copyfileobj(stream,  response)
     stream.close()
     return response
+
+
+def openEventFinder(desktop):
+    navtree = gui.Directory("events", "Events", [
+        gui.Search("search", "Search", url = config.root + "/events/"),
+        ])
+    appWindow = gui.EventFinder(config.root + "/events/", "Event Search", navtree)
+    desktop.insertWindow(appWindow)
+    desktop.events = appWindow
     
 
 def event_search(request, path, desktop):
@@ -1559,20 +1615,11 @@
 
     if path: raise Http404
 
-    search = gui.Search("search", "Search", url = config.root + "/events/")
-    navtree = gui.Directory("events", "Events", [
-        search,
-        ])
-    appWindow = gui.EventFinder(config.root + "/events/", "Event Finder", navtree)
-    desktop.insertWindow(appWindow)
+    appWindow = desktop.events
     desktop.selectWindow(appWindow)
     
-    #fileBrowser = desktop.windowList[0]
-    #eventsDir = fileBrowser.root.index["events"]
-    #fileBrowser.path.append(eventsDir)
-
     if not request.GET:
-        appWindow.path.append(search)
+        appWindow.path.append(appWindow.root.index['search'])
         search = gui.ChildWindow(config.root + "/events/", "Search")
         desktop.activeWindow.insertWindow(search)
         html = loader.render_to_string('SeismoWebPortal/event_search.html')
@@ -1611,7 +1658,7 @@
     resultsURL = request.get_full_path()
 
     results = gui.SearchResults("results", "Results", url = resultsURL)
-    navtree.appendNode(results)
+    appWindow.root.appendNode(results)
     appWindow.path.append(results)
     
     results = gui.ChildWindow(resultsURL, "Results")
@@ -2195,4 +2242,173 @@
         return model
 
 
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+# Administration
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+def openAdminApp(desktop):
+    navtree = gui.Directory("admin", "Administration", [
+        gui.File("status", "Status"),
+        gui.Directory("jobs", "Jobs", []),
+        gui.Directory("requests", "Requests", []),
+        gui.Directory("users", "Users", []),
+        gui.Directory("invites", "Invites", []),
+        ])
+    adminAppWindow = gui.TreeBrowser(config.root + "/admin/", "Administration", navtree)
+    desktop.insertWindow(adminAppWindow)
+    desktop.admin = adminAppWindow
+
+
+def admin(request, path, desktop):
+    if not request.user.is_staff: raise Http404
+    
+    appWindow = desktop.admin
+    desktop.selectWindow(appWindow)
+    navtree = appWindow.root
+    url = config.root + "/admin/"
+    
+    if not path:
+        child = gui.ChildWindow(url, "Administration")
+        child.content = navtree.iconView(url)
+        desktop.activeWindow.selectWindow(child)
+        return desktop
+
+    name = path.pop(0)
+
+    if name == "status":
+        appWindow.path.append(navtree.index['status'])
+        child = gui.ChildWindow(url, "Status")
+
+        html = StringIO()
+        print >>html, '<h2>Status</h2>'
+        
+        child.content = gui.StaticContent(html.getvalue())
+        desktop.activeWindow.selectWindow(child)
+        return desktop
+
+    if name == "jobs":
+        appWindow.path.append(navtree.index['jobs'])
+        child = gui.ChildWindow(url, "Jobs")
+
+        html = StringIO()
+        print >>html, '<h2>Jobs</h2>'
+        
+        child.content = gui.StaticContent(html.getvalue())
+        desktop.activeWindow.selectWindow(child)
+        return desktop
+
+    if name == "requests":
+        from models import CODE_CHOICES
+        
+        url += "requests/"
+        appWindow.path.append(navtree.index['requests'])
+
+        if path:
+            name = path.pop(0)
+            objId = intOr404(name)
+            obj = get_object_or_404(Request, id = objId)
+            url += "%d/" % objId
+
+            if request.method == 'POST':
+                Run.objects.create(
+                    request = obj,
+                    status = "new",
+                    )
+                return HttpResponseRedirect(url)
+
+            html = StringIO()
+            print >>html, '<h2>Request %04d</h2>' % objId
+            print >>html, '<p class=infobar>%s</p>' % CODE_CHOICES[obj.code-1][1]
+            print >>html, '<table rules="groups" class="cool">'
+            print >>html, '<thead>'
+            print >>html, '<tr><th></th><th>run</th><th>status</th><th>output</th></tr>'
+            print >>html, '</thead>'
+            print >>html, '<tbody>'
+            for i, run in enumerate(obj.run_set.all()):
+                if run.id == obj.run.id:
+                    arrow = '&rarr;'
+                else:
+                    arrow = ''
+                print >>html, '<tr class=%s><td>%s</td><td>%05d</td><td>%s</td><td>%s</td>' % (
+                    (i % 2 and 'even' or 'odd'), arrow, run.id, run.status, runOutputList(run)
+                    )
+            print >>html, '</tbody>'
+            print >>html, '</table>'
+
+            print >>html, '<p><form method="post" action="%s"><input type="submit" value="Run Again" /></form></p>' % url
+            
+            window = gui.ChildWindow(url, "View")
+            desktop.activeWindow.insertWindow(window)
+            window.content = gui.StaticContent(html.getvalue())
+            desktop.activeWindow.selectWindow(window)
+            return desktop
+        
+        html = StringIO()
+        print >>html, '<h2>Requests</h2>'
+        print >>html, '<table rules="groups" class="cool">'
+        print >>html, '<thead>'
+        print >>html, '<tr><th>id</th><th>code</th><th>status</th><th>output</th></tr>'
+        print >>html, '</thead>'
+        print >>html, '<tbody>'
+        for i, obj in enumerate(Request.objects.all().order_by('-id')):
+            id = '<a href="%s%d/">%04d</a>' % (url, obj.id, obj.id)
+            print >>html, '<tr class=%s><td>%s</td><td>%s</td><td>%s</td><td>%s</td>' % (
+                (i % 2 and 'even' or 'odd'), id, CODE_CHOICES[obj.code-1][1],
+                obj.run.status, runOutputList(obj.run)
+                )
+        print >>html, '</tbody>'
+        print >>html, '</table>'
+        
+        window = gui.ChildWindow(url, "View")
+        desktop.activeWindow.insertWindow(window)
+        window.content = gui.StaticContent(html.getvalue())
+        desktop.activeWindow.selectWindow(window)
+        return desktop
+
+    if name == "users":
+        from django.contrib.auth.models import User
+        url += "users/"
+        appWindow.path.append(navtree.index['users'])
+        window = gui.ChildWindow(url + "users/", "Users")
+        desktop.activeWindow.insertWindow(window)
+
+        users = User.objects.all()
+
+        icon = img("http://www.geodynamics.org/cig/user.gif", width=16, height=16)
+        
+        html = StringIO()
+        print >>html, '<h2>Users</h2>'
+        print >>html, '<p class=infobar>%d users</p>' % users.count()
+        print >>html, '<table rules="groups" class="cool">'
+        print >>html, '<thead>'
+        print >>html, ('<tr><th>username</th><th>e-mail</th><th>first name</th><th>last name</th><th>staff</th>' +
+                       '<th>invite</th><th>approved</th><th>last login</th></tr>')
+        print >>html, '</thead>'
+        print >>html, '<tbody>'
+        for i, user in enumerate(users):
+            print >>html, ('<tr class=%s><td>%s%s</td><td>%s</td><td>%s</td><td>%s</td>' +
+                           '<td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>') % (
+                (i % 2 and 'even' or 'odd'), icon, user.username, mailto(user.email), user.first_name, user.last_name,
+                yesNo(user.is_staff), user.userinfo.invite, yesNo(user.userinfo.approved), user.last_login.date())
+        print >>html, '</tbody>'
+        print >>html, '</table>'
+        
+        window.content = gui.StaticContent(html.getvalue())
+        desktop.activeWindow.selectWindow(window)
+        return desktop
+
+    if name == "invites":
+        appWindow.path.append(navtree.index['invites'])
+        child = gui.ChildWindow(url, "Invites")
+
+        html = StringIO()
+        print >>html, '<h2>Invites</h2>'
+        
+        child.content = gui.StaticContent(html.getvalue())
+        desktop.activeWindow.selectWindow(child)
+        return desktop
+
+    raise Http404
+
+
 # end of file



More information about the cig-commits mailing list