From cd1ee973de2b47cc46b0a3fccd0e182b34a346bd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 1/13] Add an option to allow/disable tickets on project in this pagure instance --- diff --git a/pagure/default_config.py b/pagure/default_config.py index ad3d1e5..c9d1873 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -33,6 +33,10 @@ EMAIL_ERROR = 'pingou@pingoured.fr' # The URL at which the project is available. APP_URL = 'https://pagure.org/' + +# Enables / Disables tickets for project for the entire pagure instance +PROJECT_TICKETS = True + # The URL to use to clone the git repositories. GIT_URL_SSH = 'ssh://git@pagure.org/' GIT_URL_GIT = 'git://pagure.org/' From 5e52ba207df2d46480d125061481d13d00d309d1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 2/13] Turn of the issue link in the project master template if it's off in the instance --- diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html index c0c5e58..1bf70a3 100644 --- a/pagure/templates/repo_master.html +++ b/pagure/templates/repo_master.html @@ -60,7 +60,8 @@ repo=repo.name) }}">Tags - {% if repo and repo.settings.get('issue_tracker', True) %} + {% if config.get('PROJECT_TICKETS', True) and repo + and repo.settings.get('issue_tracker', True) %}
  • Issues From 32b7b4deca561154d15c6855a9a6cd221dc34731 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 3/13] Do not include the issue controller if issues have been turned off globally --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 1c1f359..556ad13 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -435,7 +435,8 @@ import pagure.ui.app import pagure.ui.admin import pagure.ui.fork import pagure.ui.groups -import pagure.ui.issues +if APP.config.get('PROJECT_TICKETS', True): + import pagure.ui.issues import pagure.ui.plugins import pagure.ui.repo From dbf3199980616c005432b7c5ee9dd558155ecc57 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 4/13] Disable the markdown filters for # if issues are globally disabled --- diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index eaaca3d..b7cc09b 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -119,12 +119,13 @@ class PagureExtension(markdown.extensions.Extension): ]) md.inlinePatterns['mention'] = MentionPattern(MENTION_RE) - md.inlinePatterns['explicit_fork_issue'] = \ - ExplicitForkIssuePattern(EXPLICIT_FORK_ISSUE_RE) - md.inlinePatterns['explicit_main_issue'] = \ - ExplicitMainIssuePattern(EXPLICIT_MAIN_ISSUE_RE) - md.inlinePatterns['implicit_issue'] = \ - ImplicitIssuePattern(IMPLICIT_ISSUE_RE) + if pagure.APP.config.get('PROJECT_TICKETS', True): + md.inlinePatterns['explicit_fork_issue'] = \ + ExplicitForkIssuePattern(EXPLICIT_FORK_ISSUE_RE) + md.inlinePatterns['explicit_main_issue'] = \ + ExplicitMainIssuePattern(EXPLICIT_MAIN_ISSUE_RE) + md.inlinePatterns['implicit_issue'] = \ + ImplicitIssuePattern(IMPLICIT_ISSUE_RE) md.registerExtension(self) From 559b8928060646277aca6968d7e5a04104f4fcc4 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 5/13] Adjust the API to not include the issues if they are globally disabled --- diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 1cdffa9..665d9a6 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -191,7 +191,8 @@ def api_method(function): return wrapper -from pagure.api import issue +if pagure.APP.config.get('PROJECT_TICKETS', True): + from pagure.api import issue from pagure.api import fork from pagure.api import project from pagure.api import user @@ -414,11 +415,13 @@ def api(): api_git_tags_doc = load_doc(project.api_git_tags) api_projects_doc = load_doc(project.api_projects) - api_new_issue_doc = load_doc(issue.api_new_issue) - api_view_issue_doc = load_doc(issue.api_view_issue) - api_view_issue_comment_doc = load_doc(issue.api_view_issue_comment) - api_view_issues_doc = load_doc(issue.api_view_issues) - api_issue_add_comment_doc = load_doc(issue.api_comment_issue) + issues = [] + if pagure.APP.config.get('PROJECT_TICKETS', True): + issues.append(load_doc(issue.api_new_issue)) + issues.append(load_doc(issue.api_view_issues)) + issues.append(load_doc(issue.api_view_issue)) + issues.append(load_doc(issue.api_view_issue_comment)) + issues.append(load_doc(issue.api_comment_issue)) api_pull_request_views_doc = load_doc(fork.api_pull_request_views) api_pull_request_view_doc = load_doc(fork.api_pull_request_view) @@ -442,13 +445,7 @@ def api(): api_git_tags_doc, api_projects_doc, ], - issues=[ - api_new_issue_doc, - api_view_issues_doc, - api_view_issue_doc, - api_view_issue_comment_doc, - api_issue_add_comment_doc, - ], + issues=issues, requests=[ api_pull_request_views_doc, api_pull_request_view_doc, From fedbe55e2e8502a8758af3edd29efc182965e897 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 6/13] Hide the API doc section about issues if there are no issues doc --- diff --git a/pagure/templates/api.html b/pagure/templates/api.html index b6ee060..e831913 100644 --- a/pagure/templates/api.html +++ b/pagure/templates/api.html @@ -25,6 +25,7 @@ {% endfor %} +{% if issues %}

    Issues @@ -36,6 +37,7 @@ {{ html | InsertDiv | safe }} {% endfor %} +{% endif %}

    Pull-requests From 1de9c5d86c00b74136acacc9c79fe9e00a1748a3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 7/13] One more API endpoint to not show if issues are disabled project-wide --- diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 665d9a6..425d52e 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -434,10 +434,19 @@ def api(): api_version_doc = load_doc(api_version) api_users_doc = load_doc(api_users) api_view_user_doc = load_doc(user.api_view_user) - api_project_tags_doc = load_doc(api_project_tags) + if pagure.APP.config.get('PROJECT_TICKETS', True): + api_project_tags_doc = load_doc(api_project_tags) api_groups_doc = load_doc(api_groups) api_error_codes_doc = load_doc(api_error_codes) + extras = [ + api_version_doc, + api_error_codes_doc, + ] + + if pagure.APP.config.get('PROJECT_TICKETS', True): + extras.append(api_project_tags_doc) + return flask.render_template( 'api.html', api_doc=APIDOC, @@ -459,11 +468,7 @@ def api(): api_view_user_doc, api_groups_doc, ], - extras=[ - api_version_doc, - api_project_tags_doc, - api_error_codes_doc, - ], + extras=extras, ) From b456047d9707e262ba9f3c8c57ec606b0780f426 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 8/13] Hide the issues link if the project has no issues --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index 9859d29..f29b4e1 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -221,6 +221,7 @@ {{ config.get('GIT_URL_GIT') }}docs/{{ repo.fullname }}.git + {% if config.get('PROJECT_TICKETS', True) %} Tickets : @@ -231,6 +232,7 @@ {{ config.get('GIT_URL_GIT') }}tickets/{{ repo.fullname }}.git + {% endif %} Requests : From e0fe3f51abd50f48e6f245aef26f06071737aed1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 14 2015 21:21:29 +0000 Subject: [PATCH 9/13] Hide the docs links if the project has no docs --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index f29b4e1..20d1793 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -211,6 +211,7 @@ {{ config.get('GIT_URL_GIT') }}{% if repo.parent %}forks/{% endif %}{{ repo.fullname }}.git + {% if config['DOC_APP_URL'] and repo and repo.settings.get('project_documentation', True) %} Docs : @@ -221,6 +222,7 @@ {{ config.get('GIT_URL_GIT') }}docs/{{ repo.fullname }}.git + {% endif %} {% if config.get('PROJECT_TICKETS', True) %} Tickets From c11edb7e6d26fab59b7d42b7b36e2e7d05354c26 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 15 2015 15:42:38 +0000 Subject: [PATCH 10/13] Fix the Settings page for when issues are globally disabled --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 64c5339..114c52b 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -167,6 +167,8 @@ username=username, repo=repo.name) }}" method="post"> {% for key in repo.settings | sort %} + {% if not config.get('PROJECT_TICKETS', True) and key in ['issue_tracker'] %} + {% else %} + {% endif %} {% endfor %}
    @@ -179,6 +181,7 @@ {% endif %}

    @@ -279,6 +282,8 @@ {% endif %} + +{% if config.get('PROJECT_TICKETS', True) %}

    Tags

    @@ -314,7 +319,7 @@ {% endfor %}
    - +{% endif %}
    Activate {{ key | replace('_', ' ') }} From 540c4b0e11eb2e6ce7a1e35d74fd9b586d42c654 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 15 2015 15:52:08 +0000 Subject: [PATCH 12/13] Replace checking for project_documentation by checking for pull_requests Since by default the doc server isn't configured which means its setting isn't shown on the settings page --- diff --git a/tests/test_progit_flask_ui_repo.py b/tests/test_progit_flask_ui_repo.py index 7821659..52e1694 100644 --- a/tests/test_progit_flask_ui_repo.py +++ b/tests/test_progit_flask_ui_repo.py @@ -404,8 +404,8 @@ class PagureFlaskRepotests(tests.Modeltests): '
      \n
    ' in output.data) # Both checkbox checked before self.assertTrue( - '' in output.data) + '' in output.data) self.assertTrue( '' in output.data) @@ -430,8 +430,8 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertTrue( '
      \n
    ' in output.data) self.assertTrue( - '' in output.data) + '' in output.data) self.assertTrue( '' in output.data) @@ -456,15 +456,15 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertTrue( '
      \n
    ' in output.data) self.assertTrue( - '' in output.data) + '' in output.data) self.assertTrue( '' in output.data) data = { 'csrf_token': csrf_token, - 'project_documentation': 'y', + 'pull_requests': 'y', 'issue_tracker': 'y', } output = self.app.post( @@ -486,8 +486,8 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertTrue( '
      \n
    ' in output.data) self.assertTrue( - '' in output.data) + '' in output.data) self.assertTrue( '' in output.data) From a4bd4dcaa8d3e8a90af80eee40dc2a55231a45a9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 16 2015 16:13:08 +0000 Subject: [PATCH 13/13] Rename the PROJECT_TICKETS variable to ENABLE_TICKETS This makes it clearer what it does as per @puiterwijk's suggestion --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 556ad13..2e91631 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -435,7 +435,7 @@ import pagure.ui.app import pagure.ui.admin import pagure.ui.fork import pagure.ui.groups -if APP.config.get('PROJECT_TICKETS', True): +if APP.config.get('ENABLE_TICKETS', True): import pagure.ui.issues import pagure.ui.plugins import pagure.ui.repo diff --git a/pagure/api/__init__.py b/pagure/api/__init__.py index 425d52e..01fd81b 100644 --- a/pagure/api/__init__.py +++ b/pagure/api/__init__.py @@ -191,7 +191,7 @@ def api_method(function): return wrapper -if pagure.APP.config.get('PROJECT_TICKETS', True): +if pagure.APP.config.get('ENABLE_TICKETS', True): from pagure.api import issue from pagure.api import fork from pagure.api import project @@ -416,7 +416,7 @@ def api(): api_projects_doc = load_doc(project.api_projects) issues = [] - if pagure.APP.config.get('PROJECT_TICKETS', True): + if pagure.APP.config.get('ENABLE_TICKETS', True): issues.append(load_doc(issue.api_new_issue)) issues.append(load_doc(issue.api_view_issues)) issues.append(load_doc(issue.api_view_issue)) @@ -434,7 +434,7 @@ def api(): api_version_doc = load_doc(api_version) api_users_doc = load_doc(api_users) api_view_user_doc = load_doc(user.api_view_user) - if pagure.APP.config.get('PROJECT_TICKETS', True): + if pagure.APP.config.get('ENABLE_TICKETS', True): api_project_tags_doc = load_doc(api_project_tags) api_groups_doc = load_doc(api_groups) api_error_codes_doc = load_doc(api_error_codes) @@ -444,7 +444,7 @@ def api(): api_error_codes_doc, ] - if pagure.APP.config.get('PROJECT_TICKETS', True): + if pagure.APP.config.get('ENABLE_TICKETS', True): extras.append(api_project_tags_doc) return flask.render_template( diff --git a/pagure/default_config.py b/pagure/default_config.py index c9d1873..38ad853 100644 --- a/pagure/default_config.py +++ b/pagure/default_config.py @@ -35,7 +35,7 @@ APP_URL = 'https://pagure.org/' # Enables / Disables tickets for project for the entire pagure instance -PROJECT_TICKETS = True +ENABLE_TICKETS = True # The URL to use to clone the git repositories. GIT_URL_SSH = 'ssh://git@pagure.org/' diff --git a/pagure/pfmarkdown.py b/pagure/pfmarkdown.py index b7cc09b..f16ee46 100644 --- a/pagure/pfmarkdown.py +++ b/pagure/pfmarkdown.py @@ -119,7 +119,7 @@ class PagureExtension(markdown.extensions.Extension): ]) md.inlinePatterns['mention'] = MentionPattern(MENTION_RE) - if pagure.APP.config.get('PROJECT_TICKETS', True): + if pagure.APP.config.get('ENABLE_TICKETS', True): md.inlinePatterns['explicit_fork_issue'] = \ ExplicitForkIssuePattern(EXPLICIT_FORK_ISSUE_RE) md.inlinePatterns['explicit_main_issue'] = \ diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index 20d1793..a01cf00 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -223,7 +223,7 @@ {% endif %} - {% if config.get('PROJECT_TICKETS', True) %} + {% if config.get('ENABLE_TICKETS', True) %} Tickets : diff --git a/pagure/templates/repo_master.html b/pagure/templates/repo_master.html index 1bf70a3..5ff21b0 100644 --- a/pagure/templates/repo_master.html +++ b/pagure/templates/repo_master.html @@ -60,7 +60,7 @@ repo=repo.name) }}">Tags

  • - {% if config.get('PROJECT_TICKETS', True) and repo + {% if config.get('ENABLE_TICKETS', True) and repo and repo.settings.get('issue_tracker', True) %}
  • {% for key in repo.settings | sort %} - {% if not config.get('PROJECT_TICKETS', True) and key in ['issue_tracker'] %} + {% if not config.get('ENABLE_TICKETS', True) and key in ['issue_tracker'] %} {% elif not config.get('DOC_APP_URL') and key in ['project_documentation'] %} {% else %} @@ -284,7 +284,7 @@ {% endif %} -{% if config.get('PROJECT_TICKETS', True) %} +{% if config.get('ENABLE_TICKETS', True) %}

    Tags