-
-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework how external bug tracker integrations are discovered
- All of them are now listed as dotted class paths under the EXTERNAL_BUG_TRACKERS setting - DB migration will rename existing records - tcms.issuetracker.types.from_name() is replaced with django.utils.module_loading.import_string() which returns the class at the end of a dotted path - update documentation Refs #1151 - will make overriding bug-tracker integration easier Refs kiwitcms/github-app#25 - will open the path to providing a custom GitHub Issues integration for the GitHub App
- Loading branch information
Showing
13 changed files
with
70 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ def _fixture_setup(self): | |
|
||
bug_system = BugSystem.objects.create( # nosec:B106:hardcoded_password_funcarg | ||
name='Dockerized Bugzilla', | ||
tracker_type='Bugzilla', | ||
tracker_type='tcms.issuetracker.types.Bugzilla', | ||
base_url='http://bugtracker.kiwitcms.org/bugzilla/', | ||
api_url='http://bugtracker.kiwitcms.org/bugzilla/xmlrpc.cgi', | ||
api_username='[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
# Copyright (c) 2019 Alexander Todorov <[email protected]> | ||
# Copyright (c) 2019-2020 Alexander Todorov <[email protected]> | ||
|
||
# Licensed under the GPL 2.0: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html | ||
|
||
from tcms.issuetracker.types import from_name | ||
from django.utils.module_loading import import_string | ||
|
||
from tcms.testcases.models import BugSystem | ||
|
||
|
||
|
@@ -14,6 +15,6 @@ def tracker_from_url(url): | |
""" | ||
for bug_system in BugSystem.objects.all(): | ||
if bug_system.base_url and url.startswith(bug_system.base_url): | ||
return from_name(bug_system.tracker_type)(bug_system) | ||
return import_string(bug_system.tracker_type)(bug_system) | ||
|
||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tcms/testcases/migrations/0014_update_issutracker_types.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from django.db import migrations | ||
|
||
|
||
def forwards(apps, schema_editor): | ||
BugSystem = apps.get_model('testcases', 'BugSystem') | ||
|
||
for record in BugSystem.objects.all(): | ||
if record.tracker_type: | ||
record.tracker_type = "tcms.issuetracker.types.%s" % record.tracker_type | ||
record.save() | ||
|
||
|
||
def backwards(apps, schema_editor): | ||
BugSystem = apps.get_model('testcases', 'BugSystem') | ||
|
||
for record in BugSystem.objects.all(): | ||
if record.tracker_type.startswith('tcms.issuetracker.types.'): | ||
record.tracker_type = record.tracker_type.replace('tcms.issuetracker.types.', '') | ||
record.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('testcases', '0013_remove_autofield'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forwards, backwards), | ||
] |