diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index aecbee6..e4ff8cd 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -590,7 +590,11 @@ def update_tags(repo, username=None, namespace=None): flask.flash(error_message, 'error') if not error: + known_tags = [tag.tag for tag in repo.tags_colored] for idx, tag in enumerate(tags): + if tag in known_tags: + flask.flash('Duplicated tag: %s' % tag, 'error') + break try: pagure.lib.new_tag( flask.g.session, diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index 02018a8..658e689 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -3523,7 +3523,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Valid query data = { - 'tag': ['red', 'green'], + 'tag': ['red1', 'green'], 'tag_description': ['lorem ipsum', 'sample description'], 'tag_color': ['#ff0000', '#00ff00'], 'csrf_token': csrf_token, @@ -3544,7 +3544,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output_text) self.assertIn( 'red\n' + 'style="background-color:#ff0000">red1\n' ' ' 'lorem ipsum', output_text) self.assertIn( @@ -3581,11 +3581,44 @@ class PagureFlaskIssuestests(tests.Modeltests): '', output_text) + # Invalid query - Tag already known + data = { + 'tag': ['red2'], + 'tag_color': ['#000'], + 'tag_description': [''], + 'csrf_token': csrf_token, + } + output = self.app.post( + '/test/update/tags', data=data, follow_redirects=True) + self.assertEqual(output.status_code, 200) + output_text = output.get_data(as_text=True) + self.assertIn( + '