From abf0e9f79823dc3cd0dead787d1c6f755cf3bb01 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: May 20 2024 15:40:22 +0000 Subject: [PATCH 1/81] fix: wrong reply icon in issues and pull requests The reply comment button used the share instead the reply icon Fixes: https://pagure.io/pagure/issue/5262 --- diff --git a/pagure/static/issue_ev.js b/pagure/static/issue_ev.js index 83fcca6..09ae5f9 100644 --- a/pagure/static/issue_ev.js +++ b/pagure/static/issue_ev.js @@ -172,7 +172,7 @@ add_comment = function(data, username) { + ' {% endif %} {% if id != 0 and g.fas_user and (g.repo_committer or ( @@ -253,7 +253,7 @@ {% if g.fas_user %} - + {% endif %} {% if g.fas_user and (g.repo_committer or g.fas_user.username == pull_request.user.username) %} @@ -317,7 +317,7 @@ {% if g.fas_user %} - Reply + Reply {% endif %} From 40bb4f0b56761f93b2d6746513d4160ed8325f38 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: May 20 2024 15:40:59 +0000 Subject: [PATCH 2/81] fix: libravatar.org account login url missing 's' in libravatar url on pagure user settings page Fixes: https://pagure.io/pagure/issue/5366 --- diff --git a/pagure/templates/user_settings.html b/pagure/templates/user_settings.html index d68b541..7e90d21 100644 --- a/pagure/templates/user_settings.html +++ b/pagure/templates/user_settings.html @@ -84,7 +84,7 @@
{{ g.fas_user.username | avatar(80) | safe }}
- + Change Avatar
From afee922b3a709b46d079df0c80818f0510356d1e Mon Sep 17 00:00:00 2001 From: Ryan Lerch Date: May 20 2024 15:41:44 +0000 Subject: [PATCH 3/81] Add a new admin command to clean a spam user Adds a new command to the pagure-admin cli tool that: * blocks the given user * deletes all the repos of the given user * deleles all the issues a user has filed * lists all the comments a user has done In the future, will add deleting of comments as well, but there was no method for doing this in the models (it appears it is done manaully in the UI modules at the moment) -- I didnt want to dive too deep to get this done, so we manually delete comments for now. Signed-off-by: Ryan Lerch --- diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py index 258feb9..e433782 100644 --- a/pagure/cli/admin.py +++ b/pagure/cli/admin.py @@ -440,6 +440,30 @@ def _parser_delete_project(subparser): local_parser.set_defaults(func=do_delete_project) +def _parser_sanitize_spam_user(subparser): + """Set up the CLI argument parser for the delete-user-activity action. + + :arg subparser: an argparse subparser allowing to have action's specific + arguments + + """ + local_parser = subparser.add_parser( + "sanitize-spam-user", + help="Delete repos and tickets by the user specified", + ) + + local_parser.add_argument( + "user", + help="Username of the spam user to sanitize", + ) + local_parser.add_argument( + "action_user", + help="Username of the admin user doing the action (ie: deleting the " + "users activity)", + ) + local_parser.set_defaults(func=do_sanitize_spam_user) + + def _parser_create_branch(subparser): """Set up the CLI argument parser for the create-branch action. @@ -579,6 +603,9 @@ def parse_arguments(args=None): # delete-project _parser_delete_project(subparser) + # delete-all-user-acitvity + _parser_sanitize_spam_user(subparser) + # create-branch _parser_create_branch(subparser) @@ -925,6 +952,156 @@ def do_delete_project(args): print("Project deleted") +def do_sanitize_spam_user(args): + """Block and remove activity by a spam user + + :arg args: the argparse object returned by ``parse_arguments()``. + + """ + _log.debug("user: %s", args.user) + _log.debug("user deleting: %s", args.action_user) + + # Validate users + user = pagure.lib.query.get_user(session, args.user) + action_user = pagure.lib.query.get_user(session, args.action_user) + + projects = ( + session.query(pagure.lib.model.Project).filter( + pagure.lib.model.Project.user_id == user.id + ) + ).all() + + issues = ( + session.query(pagure.lib.model.Issue).filter( + pagure.lib.model.Issue.user_id == user.id + ) + ).all() + + comments = ( + session.query(pagure.lib.model.IssueComment).filter( + pagure.lib.model.IssueComment.user_id == user.id + ) + ).all() + + prs = ( + session.query(pagure.lib.model.PullRequest).filter( + pagure.lib.model.PullRequest.user_id == user.id + ) + ).all() + + prcomments = ( + session.query(pagure.lib.model.PullRequestComment).filter( + pagure.lib.model.PullRequestComment.user_id == user.id + ) + ).all() + + groups = ( + session.query(pagure.lib.model.PagureGroup).filter( + pagure.lib.model.PagureGroup.user_id == user.id + ) + ).all() + + blocked = bool( + pagure.lib.query.get_blocked_users( + session, username=user.user, date=None + ) + ) + + print("# Projects") + if projects: + for project in projects: + print(f"* {project.full_url}") + else: + print(" ***User has no Projects***") + + print("# Issues") + if issues: + for issue in issues: + print(f"* {issue.full_url}") + else: + print(" ***User has no Issues***") + + print("# Blocked Status") + if blocked: + print(" ***User is already blocked***") + else: + print(" User is NOT blocked on pagure") + + if issues or projects or not blocked: + print("\nAre you sure you want to:") + if projects: + print(f"* DELETE {len(projects)} projects") + if issues: + print(f"* DELETE {len(issues)} issues") + if not blocked: + print(f"* BLOCK {user.user} on pagure until 2099-01-01") + + if not _ask_confirmation(): + return + + if issues: + for issue in issues: + print(f"DELETING ISSUE: {issue.full_url}") + pagure.lib.query.drop_issue( + session, + issue=issue, + user=action_user.user, + ) + session.commit() + + if projects: + for project in projects: + print(f"DELETING PROJECT: {project.full_url}") + pagure.lib.tasks.delete_project( + namespace=project.namespace, + name=project.name, + user=project.user.user if project.is_fork else None, + action_user=action_user.user, + ) + session.commit() + + if not blocked: + # block the user + print(f"BLOCKING USER: {user.user} until 2099-01-01") + date = arrow.get("2099-01-01", "YYYY-MM-DD").replace(tzinfo="UTC") + user.refuse_sessions_before = date.datetime + session.add(user) + session.commit() + + print( + f"\n\n# Other Activity by {user.user} that needs to be removed manually:" + ) + + print("## Issue Comments") + if comments: + for comment in comments: + print(f"* {comment.issue.full_url}#comment-{comment.id}") + else: + print(" ***User has no Issue Comments***") + print("## Pull Requests") + if prs: + for pr in prs: + print(f"* {pr.full_url}") + else: + print(" ***User has no Pull Requests***") + + print("## Pull Request Comments") + if prcomments: + for prcomment in prcomments: + print( + f"* {prcomment.pull_request.full_url}#comment-{prcomment.id}" + ) + else: + print(" ***User has no Pull Request Comments***") + + print("## Groups Created by the User") + if groups: + for group in groups: + print(f"* {group.full_url}") + else: + print(" ***User has not created any Groups***") + + def do_update_acls(args): """Update the ACLs in the database from the list present in the configuration file. From 46fc87f337f4bab059ea77b9613c98563d3756f6 Mon Sep 17 00:00:00 2001 From: four_4 Date: May 20 2024 15:48:37 +0000 Subject: [PATCH 4/81] Added data-toggle attribute to missing tooltips (Issue #4965) --- diff --git a/pagure/templates/commits.html b/pagure/templates/commits.html index 807159b..8aee5c9 100644 --- a/pagure/templates/commits.html +++ b/pagure/templates/commits.html @@ -115,6 +115,7 @@ {{ diff_commit_full.author | author2avatar(20) | safe }} {{ diff_commit_full.author.name }} • {{ diff_commit_full.commit_time|humanize }}   @@ -172,6 +173,7 @@ author=commit.author.email), cssclass="notblue")|safe}} • {{ commit.commit_time|humanize }}   diff --git a/pagure/templates/file_history.html b/pagure/templates/file_history.html index d2503b0..95b7b61 100644 --- a/pagure/templates/file_history.html +++ b/pagure/templates/file_history.html @@ -128,6 +128,7 @@ author=commit.author.email), cssclass="notblue")|safe}} • {{ commit.commit_time|humanize }}   diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index ca8f20e..56ff93e 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -97,7 +97,7 @@ Opened {{ issue.date_created |humanize }} - by {{ issue.user.user }}. + by {{ issue.user.user }}. {% endif %} diff --git a/pagure/templates/repo_comparecommits.html b/pagure/templates/repo_comparecommits.html index 7826ea1..5c76efe 100644 --- a/pagure/templates/repo_comparecommits.html +++ b/pagure/templates/repo_comparecommits.html @@ -95,6 +95,7 @@ author=commit.author.email), cssclass="notblue")|safe}} • {{ commit.commit_time|humanize }}   diff --git a/pagure/templates/repo_new_pull_request.html b/pagure/templates/repo_new_pull_request.html index 17b09a2..7dc1d1d 100644 --- a/pagure/templates/repo_new_pull_request.html +++ b/pagure/templates/repo_new_pull_request.html @@ -290,6 +290,7 @@ author=commit.author.email), cssclass="notblue")|safe}} • {{ commit.commit_time|humanize }}   diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index 9fcd1e5..29a5066 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -68,7 +68,7 @@ Opened {{ pull_request.date_created |humanize }} - by {{ pull_request.user.user }}. + by {{ pull_request.user.user }}. {% elif pull_request.status == 'Closed' %} Closed {{ pull_request.closed_at |humanize }} @@ -78,7 +78,7 @@ Opened {{ pull_request.date_created |humanize }} - by {{ pull_request.user.user }}. + by {{ pull_request.user.user }}. {% endif %} @@ -342,6 +342,7 @@ author=commit.author.email), cssclass="notblue")|safe}} • {{ commit.commit_time|humanize }}   From 6d18e4eb679e9c4bc9cbf5b1094b32a5b2c1719d Mon Sep 17 00:00:00 2001 From: L. Guruprasad Date: May 20 2024 15:52:05 +0000 Subject: [PATCH 5/81] Fix the breadcrumb styles for the file history page --- diff --git a/pagure/templates/file_history.html b/pagure/templates/file_history.html index 95b7b61..f3836e1 100644 --- a/pagure/templates/file_history.html +++ b/pagure/templates/file_history.html @@ -63,7 +63,7 @@
From 8ac3244e1447dcd859fef71f94331df3faac9b36 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: May 20 2024 15:54:01 +0000 Subject: [PATCH 8/81] file.html: Add comment with template name, simplify markup --- diff --git a/pagure/templates/file.html b/pagure/templates/file.html index adcfc42..de7d46f 100644 --- a/pagure/templates/file.html +++ b/pagure/templates/file.html @@ -16,7 +16,9 @@ {% endblock %} + {% block repo %} +
{% block overviewtabs %}{{ super() }}{% endblock %} @@ -29,14 +31,13 @@
-
-
+
{% if branchname in g.branches %}
+ + {% endblock %} + {% block jscripts %} {{ super() }} {% endblock %} diff --git a/pagure/templates/group_info.html b/pagure/templates/group_info.html index 1e6088f..395a35b 100644 --- a/pagure/templates/group_info.html +++ b/pagure/templates/group_info.html @@ -128,7 +128,7 @@ return confirm('Are you sure you want to delete the group `{{ group.group_name }}`?'); }) $('.remove-user-btn').click(function() { - return confirm('Are you sure to remove user `' + $(this).attr('data-username') + '` from the group `{{ group.group_name }}`?'); + return confirm('Are you sure you want to remove user `' + $(this).attr('data-username') + '` from the group `{{ group.group_name }}`?'); }) $('#headerSearch').on('keypress keydown keyup', function(e) { if (e.which == 13) { diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 56ff93e..2c65695 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -845,7 +845,7 @@ $(document).ready(function() { 'value': '{{ form.csrf_token.current_token }}', 'type': 'hidden' })).appendTo('body'); - if (confirm('Are you sure to delete this ticket? \nThis is final and cannot be un-done.')){ + if (confirm('Are you sure you want to delete this ticket? \nThis is final and cannot be undone.')){ closeForm.submit(); } return false; @@ -1009,7 +1009,7 @@ function take_issue(){ setup_btn_take_drop(); } ).fail(function() { - alert( "An error occured, could not assign this ticket to you." ); + alert( "An error occurred, could not assign this ticket to you." ); }) return false; } @@ -1034,7 +1034,7 @@ function drop_issue(){ setup_btn_take_drop(); } ).fail(function() { - alert( "An error occured, could not drop the current assignee." ); + alert( "An error occurred, could not drop the current assignee." ); }) return false; } diff --git a/pagure/templates/repo_branches.html b/pagure/templates/repo_branches.html index d2f2afa..726b82c 100644 --- a/pagure/templates/repo_branches.html +++ b/pagure/templates/repo_branches.html @@ -120,7 +120,7 @@ $(function() { $(".delete-branch-form").submit(function() { console.log($(this)); - return confirm('Are you sure you want to remove the branch: ' + $(this).attr("data-branch-name") + '?\nThis cannot be un-done!'); + return confirm('Are you sure you want to remove the branch: ' + $(this).attr("data-branch-name") + '?\nThis cannot be undone!'); }); var _cnt = 0; diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index f235e0c..ed3c4ee 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -151,7 +151,7 @@ - Tags for project itself, as a comma-separated list. Tags + Tags for the project itself, as a comma-separated list. Tags for issues are managed further down on this page. @@ -192,11 +192,11 @@

- Each message sent to the web-hook are signed via hmac and SHA1 using + Each message sent to the web-hook is signed via hmac and SHA1 using this private key.

- This key is private to your project, make sure to store in a safe place + This key is private to your project. Be sure to store it in a safe place and do not share it.

@@ -213,7 +213,7 @@ method="post" class="icon"> {{ form.csrf_token }} @@ -239,7 +239,7 @@

The email addresses entered below will receive all the notifications related to {% if g.issues_enabled %} - (public) issues and {% endif %}pull-requests, this includes + (public) issues and {% endif %}pull-requests. This includes notifications about {% if g.issues_enabled %} new issue or {% endif %} new pull-request, new comment and status change. @@ -511,7 +511,7 @@

Below are the priorities you may assign to a ticket, allowing you to sort them with it. The Weight determines the ordering. Higher - priority should correspond to lower weight. + priority corresponds to lower weight. To remove an entry, simply clean the Weight and Title @@ -576,7 +576,7 @@

- The default priority will be set to all issues created after + The default priority will be set on all issues created after it has been set.

- Here is the list of all the status that can be used when closing + Here is the list of all statuses that can be used when closing an issue.

Set some custom fields for your issues. Field Values are currently - only used for Lists, and it accepts a comma separated list of items + only used for Lists, and consist of a comma separated list of items for the drop down list.

-

Quick replies will be offered in a new comment form on Issue or +

Quick replies will be offered in a new comment form on the Issue or Pull Request page. This allows you to reply to common problems with a click of a button.

The reply can use the same Markdown formatting as regular @@ -1138,21 +1138,21 @@ $(document).ready(function() { updateform(); $('#generate_new_hook_token').click(function() { - return confirm('Are you sure to generate a new token for ' - + 'this project/fork? \nThis will break all web hook in place and ' - + 'cannot be un-done.'); + return confirm('Are you sure you want to generate a new token for ' + + 'this project/fork? \nThis will break all web hooks in place and ' + + 'cannot be undone.'); }); $('.remove_user_btn').click(function(){ - return confirm('You sure you want to remove this user from this project?'); + return confirm('Are you sure you want to remove this user from this project?'); }); $('.remove_group_btn').click(function(){ - return confirm('You sure you want to remove this group from this project?'); + return confirm('Are you sure you want to remove this group from this project?'); }); $('.remove_deploy_key_btn').click(function(){ - return confirm('You sure you want to remove this deploy key from this project?'); + return confirm('Are you sure you want to remove this deploy key from this project?'); }); $('.delete_report_btn').click(function(){ @@ -1165,21 +1165,21 @@ $(document).ready(function() { }); $('.give_project_btn').click(function(){ - return confirm('Are you sure to give {{ repo.fullname }}? \nThis is final and cannot be un-done.'); + return confirm('Are you sure you want to give {{ repo.fullname }}? \nThis is final and cannot be undone.'); }); $('.delete_project_btn').click(function(){ - return confirm('Are you sure to delete {{ repo.fullname }}? \nThis is final and cannot be un-done.'); + return confirm('Are you sure you want to delete {{ repo.fullname }}? \nThis is final and cannot be undone.'); }); $('.revoke_token_btn').click(function(){ - return confirm('Are you sure to revoke this token ?' - + '\nThis will break all application using it and ' - + 'cannot be un-done.'); + return confirm('Are you sure you want to revoke this token ?' + + '\nThis will break all applications using it and ' + + 'cannot be undone.'); }); $('.renew_token_btn').click(function(){ - return confirm('Are you sure to renew this token ?' + return confirm('Are you sure you want to renew this token ?' + '\nIt will have the same ACL but will be a different key.'); }); diff --git a/pagure/templates/settings_api_keys.html b/pagure/templates/settings_api_keys.html index 4323f51..0422ac1 100644 --- a/pagure/templates/settings_api_keys.html +++ b/pagure/templates/settings_api_keys.html @@ -29,16 +29,16 @@

API keys are tokens used to authenticate you on pagure. They can also - be used to grant access to 3rd party application to behave on this - project on your name. + be used to grant access to 3rd party applications to act on this + project on your behalf.

These are your personal tokens; they are not visible to the other admins of this repository.

- These keys are private to your project, make sure to store in a safe - place and do not share it. + These keys are private to your project. Be sure to store them in a safe + place and do not share them.

{% if repo.tokens %} {% for token in repo.tokens %} diff --git a/pagure/templates/user_settings.html b/pagure/templates/user_settings.html index 7e90d21..4b70cf1 100644 --- a/pagure/templates/user_settings.html +++ b/pagure/templates/user_settings.html @@ -147,15 +147,15 @@

API keys are tokens used to authenticate you on pagure. They can also - be used to grant access to 3rd party application to behave on all + be used to grant access to 3rd party applications to act on all {{projectstring(plural=True)}} in your name.

These are your personal tokens; they are not visible to others.

- These keys are private, make sure to store in a safe place and - do not share it. + These keys are private. Be sure to store them in a safe place and + do not share them.

{% if user.tokens %} {% for token in user.tokens %} @@ -273,7 +273,7 @@

- Forcefully log out from every current open session. + Forcefully log out from every currently open session.

{{ form.csrf_token }}
diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index 1c0df62..c9caf14 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -1316,7 +1316,7 @@ class PagureFlaskIssuestests(tests.Modeltests): ) self.assertIn( '' - "Login\n to comment on this ticket.", + "Log in\n to comment on this ticket.", output_text, ) @@ -1359,7 +1359,7 @@ class PagureFlaskIssuestests(tests.Modeltests): ) self.assertIn( '' - "Login\n to comment on this ticket.", + "Log in\n to comment on this ticket.", output_text, ) @@ -1380,7 +1380,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output_text, ) self.assertFalse( - 'Login to comment on this ticket.' + 'Log in to comment on this ticket.' in output_text ) # Not author nor admin = No take @@ -1503,7 +1503,7 @@ class PagureFlaskIssuestests(tests.Modeltests): ) self.assertIn( '' - "Login\n to comment on this ticket.", + "Log in\n to comment on this ticket.", output_text, ) @@ -1530,7 +1530,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output_text, ) self.assertFalse( - 'Login to comment on this ticket.' + 'Log in to comment on this ticket.' in output_text ) # author admin = take @@ -1577,7 +1577,7 @@ class PagureFlaskIssuestests(tests.Modeltests): ) self.assertTrue( '' - "Login\n to comment on this ticket." in output_text + "Log in\n to comment on this ticket." in output_text ) # Create issues to play with @@ -1607,7 +1607,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output_text, ) self.assertFalse( - 'Login to comment on this ticket.' + 'Log in to comment on this ticket.' in output_text ) # user has ticket = take ok @@ -1718,7 +1718,7 @@ class PagureFlaskIssuestests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) # user has ticket = take ok diff --git a/tests/test_pagure_flask_ui_issues_acl_checks.py b/tests/test_pagure_flask_ui_issues_acl_checks.py index f8bc550..4d991a0 100644 --- a/tests/test_pagure_flask_ui_issues_acl_checks.py +++ b/tests/test_pagure_flask_ui_issues_acl_checks.py @@ -110,7 +110,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): ) self.assertTrue( '' - "Login\n to comment on this ticket." + "Log in\n to comment on this ticket." in output.get_data(as_text=True) ) @@ -139,7 +139,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) @@ -203,7 +203,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) @@ -373,7 +373,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): ) self.assertIn( '' - "Login\n to comment on this ticket.", + "Log in\n to comment on this ticket.", output_text, ) @@ -402,7 +402,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) @@ -628,7 +628,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): ) self.assertTrue( '' - "Login\n to comment on this ticket.", + "Log in\n to comment on this ticket.", output_text, ) @@ -657,7 +657,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) @@ -881,7 +881,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): ) self.assertTrue( '' - "Login\n to comment on this ticket." + "Log in\n to comment on this ticket." in output.get_data(as_text=True) ) @@ -910,7 +910,7 @@ class PagureFlaskIssuesACLtests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) diff --git a/tests/test_pagure_flask_ui_issues_open_access.py b/tests/test_pagure_flask_ui_issues_open_access.py index 901b621..212ba82 100644 --- a/tests/test_pagure_flask_ui_issues_open_access.py +++ b/tests/test_pagure_flask_ui_issues_open_access.py @@ -214,7 +214,7 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): ) self.assertIn( '' - "Login\n to comment on this ticket.", + "Log in\n to comment on this ticket.", output_text, ) @@ -235,7 +235,7 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): output_text, ) self.assertFalse( - 'Login to comment on this ticket.' + 'Log in to comment on this ticket.' in output_text ) # Not author nor admin but open_access = take @@ -314,7 +314,7 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): ) self.assertTrue( '' - "Login\n to comment on this ticket." in output_text + "Log in\n to comment on this ticket." in output_text ) # Create issues to play with @@ -344,7 +344,7 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): output_text, ) self.assertFalse( - 'Login to comment on this ticket.' + 'Log in to comment on this ticket.' in output_text ) # user has ticket = take ok @@ -446,7 +446,7 @@ class PagureFlaskIssuesOpenAccesstests(tests.Modeltests): output_text, ) self.assertNotIn( - 'Login to comment on this ticket.', + 'Log in to comment on this ticket.', output_text, ) # user has ticket = take ok diff --git a/tests/test_pagure_flask_ui_login.py b/tests/test_pagure_flask_ui_login.py index be319c8..e0b2891 100644 --- a/tests/test_pagure_flask_ui_login.py +++ b/tests/test_pagure_flask_ui_login.py @@ -297,8 +297,8 @@ class PagureFlaskLogintests(tests.SimplePagureTest): self.assertEqual(item.user, "foouser") self.assertEqual(item.token, None) - # Login but cannot save the session to the DB due to the missing IP - # address in the flask request + # Login works but cannot save the session to the DB due to the missing + # IP address in the flask request data["password"] = "barpass" output = self.app.post("/dologin", data=data, follow_redirects=True) self.assertEqual(output.status_code, 200) @@ -518,7 +518,7 @@ class PagureFlaskLogintests(tests.SimplePagureTest): @patch.dict("pagure.config.config", {"PAGURE_AUTH": "local"}) @patch("pagure.lib.notify.send_email", MagicMock(return_value=True)) def test_non_ascii_password(self): - """Test login and create user functionality when the password is + """Test login and user creation functionality when the password is non-ascii. """ From 9ff9b34df3c02384d04f7e1d454fbdc143744b91 Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: May 20 2024 16:13:07 +0000 Subject: [PATCH 18/81] cli/admin: Shorten message to fit length rule for the style check --- diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py index e433782..e1db630 100644 --- a/pagure/cli/admin.py +++ b/pagure/cli/admin.py @@ -1068,9 +1068,7 @@ def do_sanitize_spam_user(args): session.add(user) session.commit() - print( - f"\n\n# Other Activity by {user.user} that needs to be removed manually:" - ) + print(f"\n\n# Activity by {user.user} that needs to be removed manually:") print("## Issue Comments") if comments: From 0e256092d73ddb3aea7a7a6f133b69a577f2b7aa Mon Sep 17 00:00:00 2001 From: Michal Konečný Date: May 20 2024 16:13:30 +0000 Subject: [PATCH 19/81] Fix query filter for date ranges The query for pull request of user incorrectly worked with date ranges and instead it assumed that since is lesser or equal than the date we are comparing to. This commit is fixing that behavior. Signed-off-by: Michal Konečný --- diff --git a/pagure/lib/query.py b/pagure/lib/query.py index 6047b78..46c03e9 100644 --- a/pagure/lib/query.py +++ b/pagure/lib/query.py @@ -4659,12 +4659,12 @@ def get_pull_request_of_user( query = query.filter(model.PullRequest.date_created <= created_until) if updated_since: - query = query.filter(model.PullRequest.updated_on <= updated_since) + query = query.filter(model.PullRequest.updated_on >= updated_since) if updated_until: query = query.filter(model.PullRequest.updated_on <= updated_until) if closed_since: - query = query.filter(model.PullRequest.closed_at <= closed_since) + query = query.filter(model.PullRequest.closed_at >= closed_since) if closed_until: query = query.filter(model.PullRequest.closed_at <= closed_until) diff --git a/tests/test_pagure_flask_api_user.py b/tests/test_pagure_flask_api_user.py index 27bd122..8840842 100644 --- a/tests/test_pagure_flask_api_user.py +++ b/tests/test_pagure_flask_api_user.py @@ -1214,7 +1214,7 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertEqual(len(data["requests"]), 0) + self.assertEqual(len(data["requests"]), 6) yesterday = today - datetime.timedelta(days=1) output = self.app.get( @@ -1223,7 +1223,7 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertEqual(len(data["requests"]), 0) + self.assertEqual(len(data["requests"]), 6) tomorrow = today + datetime.timedelta(days=1) output = self.app.get( @@ -1232,7 +1232,7 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertEqual(len(data["requests"]), 6) + self.assertEqual(len(data["requests"]), 0) @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_filed_closed(self, mockemail): @@ -1598,7 +1598,7 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertEqual(len(data["requests"]), 0) + self.assertEqual(len(data["requests"]), 6) yesterday = today - datetime.timedelta(days=1) output = self.app.get( @@ -1607,7 +1607,7 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertEqual(len(data["requests"]), 0) + self.assertEqual(len(data["requests"]), 6) tomorrow = today + datetime.timedelta(days=1) output = self.app.get( @@ -1616,7 +1616,7 @@ class PagureFlaskApiUsertestrequests(tests.Modeltests): ) self.assertEqual(output.status_code, 200) data = json.loads(output.get_data(as_text=True)) - self.assertEqual(len(data["requests"]), 6) + self.assertEqual(len(data["requests"]), 0) @patch("pagure.lib.notify.send_email") def test_api_view_user_requests_actionable_closed(self, mockemail): From 2668f90f1fe133874e3b6b137a9a07deffa5584d Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: May 20 2024 16:14:10 +0000 Subject: [PATCH 20/81] fix(user_settings): unable to change default email If more then two email addresses are defined in the user settings, it was not possible to change the default address to one of those additional addresses. This was caused by the frontend, all addresses got the same html 'form-id', that way always the first one was submitted when clicking the submit button, independent of the actual selected email address. Resolved by adding a random number as suffix to the 'form-id' of each email address, that way there are unique and the default mail address can be changed even with more then two assigned addresses. Fixes: https://pagure.io/pagure/issue/5327 Fixes: https://pagure.io/pagure/issue/5338 --- diff --git a/pagure/templates/user_settings.html b/pagure/templates/user_settings.html index 4b70cf1..9302587 100644 --- a/pagure/templates/user_settings.html +++ b/pagure/templates/user_settings.html @@ -7,6 +7,7 @@ {% set tag = "users"%} {% macro render_email(email, form, validated=True) %} +{% set random_number = range(0, 256) | random() %}
 {{ email.email }} {% if validated %} @@ -25,11 +26,11 @@
{% else %} + action="{{ url_for('ui_ns.set_default_email') }}" id="default_mail_{{ random_number }}"> {{ form.csrf_token }} + data-form-id="default_mail_{{ random_number }}" title="Set as default email address"> From c8a1b988d5e9a869aecdd2cf5a8763e3ce6d7291 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: May 20 2024 16:14:37 +0000 Subject: [PATCH 21/81] fix(theme): long words in source nav break layout The 'srcfpo' theme adds additional information to the commits side navigation, which might contain long words and then break the layout. In that case the content appeared below the navigation and not side-by-side with the commits overview or commit details. To fix this, a text break will be enforced in the relevant div of the 'srcfpo' theme. Also the column width in global 'commit.html' aligned with other template files by setting to 'col-2'. Fixes: https://pagure.io/pagure/issue/5353 --- diff --git a/pagure/templates/commit.html b/pagure/templates/commit.html index 73408ec..4238e0d 100644 --- a/pagure/templates/commit.html +++ b/pagure/templates/commit.html @@ -20,7 +20,7 @@ {# we recognize non-executable file, executable file and symlink #} {% set expected_modes = [33188, 33261, 40960] %}
-
+
{% block overviewtabs %}{{ super() }}{% endblock %}
diff --git a/pagure/themes/srcfpo/static/theme.css b/pagure/themes/srcfpo/static/theme.css index 1831daf..45a5600 100644 --- a/pagure/themes/srcfpo/static/theme.css +++ b/pagure/themes/srcfpo/static/theme.css @@ -13,4 +13,9 @@ .footer a.notblue{ opacity:0.7; -} \ No newline at end of file +} + +.enforce-text-break { + word-wrap: break-word !important; + word-break: break-all !important; +} diff --git a/pagure/themes/srcfpo/templates/repo_master_sidebar.html b/pagure/themes/srcfpo/templates/repo_master_sidebar.html index e579d40..306032c 100644 --- a/pagure/themes/srcfpo/templates/repo_master_sidebar.html +++ b/pagure/themes/srcfpo/templates/repo_master_sidebar.html @@ -1,4 +1,4 @@ -