diff --git a/pagure/forms.py b/pagure/forms.py index 576896f..bb57357 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -239,6 +239,10 @@ class DeleteIssueTagForm(PagureForm): class AddIssueTagForm(DeleteIssueTagForm): ''' Form to add a tag to a project. ''' + tag_description = wtforms.TextField( + 'tag_description', + [wtforms.validators.Optional()], + ) tag_color = wtforms.TextField( 'tag_color', [wtforms.validators.Required()], @@ -634,4 +638,3 @@ class SubscribtionForm(PagureForm): [wtforms.validators.optional()], false_values=('false', '', False, 'False', 0, '0'), ) - diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py index 65c61bf..09b95f9 100644 --- a/pagure/lib/__init__.py +++ b/pagure/lib/__init__.py @@ -736,7 +736,7 @@ def remove_tags_obj(session, obj, tags, ticketfolder, user): def edit_issue_tags( - session, project, old_tag, new_tag, + session, project, old_tag, new_tag, new_tag_description, new_tag_color, ticketfolder, user): ''' Removes the specified tag of a project. ''' user_obj = get_user(session, user) @@ -750,12 +750,18 @@ def edit_issue_tags( 'No tag "%s" found related to this project' % (old_tag_name)) old_tag_name = old_tag.tag + old_tag_description = old_tag.tag_description old_tag_color = old_tag.tag_color - if old_tag.tag == new_tag and old_tag_color == new_tag_color: - # check for change + + # check for change + no_change_in_tag = old_tag.tag == new_tag and \ + old_tag_description == new_tag_description and \ + old_tag_color == new_tag_color + if no_change_in_tag: raise pagure.exceptions.PagureException( - 'No change. Old tag "%s(%s)" is the same as new tag "%s(%s)"' - % (old_tag, old_tag_color, new_tag, new_tag_color)) + 'No change. Old tag "%s(%s)[%s]" is the same as new tag "%s(%s)[%s]"' + % (old_tag, old_tag_description, old_tag_color, new_tag, + new_tag_description, new_tag_color)) elif old_tag.tag != new_tag: # Check if new tag already exists existing_tag = get_tag(session, new_tag, project.id) @@ -772,6 +778,7 @@ def edit_issue_tags( ).update( { model.TagColored.tag: new_tag, + model.TagColored.tag_description: new_tag_description, model.TagColored.tag_color: new_tag_color } ) @@ -789,16 +796,19 @@ def edit_issue_tags( issue, repo=issue.project, repofolder=ticketfolder) msgs = [] - msgs.append('Edited tag: %s(%s) to %s(%s)' % - (old_tag_name, old_tag_color, new_tag, new_tag_color)) + msgs.append('Edited tag: %s(%s)[%s] to %s(%s)[%s]' % + (old_tag_name, old_tag_description, old_tag_color, + new_tag, new_tag_description, new_tag_color)) pagure.lib.notify.log( project, topic='project.tag.edited', msg=dict( project=project.to_json(public=True), old_tag=old_tag.tag, + old_tag_description=old_tag_description, old_tag_color=old_tag_color, new_tag=new_tag, + new_tag_description=new_tag_description, new_tag_color=new_tag_color, agent=user_obj.username, ), @@ -1372,10 +1382,11 @@ def new_pull_request(session, branch_from, return request -def new_tag(session, tag_name, tag_color, project_id): +def new_tag(session, tag_name, tag_description, tag_color, project_id): ''' Return a new tag object ''' tagobj = model.TagColored( tag=tag_name, + tag_description=tag_description, tag_color=tag_color, project_id=project_id ) diff --git a/pagure/lib/model.py b/pagure/lib/model.py index 34d4aff..e532d6d 100644 --- a/pagure/lib/model.py +++ b/pagure/lib/model.py @@ -1089,6 +1089,7 @@ class TagColored(BASE): id = sa.Column(sa.Integer, primary_key=True) tag = sa.Column(sa.String(255), nullable=False) + tag_description = sa.Column(sa.String(255)) project_id = sa.Column( sa.Integer, sa.ForeignKey( diff --git a/pagure/templates/edit_tag.html b/pagure/templates/edit_tag.html index 6775017..5789cfa 100644 --- a/pagure/templates/edit_tag.html +++ b/pagure/templates/edit_tag.html @@ -23,6 +23,7 @@ namespace=repo.namespace) }}" > {{ form.csrf_token }} {{ render_bootstrap_field(form.tag) }} + {{ render_bootstrap_field(form.tag_description) }}