diff options
author | Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> | 2024-09-13 19:20:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-13 19:20:00 +0200 |
commit | 38719405c318fbe898fb141428009f11cb08de49 (patch) | |
tree | 4919bd916d7f95f3cfc5abc38d4f62b72d46b33d | |
parent | 🧪 Gather coverage @ CI and upload to Codecov (#15499) (diff) | |
download | awx-38719405c318fbe898fb141428009f11cb08de49.tar.xz awx-38719405c318fbe898fb141428009f11cb08de49.zip |
Add OPTIONAL_UI_URL_PREFIX (#15506)
# Add a postfix to the UI URL patterns for UI URL generated by the API
# example if set to '' UI URL generated by the API for jobs would be $TOWER_URL/jobs
# example if set to 'execution' UI URL generated by the API for jobs would be $TOWER_URL/execution/jobs
-rw-r--r-- | awx/main/models/ad_hoc_commands.py | 2 | ||||
-rw-r--r-- | awx/main/models/inventory.py | 2 | ||||
-rw-r--r-- | awx/main/models/jobs.py | 4 | ||||
-rw-r--r-- | awx/main/models/projects.py | 2 | ||||
-rw-r--r-- | awx/settings/defaults.py | 5 |
5 files changed, 10 insertions, 5 deletions
diff --git a/awx/main/models/ad_hoc_commands.py b/awx/main/models/ad_hoc_commands.py index 0583e07c04..70b3437541 100644 --- a/awx/main/models/ad_hoc_commands.py +++ b/awx/main/models/ad_hoc_commands.py @@ -161,7 +161,7 @@ class AdHocCommand(UnifiedJob, JobNotificationMixin): return reverse('api:ad_hoc_command_detail', kwargs={'pk': self.pk}, request=request) def get_ui_url(self): - return urljoin(settings.TOWER_URL_BASE, "/#/jobs/command/{}".format(self.pk)) + return urljoin(settings.TOWER_URL_BASE, "{}/jobs/command/{}".format(settings.OPTIONAL_UI_URL_PREFIX, self.pk)) @property def notification_templates(self): diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index acc900250c..15f8b15625 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1348,7 +1348,7 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions, JobNotificationMixin, return reverse('api:inventory_update_detail', kwargs={'pk': self.pk}, request=request) def get_ui_url(self): - return urljoin(settings.TOWER_URL_BASE, "/#/jobs/inventory/{}".format(self.pk)) + return urljoin(settings.TOWER_URL_BASE, "{}/jobs/inventory/{}".format(settings.OPTIONAL_UI_URL_PREFIX, self.pk)) def get_actual_source_path(self): '''Alias to source_path that combines with project path for for SCM file based sources''' diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 551dd631d9..a1982d1ac0 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -628,7 +628,7 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin, TaskMana return reverse('api:job_detail', kwargs={'pk': self.pk}, request=request) def get_ui_url(self): - return urljoin(settings.TOWER_URL_BASE, "/#/jobs/playbook/{}".format(self.pk)) + return urljoin(settings.TOWER_URL_BASE, "{}/jobs/playbook/{}".format(settings.OPTIONAL_UI_URL_PREFIX, self.pk)) def _set_default_dependencies_processed(self): """ @@ -1275,7 +1275,7 @@ class SystemJob(UnifiedJob, SystemJobOptions, JobNotificationMixin): return reverse('api:system_job_detail', kwargs={'pk': self.pk}, request=request) def get_ui_url(self): - return urljoin(settings.TOWER_URL_BASE, "/#/jobs/system/{}".format(self.pk)) + return urljoin(settings.TOWER_URL_BASE, "{}/jobs/system/{}".format(settings.OPTIONAL_UI_URL_PREFIX, self.pk)) @property def event_class(self): diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index 0a571194b0..8c8fcd52ba 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -631,7 +631,7 @@ class ProjectUpdate(UnifiedJob, ProjectOptions, JobNotificationMixin, TaskManage return reverse('api:project_update_detail', kwargs={'pk': self.pk}, request=request) def get_ui_url(self): - return urlparse.urljoin(settings.TOWER_URL_BASE, "/#/jobs/project/{}".format(self.pk)) + return urlparse.urljoin(settings.TOWER_URL_BASE, "{}/jobs/project/{}".format(settings.OPTIONAL_UI_URL_PREFIX, self.pk)) def cancel(self, job_explanation=None, is_chain=False): res = super(ProjectUpdate, self).cancel(job_explanation=job_explanation, is_chain=is_chain) diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 50e467adf2..edf453832a 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -1157,6 +1157,11 @@ include(os.path.join(os.path.dirname(dynamic_config.__file__), 'dynamic_settings # example if set to 'controller' API pattern will be /api AND /api/controller OPTIONAL_API_URLPATTERN_PREFIX = '' +# Add a postfix to the UI URL patterns for UI URL generated by the API +# example if set to '' UI URL generated by the API for jobs would be $TOWER_URL/jobs +# example if set to 'execution' UI URL generated by the API for jobs would be $TOWER_URL/execution/jobs +OPTIONAL_UI_URL_PREFIX = '' + # Use AWX base view, to give 401 on unauthenticated requests ANSIBLE_BASE_CUSTOM_VIEW_PARENT = 'awx.api.generics.APIView' |