diff --git a/alembic/versions/38581a8fbae2_add_custom_field_data.py b/alembic/versions/38581a8fbae2_add_custom_field_data.py new file mode 100644 index 0000000..238b487 --- /dev/null +++ b/alembic/versions/38581a8fbae2_add_custom_field_data.py @@ -0,0 +1,22 @@ +"""Add custom field data + +Revision ID: 38581a8fbae2 +Revises: 208b0cd232ab +Create Date: 2017-01-16 13:03:36.683188 + +""" + +# revision identifiers, used by Alembic. +revision = '38581a8fbae2' +down_revision = '208b0cd232ab' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('issue_keys', sa.Column('key_data', sa.Text())) + + +def downgrade(): + op.drop_column('issue_keys', 'key_data') diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index d28b2af..358142d 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -3460,9 +3460,9 @@ def save_report(session, repo, name, url, username): session.add(repo) -def set_custom_key_fields(session, project, fields, types): +def set_custom_key_fields(session, project, fields, types, data): """ Set or update the custom key fields of a project with the values - provided. + provided. "data" is currently only used for lists """ current_keys = {} @@ -3470,14 +3470,19 @@ def set_custom_key_fields(session, project, fields, types): current_keys[key.name] = key for idx, key in enumerate(fields): + if types[idx] != "list": + # Only Lists use data, strip it otherwise + data[idx] = "" if key in current_keys: issuekey = current_keys[key] issuekey.key_type = types[idx] + issuekey.key_data = data[idx] else: issuekey = model.IssueKeys( project_id=project.id, name=key, key_type=types[idx], + key_data=data[idx] ) session.add(issuekey) diff --git a/pagure/lib/model.py b/pagure/lib/model.py index f982f9e..79516d7 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -820,6 +820,7 @@ class Issue(BASE): name=field.key.name, key_type=field.key.key_type, value=field.value, + key_data=field.key.key_data ) for field in self.other_fields ] @@ -988,6 +989,7 @@ class IssueKeys(BASE): nullable=False) name = sa.Column(sa.Text(), nullable=False) key_type = sa.Column(sa.String(255), nullable=False) + key_data = sa.Column(sa.Text()) __table_args__ = (sa.UniqueConstraint('project_id', 'name'),) diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index a2ba336..7864e24 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -367,7 +367,7 @@
- {% if field.name in knowns_keys %} + {% if field.name in knowns_keys %} {% if field.key_type == 'link' %} {% for link in knowns_keys[field.name].value.split(',') %} {{ link }} @@ -383,15 +383,25 @@ {% if authenticated and g.repo_admin %}
{% endif %} {% endfor %} diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 5955328..90933c2 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -684,7 +684,9 @@- Set some custom fields for your issues. + Set some custom fields for your issues. Field Values are currently + only used for Lists, and it accepts a comma separated list of items + for the drop down list.