Mercurial > p > roundup > code
comparison roundup/cgi_client.py @ 312:5a2c43891c20
[SF#473124]: UI inconsistency with Link fields.
This also prompted me to fix a fairly long-standing usability issue -
that of being able to turn off certain filters.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sun, 21 Oct 2001 04:44:50 +0000 |
| parents | dac78e092228 |
| children | 489b70c37f32 |
comparison
equal
deleted
inserted
replaced
| 311:895a1c09f4ae | 312:5a2c43891c20 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 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 $ |
| 19 | 19 |
| 20 import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes | 20 import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes |
| 21 import base64, Cookie, time | 21 import base64, Cookie, time |
| 22 | 22 |
| 23 import roundupdb, htmltemplate, date, hyperdb, password | 23 import roundupdb, htmltemplate, date, hyperdb, password |
| 127 if type(arg) == type([]): | 127 if type(arg) == type([]): |
| 128 return [arg.value for arg in arg] | 128 return [arg.value for arg in arg] |
| 129 return arg.value.split(',') | 129 return arg.value.split(',') |
| 130 return [] | 130 return [] |
| 131 | 131 |
| 132 def index_filterspec(self): | 132 def index_filterspec(self, filter): |
| 133 ''' pull the index filter spec from the form | 133 ''' pull the index filter spec from the form |
| 134 | 134 |
| 135 Links and multilinks want to be lists - the rest are straight | 135 Links and multilinks want to be lists - the rest are straight |
| 136 strings. | 136 strings. |
| 137 ''' | 137 ''' |
| 139 # all the form args not starting with ':' are filters | 139 # all the form args not starting with ':' are filters |
| 140 filterspec = {} | 140 filterspec = {} |
| 141 for key in self.form.keys(): | 141 for key in self.form.keys(): |
| 142 if key[0] == ':': continue | 142 if key[0] == ':': continue |
| 143 if not props.has_key(key): continue | 143 if not props.has_key(key): continue |
| 144 if key not in filter: continue | |
| 144 prop = props[key] | 145 prop = props[key] |
| 145 value = self.form[key] | 146 value = self.form[key] |
| 146 if (isinstance(prop, hyperdb.Link) or | 147 if (isinstance(prop, hyperdb.Link) or |
| 147 isinstance(prop, hyperdb.Multilink)): | 148 isinstance(prop, hyperdb.Multilink)): |
| 148 if type(value) == type([]): | 149 if type(value) == type([]): |
| 171 | 172 |
| 172 return visible | 173 return visible |
| 173 | 174 |
| 174 default_index_sort = ['-activity'] | 175 default_index_sort = ['-activity'] |
| 175 default_index_group = ['priority'] | 176 default_index_group = ['priority'] |
| 176 default_index_filter = [] | 177 default_index_filter = ['status'] |
| 177 default_index_columns = ['id','activity','title','status','assignedto'] | 178 default_index_columns = ['id','activity','title','status','assignedto'] |
| 178 default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']} | 179 default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']} |
| 179 def index(self): | 180 def index(self): |
| 180 ''' put up an index | 181 ''' put up an index |
| 181 ''' | 182 ''' |
| 182 self.classname = 'issue' | 183 self.classname = 'issue' |
| 183 if self.form.has_key(':sort'): sort = self.index_arg(':sort') | 184 # see if the web has supplied us with any customisation info |
| 184 else: sort = self.default_index_sort | 185 defaults = 1 |
| 185 if self.form.has_key(':group'): group = self.index_arg(':group') | 186 for key in ':sort', ':group', ':filter', ':columns': |
| 186 else: group = self.default_index_group | 187 if self.form.has_key(key): |
| 187 if self.form.has_key(':filter'): filter = self.index_arg(':filter') | 188 defaults = 0 |
| 188 else: filter = self.default_index_filter | 189 break |
| 189 if self.form.has_key(':columns'): columns = self.index_arg(':columns') | 190 if defaults: |
| 190 else: columns = self.default_index_columns | 191 # no info supplied - use the defaults |
| 191 filterspec = self.index_filterspec() | 192 sort = self.default_index_sort |
| 192 if not filterspec: | 193 group = self.default_index_group |
| 194 filter = self.default_index_filter | |
| 195 columns = self.default_index_columns | |
| 193 filterspec = self.default_index_filterspec | 196 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) | |
| 194 return self.list(columns=columns, filter=filter, group=group, | 203 return self.list(columns=columns, filter=filter, group=group, |
| 195 sort=sort, filterspec=filterspec) | 204 sort=sort, filterspec=filterspec) |
| 196 | 205 |
| 197 # XXX deviates from spec - loses the '+' (that's a reserved character | 206 # XXX deviates from spec - loses the '+' (that's a reserved character |
| 198 # in URLS | 207 # in URLS |
| 214 self.pagehead('Index of %s'%cn) | 223 self.pagehead('Index of %s'%cn) |
| 215 if sort is None: sort = self.index_arg(':sort') | 224 if sort is None: sort = self.index_arg(':sort') |
| 216 if group is None: group = self.index_arg(':group') | 225 if group is None: group = self.index_arg(':group') |
| 217 if filter is None: filter = self.index_arg(':filter') | 226 if filter is None: filter = self.index_arg(':filter') |
| 218 if columns is None: columns = self.index_arg(':columns') | 227 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) |
| 220 if show_customization is None: | 229 if show_customization is None: |
| 221 show_customization = self.customization_widget() | 230 show_customization = self.customization_widget() |
| 222 | 231 |
| 223 htmltemplate.index(self, self.TEMPLATES, self.db, cn, filterspec, | 232 htmltemplate.index(self, self.TEMPLATES, self.db, cn, filterspec, |
| 224 filter, columns, sort, group, | 233 filter, columns, sort, group, |
| 674 newsupport = Client.newnode | 683 newsupport = Client.newnode |
| 675 newtimelog = Client.newnode | 684 newtimelog = Client.newnode |
| 676 | 685 |
| 677 default_index_sort = ['-activity'] | 686 default_index_sort = ['-activity'] |
| 678 default_index_group = ['priority'] | 687 default_index_group = ['priority'] |
| 679 default_index_filter = [] | 688 default_index_filter = ['status'] |
| 680 default_index_columns = ['activity','status','title','assignedto'] | 689 default_index_columns = ['activity','status','title','assignedto'] |
| 681 default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']} | 690 default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']} |
| 682 | 691 |
| 683 def pagehead(self, title, message=None): | 692 def pagehead(self, title, message=None): |
| 684 url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/') | 693 url = self.env['SCRIPT_NAME'] + '/' #self.env.get('PATH_INFO', '/') |
| 697 else: | 706 else: |
| 698 admin_links = '' | 707 admin_links = '' |
| 699 if self.user not in (None, 'anonymous'): | 708 if self.user not in (None, 'anonymous'): |
| 700 userid = self.db.user.lookup(self.user) | 709 userid = self.db.user.lookup(self.user) |
| 701 user_info = ''' | 710 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> | | 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> | |
| 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> | | 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> | |
| 704 <a href="user%s">My Details</a> | <a href="logout">Logout</a> | 713 <a href="user%s">My Details</a> | <a href="logout">Logout</a> |
| 705 '''%(userid, userid, userid) | 714 '''%(userid, userid, userid) |
| 706 else: | 715 else: |
| 707 user_info = '<a href="login">Login</a>' | 716 user_info = '<a href="login">Login</a>' |
| 708 if self.user is not None: | 717 if self.user is not None: |
| 723 <table width=100%% border=0 cellspacing=0 cellpadding=2> | 732 <table width=100%% border=0 cellspacing=0 cellpadding=2> |
| 724 <tr class="location-bar"><td><big><strong>%s</strong></big></td> | 733 <tr class="location-bar"><td><big><strong>%s</strong></big></td> |
| 725 <td align=right valign=bottom>%s</td></tr> | 734 <td align=right valign=bottom>%s</td></tr> |
| 726 <tr class="location-bar"> | 735 <tr class="location-bar"> |
| 727 <td align=left>All | 736 <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>, | 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>, |
| 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> | 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> |
| 730 | Unassigned | 739 | 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>, | 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>, |
| 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> | 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> |
| 733 %s | 742 %s |
| 734 %s</td> | 743 %s</td> |
| 735 <td align=right>%s</td> | 744 <td align=right>%s</td> |
| 736 </table> | 745 </table> |
| 737 '''%(title, style, message, title, user_name, add_links, admin_links, | 746 '''%(title, style, message, title, user_name, add_links, admin_links, |
| 756 value = date.Date(form[key].value.strip()) | 765 value = date.Date(form[key].value.strip()) |
| 757 elif isinstance(proptype, hyperdb.Interval): | 766 elif isinstance(proptype, hyperdb.Interval): |
| 758 value = date.Interval(form[key].value.strip()) | 767 value = date.Interval(form[key].value.strip()) |
| 759 elif isinstance(proptype, hyperdb.Link): | 768 elif isinstance(proptype, hyperdb.Link): |
| 760 value = form[key].value.strip() | 769 value = form[key].value.strip() |
| 761 # handle key values | 770 # see if it's the "no selection" choice |
| 762 link = cl.properties[key].classname | 771 if value == '-1': |
| 763 if not num_re.match(value): | 772 # don't set this property |
| 764 try: | 773 continue |
| 765 value = db.classes[link].lookup(value) | 774 else: |
| 766 except KeyError: | 775 # handle key values |
| 767 raise ValueError, 'property "%s": %s not a %s'%( | 776 link = cl.properties[key].classname |
| 768 key, value, link) | 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) | |
| 769 elif isinstance(proptype, hyperdb.Multilink): | 783 elif isinstance(proptype, hyperdb.Multilink): |
| 770 value = form[key] | 784 value = form[key] |
| 771 if type(value) != type([]): | 785 if type(value) != type([]): |
| 772 value = [i.strip() for i in value.value.split(',')] | 786 value = [i.strip() for i in value.value.split(',')] |
| 773 else: | 787 else: |
| 792 props[key] = value | 806 props[key] = value |
| 793 return props, changed | 807 return props, changed |
| 794 | 808 |
| 795 # | 809 # |
| 796 # $Log: not supported by cvs2svn $ | 810 # $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 # | |
| 797 # Revision 1.34 2001/10/20 11:58:48 richard | 815 # Revision 1.34 2001/10/20 11:58:48 richard |
| 798 # Catch errors in login - no username or password supplied. | 816 # Catch errors in login - no username or password supplied. |
| 799 # Fixed editing of password (Password property type) thanks Roch'e Compaan. | 817 # Fixed editing of password (Password property type) thanks Roch'e Compaan. |
| 800 # | 818 # |
| 801 # Revision 1.33 2001/10/17 00:18:41 richard | 819 # Revision 1.33 2001/10/17 00:18:41 richard |
