1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: cgi_client.py,v 1.35 2001-10-21 00:17:54 richard Exp $
18+ # $Id: cgi_client.py,v 1.36 2001-10-21 04:44:50 richard Exp $
1919
2020import os , cgi , pprint , StringIO , urlparse , re , traceback , mimetypes
2121import base64 , Cookie , time
@@ -129,7 +129,7 @@ def index_arg(self, arg):
129129 return arg .value .split (',' )
130130 return []
131131
132- def index_filterspec (self ):
132+ def index_filterspec (self , filter ):
133133 ''' pull the index filter spec from the form
134134
135135 Links and multilinks want to be lists - the rest are straight
@@ -141,6 +141,7 @@ def index_filterspec(self):
141141 for key in self .form .keys ():
142142 if key [0 ] == ':' : continue
143143 if not props .has_key (key ): continue
144+ if key not in filter : continue
144145 prop = props [key ]
145146 value = self .form [key ]
146147 if (isinstance (prop , hyperdb .Link ) or
@@ -173,24 +174,32 @@ def customization_widget(self):
173174
174175 default_index_sort = ['-activity' ]
175176 default_index_group = ['priority' ]
176- default_index_filter = []
177+ default_index_filter = ['status' ]
177178 default_index_columns = ['id' ,'activity' ,'title' ,'status' ,'assignedto' ]
178179 default_index_filterspec = {'status' : ['1' , '2' , '3' , '4' , '5' , '6' , '7' ]}
179180 def index (self ):
180181 ''' put up an index
181182 '''
182183 self .classname = 'issue'
183- if self .form .has_key (':sort' ): sort = self .index_arg (':sort' )
184- else : sort = self .default_index_sort
185- if self .form .has_key (':group' ): group = self .index_arg (':group' )
186- else : group = self .default_index_group
187- if self .form .has_key (':filter' ): filter = self .index_arg (':filter' )
188- else : filter = self .default_index_filter
189- if self .form .has_key (':columns' ): columns = self .index_arg (':columns' )
190- else : columns = self .default_index_columns
191- filterspec = self .index_filterspec ()
192- if not filterspec :
184+ # see if the web has supplied us with any customisation info
185+ defaults = 1
186+ for key in ':sort' , ':group' , ':filter' , ':columns' :
187+ if self .form .has_key (key ):
188+ defaults = 0
189+ break
190+ if defaults :
191+ # no info supplied - use the defaults
192+ sort = self .default_index_sort
193+ group = self .default_index_group
194+ filter = self .default_index_filter
195+ columns = self .default_index_columns
193196 filterspec = self .default_index_filterspec
197+ else :
198+ sort = self .index_arg (':sort' )
199+ group = self .index_arg (':group' )
200+ filter = self .index_arg (':filter' )
201+ columns = self .index_arg (':columns' )
202+ filterspec = self .index_filterspec (filter )
194203 return self .list (columns = columns , filter = filter , group = group ,
195204 sort = sort , filterspec = filterspec )
196205
@@ -216,7 +225,7 @@ def list(self, sort=None, group=None, filter=None, columns=None,
216225 if group is None : group = self .index_arg (':group' )
217226 if filter is None : filter = self .index_arg (':filter' )
218227 if columns is None : columns = self .index_arg (':columns' )
219- if filterspec is None : filterspec = self .index_filterspec ()
228+ if filterspec is None : filterspec = self .index_filterspec (filter )
220229 if show_customization is None :
221230 show_customization = self .customization_widget ()
222231
@@ -676,7 +685,7 @@ class ExtendedClient(Client):
676685
677686 default_index_sort = ['-activity' ]
678687 default_index_group = ['priority' ]
679- default_index_filter = []
688+ default_index_filter = ['status' ]
680689 default_index_columns = ['activity' ,'status' ,'title' ,'assignedto' ]
681690 default_index_filterspec = {'status' : ['1' , '2' , '3' , '4' , '5' , '6' , '7' ]}
682691
@@ -699,8 +708,8 @@ def pagehead(self, title, message=None):
699708 if self .user not in (None , 'anonymous' ):
700709 userid = self .db .user .lookup (self .user )
701710 user_info = '''
702- <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> |
703- <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> |
711+ <a href="issue?assignedto=%s&status=-1, unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto &:sort=activity&:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">My Issues</a> |
712+ <a href="support?assignedto=%s&status=-1, unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:filter=status,assignedto &:sort=activity&:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">My Support</a> |
704713<a href="user%s">My Details</a> | <a href="logout">Logout</a>
705714''' % (userid , userid , userid )
706715 else :
@@ -725,11 +734,11 @@ def pagehead(self, title, message=None):
725734<td align=right valign=bottom>%s</td></tr>
726735<tr class="location-bar">
727736<td align=left>All
728- <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>,
729- <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>
737+ <a href="issue?status=-1, unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status &:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>,
738+ <a href="support?status=-1, unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status &:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
730739| Unassigned
731- <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>,
732- <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>
740+ <a href="issue?assignedto=-1 &status=-1, unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status,assignedto &:columns=id,activity,status,title,assignedto&:group=priority&show_customization=1">Issues</a>,
741+ <a href="support?assignedto=-1 &status=-1, unread,deferred,chatting,need-eg,in-progress,testing,done-cbb&:sort=activity&:filter=status,assignedto &:columns=id,activity,status,title,assignedto&:group=customername&show_customization=1">Support</a>
733742%s
734743%s</td>
735744<td align=right>%s</td>
@@ -758,14 +767,19 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
758767 value = date .Interval (form [key ].value .strip ())
759768 elif isinstance (proptype , hyperdb .Link ):
760769 value = form [key ].value .strip ()
761- # handle key values
762- link = cl .properties [key ].classname
763- if not num_re .match (value ):
764- try :
765- value = db .classes [link ].lookup (value )
766- except KeyError :
767- raise ValueError , 'property "%s": %s not a %s' % (
768- key , value , link )
770+ # see if it's the "no selection" choice
771+ if value == '-1' :
772+ # don't set this property
773+ continue
774+ else :
775+ # handle key values
776+ link = cl .properties [key ].classname
777+ if not num_re .match (value ):
778+ try :
779+ value = db .classes [link ].lookup (value )
780+ except KeyError :
781+ raise ValueError , 'property "%s": %s not a %s' % (
782+ key , value , link )
769783 elif isinstance (proptype , hyperdb .Multilink ):
770784 value = form [key ]
771785 if type (value ) != type ([]):
@@ -794,6 +808,10 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
794808
795809#
796810# $Log: not supported by cvs2svn $
811+ # Revision 1.35 2001/10/21 00:17:54 richard
812+ # CGI interface view customisation section may now be hidden (patch from
813+ # Roch'e Compaan.)
814+ #
797815# Revision 1.34 2001/10/20 11:58:48 richard
798816# Catch errors in login - no username or password supplied.
799817# Fixed editing of password (Password property type) thanks Roch'e Compaan.
0 commit comments