changeset 1134:16874c9b86ad

generic item editing
author Richard Jones <richard@users.sourceforge.net>
date Fri, 13 Sep 2002 01:28:54 +0000
parents 36ec30d286ea
children 645a7caa2e9c
files roundup/cgi/templating.py roundup/templates/classic/html/_generic.item
diffstat 2 files changed, 41 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Fri Sep 13 00:08:44 2002 +0000
+++ b/roundup/cgi/templating.py	Fri Sep 13 01:28:54 2002 +0000
@@ -193,12 +193,16 @@
         # we want config to be exposed
         self.config = client.db.config
 
+    def __getitem__(self, item):
+        self._client.db.getclass(item)
+        return HTMLClass(self._client, item)
+
     def __getattr__(self, attr):
         try:
-            self._client.db.getclass(attr)
+            return self[attr]
         except KeyError:
             raise AttributeError, attr
-        return HTMLClass(self._client, attr)
+
     def classes(self):
         l = self._client.db.classes.keys()
         l.sort()
@@ -857,7 +861,7 @@
             value = cgi.escape(value)
         return value
 
-    def field(self):
+    def field(self, showid=0, size=None):
         ''' Render a form edit field for the property
         '''
         linkcl = self._db.getclass(self._prop.classname)
@@ -865,11 +869,11 @@
             sort_on = 'order'  
         else:  
             sort_on = linkcl.labelprop()  
-        options = linkcl.filter(None, {}, [sort_on], []) 
+        options = linkcl.filter(None, {}, ('+', sort_on), (None, None))
         # TODO: make this a field display, not a menu one!
-        l = ['<select name="%s">'%property]
+        l = ['<select name="%s">'%self._name]
         k = linkcl.labelprop(1)
-        if value is None:
+        if self._value is None:
             s = 'selected '
         else:
             s = ''
@@ -877,7 +881,7 @@
         for optionid in options:
             option = linkcl.get(optionid, k)
             s = ''
-            if optionid == value:
+            if optionid == self._value:
                 s = 'selected '
             if showid:
                 lab = '%s%s: %s'%(self._prop.classname, optionid, option)
@@ -999,6 +1003,8 @@
         if value:
             value.sort(sortfunc)
         # map the id to the label property
+        if not linkcl.getkey():
+            showid=1
         if not showid:
             k = linkcl.labelprop(1)
             value = [linkcl.get(v, k) for v in value]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/roundup/templates/classic/html/_generic.item	Fri Sep 13 01:28:54 2002 +0000
@@ -0,0 +1,28 @@
+<form method="POST" onSubmit="return submit_once()"
+      enctype="multipart/form-data">
+
+<input type="hidden" name=":template" value="item">
+<input type="hidden" name=":required" value="title">
+
+<table class="form">
+
+<tr tal:repeat="prop python:db[context._classname].properties()">
+ <tal:block tal:condition="python:prop._name not in ('id', 'creator', 'created', 'activity')">
+  <th tal:content="prop/_name"></th>
+  <td tal:content="structure python:context[prop._name].field()"></td>
+ </tal:block>
+</tr>
+<tr>
+ <td>&nbsp;</td>
+ <td colspan=3 tal:content="structure context/submit">
+  submit button will go here
+ </td>
+</tr>
+</table>
+
+
+<tal:block tal:condition="context/id">
+ <tal:block tal:replace="structure context/history" />
+</tal:block>
+
+</form>

Roundup Issue Tracker: http://roundup-tracker.org/