예제 #1
0
    def _createNote(self,
                    comment,
                    fromname=None,
                    email=None,
                    acl_adder=None,
                    public=False,
                    display_format='',
                    block_id='',
                    REQUEST=None):

        # the comment can not be blank
        if not comment:
            raise IssueNoteError("Note comment can not be empty")

        if threadID:
            try:
                thread = getattr(self, threadID)
            except AttributeError:
                raise ValueError("thread does not exist")

        # test if the comment doesn't already exist
        for note in self.findNotes(comment=comment,
                                   fromname=fromname,
                                   email=email,
                                   acl_adder=acl_adder,
                                   threadID=threadID):
            # already created
            # perhaps user doubleclick the submit button
            return note

        randomid_length = self.randomid_length
        if randomid_length > 3:
            randomid_length = 3
        genid = self.generateID(randomid_length,
                                prefix=self.issueprefix + 'note',
                                meta_type=ISSUENOTE_METATYPE,
                                use_stored_counter=False)

        from Products.IssueTrackerProduct.Note import IssueNote
        # create a note inside this issue
        note = IssueNote(genid,
                         title,
                         comment,
                         fromname,
                         email,
                         display_format=display_format,
                         acl_adder=acl_adder,
                         threadID=threadID)
        self._setObject(genid, note)
        note = self._getOb(genid)
        note.index_object()

        return note
예제 #2
0
    def test_note_creation_basic(self):
        """create a note inside an issue and to a followup in that issue."""

        # make an issue
        title = u"Fat people"
        description = u"bla bla bla"

        tracker = self.folder.tracker
        request = self.app.REQUEST
        request.set('title', title)
        request.set('fromname', u'B\xc3\xa9b')
        request.set('email', u'*****@*****.**')
        request.set('description', description)
        request.set('type', tracker.getDefaultType())
        request.set('urgency', tracker.getDefaultUrgency())

        tracker.SubmitIssue(request)
        issue = tracker.getIssueObjects()[0]

        from Products.IssueTrackerProduct.Note import IssueNote
        # create a note inside this issue
        note = IssueNote('1', u'A note about something',
                         u"Some note about something which is a long string",
                         u'B\xc3\xa9b', '*****@*****.**')
        issue._setObject('1', note)
        note = issue._getOb('1')
        note.index_object()

        self.assertEqual(note.getFromname(), u'B\xc3\xa9b')
        self.assertEqual(note.getEmail(), u'*****@*****.**')
        self.assertEqual(note.getACLAdder(), '')

        self.assertEqual(list(issue.getNotes()), [note])
예제 #3
0
 def _createNote(self, comment, fromname=None, email=None, acl_adder=None,
                 public=False, display_format='', block_id='',
                 REQUEST=None):
     
     # the comment can not be blank
     if not comment:
         raise IssueNoteError("Note comment can not be empty")
     
     if threadID:
         try:
             thread = getattr(self, threadID)
         except AttributeError:
             raise ValueError("thread does not exist")
     
             
     # test if the comment doesn't already exist
     for note in self.findNotes(comment=comment,
                                 fromname=fromname, email=email,
                                 acl_adder=acl_adder,
                                 threadID=threadID):
         # already created
         # perhaps user doubleclick the submit button
         return note
         
     randomid_length = self.randomid_length
     if randomid_length > 3:
         randomid_length = 3
     genid = self.generateID(randomid_length,
                             prefix=self.issueprefix + 'note',
                             meta_type=ISSUENOTE_METATYPE,
                             use_stored_counter=False)
     
     from Products.IssueTrackerProduct.Note import IssueNote
     # create a note inside this issue
     note = IssueNote(genid, title, comment, fromname, email,
                      display_format=display_format,
                      acl_adder=acl_adder, threadID=threadID
                      )
     self._setObject(genid, note)
     note = self._getOb(genid)
     note.index_object()
     
     return note
예제 #4
0
 def test_note_creation_basic(self):
     """create a note inside an issue and to a followup in that issue."""
     
     # make an issue
     title = u"Fat people"
     description = u"bla bla bla"
     
     tracker = self.folder.tracker
     request = self.app.REQUEST
     request.set('title', title)
     request.set('fromname', u'B\xc3\xa9b')
     request.set('email', u'*****@*****.**')
     request.set('description', description)
     request.set('type', tracker.getDefaultType())
     request.set('urgency', tracker.getDefaultUrgency())
     
     tracker.SubmitIssue(request)
     issue = tracker.getIssueObjects()[0]
     
     from Products.IssueTrackerProduct.Note import IssueNote
     # create a note inside this issue
     note = IssueNote('1', u'A note about something',
                      u"Some note about something which is a long string",
                      u'B\xc3\xa9b',
                      '*****@*****.**'
                      )
     issue._setObject('1', note)
     note = issue._getOb('1')
     note.index_object()
     
     self.assertEqual(note.getFromname(),
                      u'B\xc3\xa9b')
     self.assertEqual(note.getEmail(),
                      u'*****@*****.**')
     self.assertEqual(note.getACLAdder(), '')
     
     self.assertEqual(list(issue.getNotes()),
                      [note])