Code

generic item editing
authorrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Fri, 13 Sep 2002 01:28:54 +0000 (01:28 +0000)
committerrichard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2>
Fri, 13 Sep 2002 01:28:54 +0000 (01:28 +0000)
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1156 57a73879-2fb5-44c3-a270-3262357dd7e2

roundup/cgi/templating.py
roundup/templates/classic/html/_generic.item [new file with mode: 0644]

index 81d10ac83241ffca52207c118d09dd2c57195395..8f63d3a8576c24897cb600d89e3cd194f82144f8 100644 (file)
@@ -193,12 +193,16 @@ class HTMLDatabase:
         # 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 @@ class LinkHTMLProperty(HTMLProperty):
             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 @@ class LinkHTMLProperty(HTMLProperty):
             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 @@ class LinkHTMLProperty(HTMLProperty):
         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 @@ class MultilinkHTMLProperty(HTMLProperty):
         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]
diff --git a/roundup/templates/classic/html/_generic.item b/roundup/templates/classic/html/_generic.item
new file mode 100644 (file)
index 0000000..4c0810f
--- /dev/null
@@ -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>