Mercurial > p > roundup > code
comparison roundup/htmltemplate.py @ 306:36ae7ffb8a42
Fixed Checklist function - wasn't always working on a list.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Sun, 21 Oct 2001 00:00:16 +0000 |
| parents | 3d5031f834f0 |
| children | dac78e092228 |
comparison
equal
deleted
inserted
replaced
| 305:cb6d168b5aaa | 306:36ae7ffb8a42 |
|---|---|
| 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: htmltemplate.py,v 1.27 2001-10-20 12:13:44 richard Exp $ | 18 # $Id: htmltemplate.py,v 1.28 2001-10-21 00:00:16 richard Exp $ |
| 19 | 19 |
| 20 import os, re, StringIO, urllib, cgi, errno | 20 import os, re, StringIO, urllib, cgi, errno |
| 21 | 21 |
| 22 import hyperdb, date, password | 22 import hyperdb, date, password |
| 23 | 23 |
| 303 ''' for a Link or Multilink property, display checkboxes for the available | 303 ''' for a Link or Multilink property, display checkboxes for the available |
| 304 choices to permit filtering | 304 choices to permit filtering |
| 305 ''' | 305 ''' |
| 306 def __call__(self, property, **args): | 306 def __call__(self, property, **args): |
| 307 propclass = self.properties[property] | 307 propclass = self.properties[property] |
| 308 if (not isinstance(propclass, hyperdb.Link) and not | |
| 309 isinstance(propclass, hyperdb.Multilink)): | |
| 310 return '[Checklist: not a link]' | |
| 311 | |
| 312 # get our current checkbox state | |
| 308 if self.nodeid: | 313 if self.nodeid: |
| 309 value = self.cl.get(self.nodeid, property) | 314 # get the info from the node - make sure it's a list |
| 315 if isinstance(propclass, hyperdb.Link: | |
| 316 value = [self.cl.get(self.nodeid, property)] | |
| 317 else: | |
| 318 value = self.cl.get(self.nodeid, property) | |
| 310 elif self.filterspec is not None: | 319 elif self.filterspec is not None: |
| 320 # get the state from the filter specification (always a list) | |
| 311 value = self.filterspec.get(property, []) | 321 value = self.filterspec.get(property, []) |
| 312 else: | 322 else: |
| 323 # it's a new node, so there's no state | |
| 313 value = [] | 324 value = [] |
| 314 if (isinstance(propclass, hyperdb.Link) or | 325 |
| 315 isinstance(propclass, hyperdb.Multilink)): | 326 # so we can map to the linked node's "lable" property |
| 316 linkcl = self.db.classes[propclass.classname] | 327 linkcl = self.db.classes[propclass.classname] |
| 317 l = [] | 328 l = [] |
| 318 k = linkcl.labelprop() | 329 k = linkcl.labelprop() |
| 319 for optionid in linkcl.list(): | 330 for optionid in linkcl.list(): |
| 320 option = linkcl.get(optionid, k) | 331 option = linkcl.get(optionid, k) |
| 321 if optionid in value or option in value: | 332 if optionid in value or option in value: |
| 322 checked = 'checked' | 333 checked = 'checked' |
| 323 else: | 334 else: |
| 324 checked = '' | 335 checked = '' |
| 325 l.append('%s:<input type="checkbox" %s name="%s" value="%s">'%( | 336 l.append('%s:<input type="checkbox" %s name="%s" value="%s">'%( |
| 326 option, checked, property, option)) | 337 option, checked, property, option)) |
| 327 return '\n'.join(l) | 338 return '\n'.join(l) |
| 328 return '[Checklist: not a link]' | |
| 329 | 339 |
| 330 class Note(Base): | 340 class Note(Base): |
| 331 ''' display a "note" field, which is a text area for entering a note to | 341 ''' display a "note" field, which is a text area for entering a note to |
| 332 go along with a change. | 342 go along with a change. |
| 333 ''' | 343 ''' |
| 756 w(replace.go(s)) | 766 w(replace.go(s)) |
| 757 w('</form>') | 767 w('</form>') |
| 758 | 768 |
| 759 # | 769 # |
| 760 # $Log: not supported by cvs2svn $ | 770 # $Log: not supported by cvs2svn $ |
| 771 # Revision 1.27 2001/10/20 12:13:44 richard | |
| 772 # Fixed grouping of non-str properties (thanks Roch'e Compaan) | |
| 773 # | |
| 761 # Revision 1.26 2001/10/14 10:55:00 richard | 774 # Revision 1.26 2001/10/14 10:55:00 richard |
| 762 # Handle empty strings in HTML template Link function | 775 # Handle empty strings in HTML template Link function |
| 763 # | 776 # |
| 764 # Revision 1.25 2001/10/09 07:25:59 richard | 777 # Revision 1.25 2001/10/09 07:25:59 richard |
| 765 # Added the Password property type. See "pydoc roundup.password" for | 778 # Added the Password property type. See "pydoc roundup.password" for |
