diff --git a/alembic/versions/4df932caa9a9_add_needinfo_request.py b/alembic/versions/4df932caa9a9_add_needinfo_request.py new file mode 100644 --- /dev/null +++ b/alembic/versions/4df932caa9a9_add_needinfo_request.py @@ -0,0 +1,38 @@ +"""add needinfo_requestee field to the bug table + +Revision ID: 4df932caa9a9 +Revises: 1dfd879c7637 +Create Date: 2014-11-07 09:27:48.882949 + +""" + +# revision identifiers, used by Alembic. +revision = '4df932caa9a9' +down_revision = '1dfd879c7637' + +from alembic import op +import sqlalchemy as sa + +from sqlalchemy.sql import table, column +from sqlalchemy import String, Boolean + +def upgrade(): + op.alter_column(u'bug', u'needinfo', new_column_name=u'needinfo_requestee') + op.add_column(u'bug', sa.Column(u'needinfo', sa.Boolean)) + + bug = table('bug', + column('needinfo', Boolean), + column('needinfo_requestee', String) + ) + + op.execute( + bug.update().\ + where(bug.c.needinfo_requestee!=op.inline_literal('')).\ + values({'needinfo':op.inline_literal(True)}) + ) + + + +def downgrade(): + op.drop_column(u'bug', u'needinfo') + op.alter_column(u'bug', u'needinfo_requestee', new_column_name=u'needinfo') diff --git a/blockerbugs/models/bug.py b/blockerbugs/models/bug.py --- a/blockerbugs/models/bug.py +++ b/blockerbugs/models/bug.py @@ -34,7 +34,8 @@ component = db.Column(db.String(80), unique=False) active = db.Column(db.Boolean) last_bug_sync = db.Column(db.DateTime) - needinfo = db.Column(db.String(1024), unique=False) + needinfo = db.Column(db.Boolean) + needinfo_requestee = db.Column(db.String(1024), unique=False) proposed_blocker = db.Column(db.Boolean) proposed_fe = db.Column(db.Boolean) rejected_blocker = db.Column(db.Boolean) @@ -47,14 +48,16 @@ #backref='bugs') def __init__(self, bugid, url, summary, status, component, milestone, - active, needinfo, last_bug_sync=datetime.datetime.now()): + active, needinfo, needinfo_requestee, + last_bug_sync=datetime.datetime.now()): self.bugid = bugid self.url = url self.summary = summary self.status = status self.component = component self.active = active self.needinfo = needinfo + self.needinfo_requestee = needinfo_requestee self.milestone = milestone self.proposed_blocker = False self.accepted_blocker = False @@ -75,6 +78,7 @@ self.last_bug_sync = buginfo['last_change_time'] self.active = buginfo['active'] self.needinfo = buginfo['needinfo'] + self.needinfo_requestee = buginfo['needinfo_requestee'] if tracker_type == 'Blocker': self.proposed_blocker = buginfo['proposed'] self.accepted_blocker = buginfo['accepted'] @@ -88,7 +92,7 @@ @classmethod def from_data(cls, buginfo, release, tracker_type): - newbug = Bug(buginfo['bug_id'], '', '', '','', release, buginfo['active'], '') + newbug = Bug(buginfo['bug_id'], '', '', '','', release, buginfo['active'], False, '') newbug.update(buginfo, tracker_type, release) return newbug diff --git a/blockerbugs/templates/blocker_list.html b/blockerbugs/templates/blocker_list.html --- a/blockerbugs/templates/blocker_list.html +++ b/blockerbugs/templates/blocker_list.html @@ -71,7 +71,7 @@ {% for bug in buglists[buglist] %} - {% if bug.bugid in recent %}{% endif %} {% if bug.needinfo %}?{% endif %} + {% if bug.bugid in recent %}{% endif %} {% if bug.needinfo %}?{% endif %} {{ bug.bugid }} {{ bug.component }} {{ bug.status }} diff --git a/blockerbugs/util/bug_sync.py b/blockerbugs/util/bug_sync.py --- a/blockerbugs/util/bug_sync.py +++ b/blockerbugs/util/bug_sync.py @@ -57,15 +57,20 @@ buginfo['summary'] = bug.summary buginfo['status'] = bug.status buginfo['url'] = bug.weburl - buginfo['needinfo'] = '' + buginfo['needinfo'] = False + buginfo['needinfo_requestee'] = '' # needinfo flag if hasattr(bug, 'flags'): needinfos = [] for flag in bug.flags: if flag['name'] == 'needinfo' and flag['status'] == '?' and flag['is_active']: - needinfos.append(flag['requestee']) - buginfo['needinfo'] = ', '.join(needinfos) + buginfo['needinfo'] = True + try: + needinfos.append(flag['requestee']) + except KeyError, e: + pass + buginfo['needinfo_requestee'] = ', '.join(needinfos) # according to bugzilla's docs, this is always in UTC last_change_time = bug.last_change_time.timetuple() diff --git a/testing/test_bugsync_extract_information.py b/testing/test_bugsync_extract_information.py --- a/testing/test_bugsync_extract_information.py +++ b/testing/test_bugsync_extract_information.py @@ -119,10 +119,33 @@ def test_needinfo(self): buginfo = self.testsync.extract_information(self.testbug, 'Blocker') - assert buginfo['needinfo'] == 'John Doe' + assert buginfo['needinfo'] + assert buginfo['needinfo_requestee'] == 'John Doe' def test_multiple_needinfo(self): self.testbug.flags.append({'name': 'needinfo', 'status': '?', 'is_active': True, 'requestee': 'Jane Doe'}) buginfo = self.testsync.extract_information(self.testbug, 'Blocker') - assert buginfo['needinfo'] == 'John Doe, Jane Doe' + assert buginfo['needinfo'] + assert buginfo['needinfo_requestee'] == 'John Doe, Jane Doe' + + def test_needinfo_no_requestee(self): + self.testbug.flags[0].pop('requestee') + buginfo = self.testsync.extract_information(self.testbug, 'Blocker') + + assert buginfo['needinfo'] + assert buginfo['needinfo_requestee'] == '' + + def test_multiple_needinfo_no_requestee(self): + self.testbug.flags.append({'name': 'needinfo', 'status': '?', 'is_active': True}) + buginfo = self.testsync.extract_information(self.testbug, 'Blocker') + + assert buginfo['needinfo'] + assert buginfo['needinfo_requestee'] == 'John Doe' + + def test_needinfo_empty(self): + self.testbug.flags = [] + buginfo = self.testsync.extract_information(self.testbug, 'Blocker') + + assert buginfo['needinfo'] == False + assert buginfo['needinfo_requestee'] == '' diff --git a/testing/test_controllers.py b/testing/test_controllers.py --- a/testing/test_controllers.py +++ b/testing/test_controllers.py @@ -42,7 +42,7 @@ def add_bug(bugid, summary, milestone): test_bug = Bug(bugid, 'https://bugzilla.redhat.com/show_bug.cgi?id=%d' % bugid, - summary, 'NEW', 'testcomponent', milestone, True, 'John Doe') + summary, 'NEW', 'testcomponent', milestone, True, True, 'John Doe') test_bug.accepted_blocker = True db.session.add(test_bug) db.session.commit() diff --git a/testing/testfunc_bugmodel.py b/testing/testfunc_bugmodel.py --- a/testing/testfunc_bugmodel.py +++ b/testing/testfunc_bugmodel.py @@ -18,7 +18,7 @@ def generate_bug(bugid, summary, milestone): return Bug(bugid, 'https://bugzilla.redhat.com/show_bug.cgi?id=%d' % bugid, - summary, 'NEW', 'testcomponent', milestone, True, 'John Doe') + summary, 'NEW', 'testcomponent', milestone, True, True, 'John Doe') def generate_update(title, status, bugs, release, milestones, url='http://localhost/update'): return Update(title, url, 1, status, bugs, diff --git a/testing/testfunc_bugsync.py b/testing/testfunc_bugsync.py --- a/testing/testfunc_bugsync.py +++ b/testing/testfunc_bugsync.py @@ -32,7 +32,8 @@ 'proposed': False, 'last_change_time': datetime.datetime.utcnow(), 'active': True, - 'needinfo': 'John Doe' + 'needinfo': True, + 'needinfo_requestee': 'John Doe' }