예제 #1
0
    def doBulk(self):
        qidxes = self.ui.bugList.selectionModel().selectedIndexes()
        cols = set(qidx.column() for qidx in qidxes)
        if len(cols) != 1:
            return

        col, = cols
        colname = self.mdl.headerData(col, Qt.Horizontal, Qt.DisplayRole)
        if colname not in ('status', 'assignee'):
            return

        objs = [qidx.data(ResultModel.RoleObject) for qidx in qidxes]
        project = objs[0].project
        if colname == 'status':
            vals = [status.name for status in project.statuses or []]
            val, ok = QInputDialog.getItem(self, self.tr('Bulk edit'), self.tr('Select new status for selected items'), vals, 0, False)
        elif colname == 'assignee':
            vals = [user.name for user in project.members or []]
            val, ok = QInputDialog.getItem(self, self.tr('Bulk edit'), self.tr('Select new assignee for selected items'), vals, 0, False)
        if not ok:
            return

        for obj in objs:
            change = Change()
            change.field = colname
            change.new = val

            update = Update()
            update.changes = [change]

            self.weboob.do('update_issue', obj, update, backends=(obj.backend,))
예제 #2
0
    def get_issue(self, issue):
        if isinstance(issue, Issue):
            id = issue.id
        else:
            id = issue
            issue = Issue(issue)

        try:
            with self.browser:
                params = self.browser.get_issue(id)
        except BrowserHTTPNotFound:
            return None

        issue.project = self._build_project(params['project'])
        issue.title = params['subject']
        issue.body = params['body']
        issue.creation = params['created_on']
        issue.updated = params['updated_on']
        issue.start = params['start_date']
        issue.due = params['due_date']
        issue.fields = {}
        for key, value in params['fields'].iteritems():
            issue.fields[key] = value
        issue.attachments = []
        for a in params['attachments']:
            attachment = Attachment(a['id'])
            attachment.filename = a['filename']
            attachment.url = a['url']
            issue.attachments.append(attachment)
        issue.history = []
        for u in params['updates']:
            update = Update(u['id'])
            update.author = issue.project.find_user(*u['author'])
            update.date = u['date']
            update.message = u['message']
            update.changes = []
            for i, (field, last, new) in enumerate(u['changes']):
                change = Change(i)
                change.field = field
                change.last = last
                change.new = new
                update.changes.append(change)
            issue.history.append(update)
        issue.author = issue.project.find_user(*params['author'])
        issue.assignee = issue.project.find_user(*params['assignee'])
        issue.tracker = params['tracker'][1]
        issue.category = params['category'][1]
        issue.version = issue.project.find_version(*params['version'])
        issue.status = issue.project.find_status(params['status'][1])
        issue.priority = params['priority'][1]

        return issue
예제 #3
0
파일: module.py 프로젝트: guix77/weboob
    def _make_update(self, d, project):
        u = Update(d['id'])
        u.author = project.find_user(d['author'], None)
        if not u.author:
            # may duplicate users
            u.author = User(d['author'], d['author'])
        u.date = d['date']

        c = Change()
        c.field = d['field']
        c.last = d['old']
        c.new = d['new']

        u.changes = [c]
        return u
예제 #4
0
파일: module.py 프로젝트: laurentb/weboob
    def _make_update(self, d, project):
        u = Update(d['id'])
        u.author = project.find_user(d['author'], None)
        if not u.author:
            # may duplicate users
            u.author = User(d['author'], d['author'])
        u.date = d['date']

        c = Change()
        c.field = d['field']
        c.last = d['old']
        c.new = d['new']

        u.changes = [c]
        return u
예제 #5
0
    def doBulk(self):
        qidxes = self.ui.bugList.selectionModel().selectedIndexes()
        cols = set(qidx.column() for qidx in qidxes)
        if len(cols) != 1:
            return

        col, = cols
        colname = self.mdl.headerData(col, Qt.Horizontal, Qt.DisplayRole)
        if colname not in ('status', 'assignee'):
            return

        objs = [qidx.data(ResultModel.RoleObject) for qidx in qidxes]
        project = objs[0].project
        if colname == 'status':
            vals = [status.name for status in project.statuses or []]
            val, ok = QInputDialog.getItem(
                self, self.tr('Bulk edit'),
                self.tr('Select new status for selected items'), vals, 0,
                False)
        elif colname == 'assignee':
            vals = [user.name for user in project.members or []]
            val, ok = QInputDialog.getItem(
                self, self.tr('Bulk edit'),
                self.tr('Select new assignee for selected items'), vals, 0,
                False)
        if not ok:
            return

        for obj in objs:
            change = Change()
            change.field = colname
            change.new = val

            update = Update()
            update.changes = [change]

            self.weboob.do('update_issue',
                           obj,
                           update,
                           backends=(obj.backend, ))