Code

CGI interface view customisation section may now be hidden (patch from
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Sun, 21 Oct 2001 00:17:56 +0000 (00:17 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Sun, 21 Oct 2001 00:17:56 +0000 (00:17 +0000)
 Roch'e Compaan.)

git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@317 57a73879-2fb5-44c3-a270-3262357dd7e2

CHANGES.txt
roundup/cgi_client.py
roundup/htmltemplate.py

index 686d30fb48c39b9b9c2575dc8473c9249b579343..95b3484f5b8501030823396156ede9b1fa6b706f 100644 (file)
@@ -4,6 +4,8 @@ are given with the most recent entry first.
 2001-10-?? - 0.3.0
 Feature:
  . Hyperdatabase sorts strings-that-look-like-numbers as numbers now.
+ . CGI interface view customisation section may now be hidden (patch from
+   Roch'e Compaan.)
  Admin Tool (roundup-admin):
   . Interactive mode for running multiple (independant at present) commands.
   . Tabular display of nodes.
index 21af9a20720fa165278d75f62af5c84b0b33a5af..55ced042a158a93b77fd0e0016a7695d14c4afd7 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: cgi_client.py,v 1.34 2001-10-20 11:58:48 richard Exp $
+# $Id: cgi_client.py,v 1.35 2001-10-21 00:17:54 richard Exp $
 
 import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
 import base64, Cookie, time
@@ -156,6 +156,21 @@ class Client:
                 filterspec[key] = value.value
         return filterspec
 
+    def customization_widget(self):
+        ''' The customization widget is visible by default. The widget
+            visibility is remembered by show_customization.  Visibility
+            is not toggled if the action value is "Redisplay"
+        '''
+        if not self.form.has_key('show_customization'):
+            visible = 1
+        else:
+            visible = int(self.form['show_customization'].value)
+            if self.form.has_key('action'):
+                if self.form['action'].value != 'Redisplay':
+                    visible = self.form['action'].value == '+'
+            
+        return visible
+
     default_index_sort = ['-activity']
     default_index_group = ['priority']
     default_index_filter = []
@@ -182,7 +197,7 @@ class Client:
     # XXX deviates from spec - loses the '+' (that's a reserved character
     # in URLS
     def list(self, sort=None, group=None, filter=None, columns=None,
-            filterspec=None):
+            filterspec=None, show_customization=None):
         ''' call the template index with the args
 
             :sort    - sort by prop name, optionally preceeded with '-'
@@ -202,9 +217,12 @@ class Client:
         if filter is None: filter = self.index_arg(':filter')
         if columns is None: columns = self.index_arg(':columns')
         if filterspec is None: filterspec = self.index_filterspec()
+        if show_customization is None:
+            show_customization = self.customization_widget()
 
         htmltemplate.index(self, self.TEMPLATES, self.db, cn, filterspec,
-            filter, columns, sort, group)
+            filter, columns, sort, group,
+            show_customization=show_customization)
         self.pagefoot()
 
     def shownode(self, message=None):
@@ -681,8 +699,8 @@ class ExtendedClient(Client):
         if self.user not in (None, 'anonymous'):
             userid = self.db.user.lookup(self.user)
             user_info = '''
-<a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">My Issues</a> |
-<a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">My Support</a> |
+<a href="issue?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> |
+<a href="support?assignedto=%s&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">My Support</a> |
 <a href="user%s">My Details</a> | <a href="logout">Logout</a>
 '''%(userid, userid, userid)
         else:
@@ -707,11 +725,11 @@ class ExtendedClient(Client):
 <td align=right valign=bottom>%s</td></tr>
 <tr class="location-bar">
 <td align=left>All
-<a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
-<a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
+<a href="issue?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>,
+<a href="support?status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
 | Unassigned
-<a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority">Issues</a>,
-<a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername">Support</a>
+<a href="issue?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>,
+<a href="support?assignedto=admin&status=unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
 %s
 %s</td>
 <td align=right>%s</td>
@@ -776,6 +794,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.34  2001/10/20 11:58:48  richard
+# Catch errors in login - no username or password supplied.
+# Fixed editing of password (Password property type) thanks Roch'e Compaan.
+#
 # Revision 1.33  2001/10/17 00:18:41  richard
 # Manually constructing cookie headers now.
 #
index 6a37e4338cd38e0a401b6a36bbc440ed09adc051..c65ef4dea6763cd0ad5db16f6df981b888585938 100644 (file)
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-# $Id: htmltemplate.py,v 1.28 2001-10-21 00:00:16 richard Exp $
+# $Id: htmltemplate.py,v 1.29 2001-10-21 00:17:56 richard Exp $
 
 import os, re, StringIO, urllib, cgi, errno
 
@@ -312,7 +312,7 @@ class Checklist(Base):
         # get our current checkbox state
         if self.nodeid:
             # get the info from the node - make sure it's a list
-            if isinstance(propclass, hyperdb.Link:
+            if isinstance(propclass, hyperdb.Link):
                 value = [self.cl.get(self.nodeid, property)]
             else:
                 value = self.cl.get(self.nodeid, property)
@@ -462,6 +462,7 @@ def sortby(sort_name, columns, filter, sort, group, filterspec):
 
 def index(client, templates, db, classname, filterspec={}, filter=[],
         columns=[], sort=[], group=[], show_display_form=1, nodeids=None,
+        show_customization=1,
         col_re=re.compile(r'<property\s+name="([^>]+)">')):
     globals = {
         'plain': Plain(db, templates, classname, filterspec=filterspec),
@@ -498,7 +499,7 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
         replace = IndexTemplateReplace(globals, locals(), filter)
         w(replace.go(template))
         w('<tr class="location-bar"><td width="1%%">&nbsp;</td>')
-        w('<td><input type="submit" value="Redisplay"></td></tr>')
+        w('<td><input type="submit" name="action" value="Redisplay"></td></tr>')
         w('</table>')
 
     # If the filters aren't being displayed, then hide their current
@@ -528,6 +529,93 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
                 l.append(name)
         columns = l
 
+    # now add in the filter/columns/group/etc config table form
+    w('<input type="hidden" name="show_customization" value="%s">' %
+        show_customization )
+    w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
+    names = []
+    for name in cl.getprops().keys():
+        if name in all_filters or name in all_columns:
+            names.append(name)
+    w('<tr class="location-bar">')
+    if show_customization:
+        action = '-'
+    else:
+        action = '+'
+        # hide the values for filters, columns and grouping in the form
+        # if the customization widget is not visible
+        for name in names:
+            if all_filters and name in filter:
+                w('<input type="hidden" name=":filter" value="%s">' % name)
+            if all_columns and name in columns:
+                w('<input type="hidden" name=":columns" value="%s">' % name)
+            if all_columns and name in group:
+                w('<input type="hidden" name=":group" value="%s">' % name)
+
+    if show_display_form:
+        # TODO: The widget style can go into the stylesheet
+        w('<th align="left" colspan=%s>'
+          '<input style="height : 1em; width : 1em; font-size: 12pt" type="submit" name="action" value="%s">&nbsp;View '
+          'customisation...</th></tr>\n'%(len(names)+1, action))
+        if show_customization:
+            w('<tr class="location-bar"><th>&nbsp;</th>')
+            for name in names:
+                w('<th>%s</th>'%name.capitalize())
+            w('</tr>\n')
+
+            # Filter
+            if all_filters:
+                w('<tr><th width="1%" align=right class="location-bar">'
+                  'Filters</th>\n')
+                for name in names:
+                    if name not in all_filters:
+                        w('<td>&nbsp;</td>')
+                        continue
+                    if name in filter: checked=' checked'
+                    else: checked=''
+                    w('<td align=middle>\n')
+                    w(' <input type="checkbox" name=":filter" value="%s" '
+                      '%s></td>\n'%(name, checked))
+                w('</tr>\n')
+
+            # Columns
+            if all_columns:
+                w('<tr><th width="1%" align=right class="location-bar">'
+                  'Columns</th>\n')
+                for name in names:
+                    if name not in all_columns:
+                        w('<td>&nbsp;</td>')
+                        continue
+                    if name in columns: checked=' checked'
+                    else: checked=''
+                    w('<td align=middle>\n')
+                    w(' <input type="checkbox" name=":columns" value="%s"'
+                      '%s></td>\n'%(name, checked))
+                w('</tr>\n')
+
+                # Grouping
+                w('<tr><th width="1%" align=right class="location-bar">'
+                  'Grouping</th>\n')
+                for name in names:
+                    prop = properties[name]
+                    if name not in all_columns:
+                        w('<td>&nbsp;</td>')
+                        continue
+                    if name in group: checked=' checked'
+                    else: checked=''
+                    w('<td align=middle>\n')
+                    w(' <input type="checkbox" name=":group" value="%s"'
+                      '%s></td>\n'%(name, checked))
+                w('</tr>\n')
+
+            w('<tr class="location-bar"><td width="1%">&nbsp;</td>')
+            w('<td colspan="%s">'%len(names))
+            w('<input type="submit" name="action" value="Redisplay"></td>')
+            w('</tr>\n')
+
+        w('</table>\n')
+        w('</form>\n')
+
     # now display the index section
     w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
     w('<tr class="list-header">\n')
@@ -596,72 +684,6 @@ def index(client, templates, db, classname, filterspec={}, filter=[],
 
     w('</table>')
 
-    if not show_display_form:
-        return
-
-    # now add in the filter/columns/group/etc config table form
-    w('<p>')
-    w('<table width=100% border=0 cellspacing=0 cellpadding=2>\n')
-    names = []
-    for name in cl.getprops().keys():
-        if name in all_filters or name in all_columns:
-            names.append(name)
-    w('<tr class="location-bar">')
-    w('<th align="left" colspan=%s>View customisation...</th></tr>\n'%
-        (len(names)+1))
-    w('<tr class="location-bar"><th>&nbsp;</th>')
-    for name in names:
-        w('<th>%s</th>'%name.capitalize())
-    w('</tr>\n')
-
-    # filter
-    if all_filters:
-        w('<tr><th width="1%" align=right class="location-bar">Filters</th>\n')
-        for name in names:
-            if name not in all_filters:
-                w('<td>&nbsp;</td>')
-                continue
-            if name in filter: checked=' checked'
-            else: checked=''
-            w('<td align=middle>\n')
-            w(' <input type="checkbox" name=":filter" value="%s" %s></td>\n'%(
-                name, checked))
-        w('</tr>\n')
-
-    # columns
-    if all_columns:
-        w('<tr><th width="1%" align=right class="location-bar">Columns</th>\n')
-        for name in names:
-            if name not in all_columns:
-                w('<td>&nbsp;</td>')
-                continue
-            if name in columns: checked=' checked'
-            else: checked=''
-            w('<td align=middle>\n')
-            w(' <input type="checkbox" name=":columns" value="%s" %s></td>\n'%(
-                name, checked))
-        w('</tr>\n')
-
-        # group
-        w('<tr><th width="1%" align=right class="location-bar">Grouping</th>\n')
-        for name in names:
-            prop = properties[name]
-            if name not in all_columns:
-                w('<td>&nbsp;</td>')
-                continue
-            if name in group: checked=' checked'
-            else: checked=''
-            w('<td align=middle>\n')
-            w(' <input type="checkbox" name=":group" value="%s" %s></td>\n'%(
-                name, checked))
-        w('</tr>\n')
-
-    w('<tr class="location-bar"><td width="1%">&nbsp;</td>')
-    w('<td colspan="%s">'%len(names))
-    w('<input type="submit" value="Redisplay"></td></tr>\n')
-    w('</table>\n')
-    w('</form>\n')
-
 
 #
 #   ITEM TEMPLATES
@@ -768,6 +790,9 @@ def newitem(client, templates, db, classname, form, replace=re.compile(
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.28  2001/10/21 00:00:16  richard
+# Fixed Checklist function - wasn't always working on a list.
+#
 # Revision 1.27  2001/10/20 12:13:44  richard
 # Fixed grouping of non-str properties (thanks Roch'e Compaan)
 #