diff --git a/alembic/versions/349a3890596_increase_length_group_name.py b/alembic/versions/349a3890596_increase_length_group_name.py index 4e84bd5..7ec1154 100644 --- a/alembic/versions/349a3890596_increase_length_group_name.py +++ b/alembic/versions/349a3890596_increase_length_group_name.py @@ -8,7 +8,7 @@ Create Date: 2016-11-30 14:30:15.681269 # revision identifiers, used by Alembic. revision = '349a3890596' -down_revision = '5083efccac7' +down_revision = '114d3a68c1fd' from alembic import op import sqlalchemy as sa diff --git a/alembic/versions/588eabcd394c_add_quick_replies_field_to_project.py b/alembic/versions/588eabcd394c_add_quick_replies_field_to_project.py new file mode 100644 index 0000000..215b328 --- /dev/null +++ b/alembic/versions/588eabcd394c_add_quick_replies_field_to_project.py @@ -0,0 +1,29 @@ +"""add quick_replies field to project + +Revision ID: 588eabcd394c +Revises: 5083efccac7 +Create Date: 2016-11-17 16:12:36.624079 + +""" + +# revision identifiers, used by Alembic. +revision = '588eabcd394c' +down_revision = '349a3890596' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + ''' Add the column _quick_replies to the table projects + ''' + op.add_column( + 'projects', + sa.Column('_quick_replies', sa.Text, nullable=True) + ) + + +def downgrade(): + ''' Drop the column _quick_replies from the table projects. + ''' + op.drop_column('projects', '_quick_replies') diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 95a2843..3c79a56 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -344,6 +344,7 @@ class Project(BASE): nullable=True) _priorities = sa.Column(sa.Text, nullable=True) _milestones = sa.Column(sa.Text, nullable=True) + _quick_replies = sa.Column(sa.Text, nullable=True) _reports = sa.Column(sa.Text, nullable=True) _notifications = sa.Column(sa.Text, nullable=True) _close_status = sa.Column(sa.Text, nullable=True) @@ -476,6 +477,23 @@ class Project(BASE): self._priorities = json.dumps(priorities) @property + def quick_replies(self): + """ Return a list of quick replies available for pull requests and + issues. + """ + quick_replies = [] + + if self._quick_replies: + quick_replies = json.loads(self._quick_replies) + + return quick_replies + + @quick_replies.setter + def quick_replies(self, quick_replies): + """ Ensures the quick replies are properly saved. """ + self._quick_replies = json.dumps(quick_replies) + + @property def notifications(self): """ Return the dict stored as string in the database as an actual dict object.