~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/browser/bugtarget.py

Merge from devel

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    Bool,
48
48
    Choice,
49
49
    )
 
50
from zope.schema.interfaces import TooLong
50
51
from zope.schema.vocabulary import SimpleVocabulary
51
52
from zope.security.proxy import removeSecurityProxy
52
53
 
105
106
from lp.bugs.interfaces.apportjob import IProcessApportBlobJobSource
106
107
from lp.bugs.interfaces.bug import (
107
108
    CreateBugParams,
108
 
    IBug,
109
109
    IBugAddForm,
110
110
    IBugSet,
111
111
    IProjectGroupBugAddForm,
344
344
        # The comment field is only required if filing a new bug.
345
345
        if self.submit_bug_action.submitted():
346
346
            comment = data.get('comment')
347
 
            if comment:
348
 
                if len(comment) > IBug['description'].max_length:
349
 
                    self.setFieldError('comment',
350
 
                        'The description is too long. If you have lots '
351
 
                        'text to add, attach a file to the bug instead.')
352
 
            else:
353
 
                self.setFieldError('comment', "Required input is missing.")
 
347
            # The widget only exposes the error message. The private
 
348
            # attr contains the real error.
 
349
            widget_error = self.widgets.get('comment')._error
 
350
            if widget_error and isinstance(widget_error.errors, TooLong):
 
351
                self.setFieldError('comment',
 
352
                    'The description is too long. If you have lots '
 
353
                    'text to add, attach a file to the bug instead.')
 
354
            elif not comment or widget_error is not None:
 
355
                self.setFieldError(
 
356
                    'comment', "Provide details about the issue.")
354
357
        # Check a bug has been selected when the user wants to
355
358
        # subscribe to an existing bug.
356
359
        elif self.this_is_my_bug_action.submitted():