コード例 #1
0
ファイル: bugtask.py プロジェクト: pombreda/UnnaturalCodeFork
 def __init__(self, field, vocabulary, request):
     RadioWidget.__init__(self, field, vocabulary, request)
     self.url_widget = CustomWidgetFactory(URIWidget)
     setUpWidget(
         self, 'url', BugWatchEditForm['url'], IInputWidget,
         context=field.context)
     self.setUpJavascript()
コード例 #2
0
ファイル: bugtask.py プロジェクト: pombreda/UnnaturalCodeFork
 def __init__(self, field, vocabulary, request):
     RadioWidget.__init__(self, field, vocabulary, request)
     self.url_widget = CustomWidgetFactory(URIWidget)
     setUpWidget(self,
                 'url',
                 BugWatchEditForm['url'],
                 IInputWidget,
                 context=field.context)
     self.setUpJavascript()
コード例 #3
0
ファイル: bugtask.py プロジェクト: pombreda/UnnaturalCodeFork
    def _toFieldValue(self, form_value):
        """Convert the textual token to a field value.

        If the form value is _new_bugwatch_value, create a new bug
        watch, otherwise look up an existing one.
        """
        if form_value == self._new_bugwatch_value:
            try:
                url = self.url_widget.getInputValue()
                bugtracker, remote_bug = getUtility(
                    IBugWatchSet).extractBugTrackerAndBug(url)
                bugtask = self.context.context
                return bugtask.bug.addWatch(bugtracker, remote_bug,
                                            getUtility(ILaunchBag).user)
            except WidgetInputError as error:
                # Prefix the error with the widget name, since the error
                # will be display at the top of the page, and not right
                # next to the widget.
                raise WidgetInputError(self.context.__name__, self.label,
                                       'Remote Bug: %s' % error.doc())
            except (NoBugTrackerFound, UnrecognizedBugTrackerURL) as error:
                raise WidgetInputError(self.context.__name__, self.label,
                                       'Invalid bug tracker URL.')
        else:
            return RadioWidget._toFieldValue(self, form_value)
コード例 #4
0
ファイル: bugtask.py プロジェクト: pombreda/UnnaturalCodeFork
    def _toFieldValue(self, form_value):
        """Convert the textual token to a field value.

        If the form value is _new_bugwatch_value, create a new bug
        watch, otherwise look up an existing one.
        """
        if form_value == self._new_bugwatch_value:
            try:
                url = self.url_widget.getInputValue()
                bugtracker, remote_bug = getUtility(
                    IBugWatchSet).extractBugTrackerAndBug(url)
                bugtask = self.context.context
                return bugtask.bug.addWatch(
                    bugtracker, remote_bug, getUtility(ILaunchBag).user)
            except WidgetInputError as error:
                # Prefix the error with the widget name, since the error
                # will be display at the top of the page, and not right
                # next to the widget.
                raise WidgetInputError(
                    self.context.__name__, self.label,
                    'Remote Bug: %s' % error.doc())
            except (NoBugTrackerFound, UnrecognizedBugTrackerURL) as error:
                raise WidgetInputError(
                    self.context.__name__, self.label,
                    'Invalid bug tracker URL.')
        else:
            return RadioWidget._toFieldValue(self, form_value)
コード例 #5
0
ファイル: boolwidgets.py プロジェクト: Vinsurya/Plone
def BooleanRadioWidget(field, request, true=_('on'), false=_('off')):
    vocabulary = SimpleVocabulary.fromItems( ((true, True), (false, False)) ) 
    widget = RadioWidget(field, vocabulary, request)
    widget.required = False
    return widget
コード例 #6
0
ファイル: bugtask.py プロジェクト: pombreda/UnnaturalCodeFork
 def setPrefix(self, prefix):
     RadioWidget.setPrefix(self, prefix)
     self.url_widget.setPrefix(prefix)
     self.setUpJavascript()
コード例 #7
0
def BooleanRadioWidget(field, request, true=_('on'), false=_('off')):
    vocabulary = SimpleVocabulary.fromItems(((true, True), (false, False)))
    widget = RadioWidget(field, vocabulary, request)
    widget.required = False
    return widget
コード例 #8
0
ファイル: bugtask.py プロジェクト: pombreda/UnnaturalCodeFork
 def setPrefix(self, prefix):
     RadioWidget.setPrefix(self, prefix)
     self.url_widget.setPrefix(prefix)
     self.setUpJavascript()