[Zope3-checkins] CVS: zopeproducts/bugtracker/browser - bug.py:1.10

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Aug 13 00:42:22 EDT 2003


Update of /cvs-repository/zopeproducts/bugtracker/browser
In directory cvs.zope.org:/tmp/cvs-serv30964/src/zopeproducts/bugtracker/browser

Modified Files:
	bug.py 
Log Message:
- Updated TOdo. It nwo just links to the online bug tracker.

- Vocabulary widgets display now vocabulary default.

- Whitespace.


=== zopeproducts/bugtracker/browser/bug.py 1.9 => 1.10 ===
--- zopeproducts/bugtracker/browser/bug.py:1.9	Tue Aug 12 14:55:11 2003
+++ zopeproducts/bugtracker/browser/bug.py	Tue Aug 12 23:41:48 2003
@@ -22,7 +22,7 @@
 from zope.interface import implements
 from zope.proxy import removeAllProxies
 from zope.schema.vocabulary import getVocabularyRegistry
-from zope.app.browser.form.vocabularywidget import VocabularyFieldEditWidget
+from zope.app.browser.form.vocabularywidget import VocabularyEditWidget
 from zope.app.browser.form.widget import TextWidget, TextAreaWidget
 from zope.app.context import ContextWrapper
 from zope.app.form.widget import CustomWidget
@@ -120,15 +120,32 @@
         return map(lambda owner: users.getTerm(owner), self.context.owners)
 
 
+
+# Make a custom widget for the vocabulary, so that default values are
+# retrieved from the vocabulary and not the field.
+class _ManagableVocabularyEditWidget(VocabularyEditWidget):
+    size=1
+
+    def _getDefault(self):
+        # Return the default value for this widget;
+        # may be overridden by subclasses.
+        return self.vocabulary.default.value
+
+def ManagableVocabularyEditWidget(field, request):
+    widget = _ManagableVocabularyEditWidget(field.vocabulary, request)
+    widget.setField(field)
+    return widget
+
+
 class BugForm(object):
     
-    type_widget = CustomWidget(VocabularyFieldEditWidget, size=1)
+    type_widget = CustomWidget(ManagableVocabularyEditWidget)
 
-    status_widget = CustomWidget(VocabularyFieldEditWidget, size=1)
+    status_widget = CustomWidget(ManagableVocabularyEditWidget)
 
-    priority_widget = CustomWidget(VocabularyFieldEditWidget, size=1)
+    priority_widget = CustomWidget(ManagableVocabularyEditWidget)
 
-    release_widget = CustomWidget(VocabularyFieldEditWidget, size=1)
+    release_widget = CustomWidget(ManagableVocabularyEditWidget)
 
     title_widget = CustomWidget(TextWidget, style="width: 80%")
 
@@ -239,11 +256,13 @@
 
     def canChangeDependencies(self):
         pid = self.request.user.getId()
+        # 100% buggy!
         roles = principalRoleManager.getRolesForPrincipal(pid)
         roles = filter(lambda r: r[1] == Allow, roles)
         roles = map(lambda r: r[0], roles)
-        return 'bugtracker.Editor' in roles
-
+        #return 'bugtracker.Editor' in roles
+        return True
+    
     legend = ViewPageTemplateFile('legend.pt')
 
 




More information about the Zope3-Checkins mailing list