Implement tower ui view url on models

This commit is contained in:
Matthew Jones
2016-02-23 14:19:42 -05:00
parent b88892be49
commit 75ef0dd395
8 changed files with 48 additions and 10 deletions

View File

@@ -6,6 +6,7 @@ import datetime
import logging
import re
import copy
from urlparse import urljoin
# Django
from django.conf import settings
@@ -25,6 +26,7 @@ from awx.main.models.jobs import Job
from awx.main.models.unified_jobs import * # noqa
from awx.main.models.notifications import Notifier
from awx.main.utils import ignore_inventory_computed_fields, _inventory_updates
from awx.main.conf import tower_settings
__all__ = ['Inventory', 'Host', 'Group', 'InventorySource', 'InventoryUpdate', 'CustomInventoryScript']
@@ -1249,6 +1251,9 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions):
def get_absolute_url(self):
return reverse('api:inventory_update_detail', args=(self.pk,))
def get_ui_url(self):
return urljoin(tower_settings.TOWER_URL_BASE, "/#/inventory_sync/{}".format(self.pk))
def is_blocked_by(self, obj):
if type(obj) == InventoryUpdate:
if self.inventory_source.inventory == obj.inventory_source.inventory: