Browse Source

fix check_mk url

Élie Bouttier 7 years ago
parent
commit
2a2d4e777e
2 changed files with 5 additions and 2 deletions
  1. 2 0
      djadhere/settings.py
  2. 3 2
      services/models.py

+ 2 - 0
djadhere/settings.py

@@ -178,3 +178,5 @@ LEAFLET_CONFIG = {
     'DEFAULT_CENTER': (43.6044, 1.4433),
     'DEFAULT_ZOOM': 12,
 }
+
+CHECK_MK_URL = 'https://nagios.tetaneutral.net/ttnn/check_mk/index.py?start_url=%2Fttnn%2Fcheck_mk%2Fview.py%3Fhost%3D{host}%26site%3Dttnn%26view_name%3Dhoststatus'

+ 3 - 2
services/models.py

@@ -10,8 +10,10 @@ from django.urls import reverse
 from django.utils.html import format_html, mark_safe, escape
 from django.core.exceptions import PermissionDenied
 from django.core.validators import RegexValidator, MinValueValidator, MaxValueValidator
+from django.conf import settings
 
 from ipaddress import ip_network
+from urllib.parse import quote
 
 from djadhere.utils import get_active_filter, is_overlapping
 from adhesions.models import Adhesion
@@ -104,8 +106,7 @@ class IPResource(models.Model):
     @property
     def checkmk_url(self):
         if self.checkmk_label:
-            # TODO: put url in config
-            return mark_safe('https://nagios.tetaneutral.net/check_mk/view.py?host={}&view_name=host'.format(escape(self.checkmk_label)))
+            return mark_safe(settings.CHECK_MK_URL.format(host=quote(self.checkmk_label)))
         else:
             return None