Beispiel #1
0
 def saveReview(self, revision_key, approvals, message, upload, submit):
     message_keys = self.app.saveReviews([revision_key], approvals, message,
                                         upload, submit)
     if upload:
         for message_key in message_keys:
             self.app.sync.submitTask(
                 sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY))
     self.refresh()
Beispiel #2
0
 def closeReview(self, dialog, rows, upload, submit):
     approvals, message = dialog.getValues()
     revision_keys = [row.current_revision_key for row in rows]
     message_keys = self.app.saveReviews(revision_keys, approvals, message,
                                         upload, submit)
     if upload:
         for message_key in message_keys:
             self.app.sync.submitTask(
                 sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY))
     self.refresh()
     self.app.backScreen()
Beispiel #3
0
 def toggleHeldChange(self, change_key):
     with self.db.getSession() as session:
         change = session.getChange(change_key)
         change.held = not change.held
         ret = change.held
         if not change.held:
             for r in change.revisions:
                 for m in change.messages:
                     if m.pending:
                         self.sync.submitTask(
                             sync.UploadReviewTask(m.key, sync.HIGH_PRIORITY))
     self.updateStatusQueries()
     return ret
Beispiel #4
0
    def saveReview(self, revision_key, approvals, message, upload):
        message_key = None
        with self.app.db.getSession() as session:
            account = session.getAccountByUsername(self.app.config.username)
            revision = session.getRevision(revision_key)
            change = revision.change
            draft_approvals = {}
            for approval in change.draft_approvals:
                draft_approvals[approval.category] = approval

            categories = set()
            for label in change.permitted_labels:
                categories.add(label.category)
            for category in categories:
                value = approvals.get(category, 0)
                approval = draft_approvals.get(category)
                if not approval:
                    approval = change.createApproval(account,
                                                     category,
                                                     0,
                                                     draft=True)
                    draft_approvals[category] = approval
                approval.value = value
            draft_message = revision.getPendingMessage()
            if not draft_message:
                draft_message = revision.getDraftMessage()
            if not draft_message:
                if message or upload:
                    draft_message = revision.createMessage(
                        None,
                        account,
                        datetime.datetime.utcnow(),
                        '',
                        draft=True)
            if draft_message:
                draft_message.created = datetime.datetime.utcnow()
                draft_message.message = message
                draft_message.pending = upload
                message_key = draft_message.key
            if upload:
                change.reviewed = True
        # Outside of db session
        if upload:
            self.app.sync.submitTask(
                sync.UploadReviewTask(message_key, sync.HIGH_PRIORITY))
        self.refresh()