Przeglądaj źródła

fixed small ntp servers module issues with var valiations

Roberto Berto 5 lat temu
rodzic
commit
05960532b2

+ 8 - 0
vycontrol/ntp/templates/ntp/list.html

@@ -7,12 +7,20 @@
 {% endblock %}
 
 {% block content %}
+
+
+
 <h3>Servers</h3>
 
+{% if ntp_servers %}
 <ul>
 {% for server in ntp_servers %}
     <li>{{ server }}</li>
 {% endfor %}
 </ul>
+{% else %}
+<p>No NTP Server defined.</p>
+{% endif %}
+
 {% endblock %}
 

+ 15 - 3
vycontrol/ntp/views.py

@@ -8,13 +8,25 @@ from django.contrib.auth.decorators import login_required
 
 import vyos
 import vycontrol_vyos_api as vapi
+import perms
 
 @login_required
 def index(request):
     all_instances = vyos.instance_getall()
     hostname_default = vyos.get_hostname_prefered(request)
+    is_superuser = perms.get_is_superuser(request.user)
+
     ntp_srv = vapi.get_ntp(hostname_default)
-    context = {'instances': all_instances,
-               'hostname_default': hostname_default,
-               'ntp_servers': ntp_srv.data['server']}
+    ntp_servers = {}
+    if ntp_srv.success:
+        if ntp_srv.data['server'] != None:
+            ntp_servers = ntp_srv.data['server']
+
+    context = {
+        'instances':                                all_instances,
+        'hostname_default':                         hostname_default,
+        'ntp_servers' :                             ntp_servers,
+        'is_superuser' :                            is_superuser,
+    }
+
     return render(request, 'ntp/list.html', context)

+ 7 - 35
vycontrol/vycontrol/templates/base.html

@@ -65,59 +65,31 @@
 
 
 
-      <h2>Manage VyOS</h2>
-
+    <h2>Manage VyOS</h2>
     <ul>
     <li><a href="{% url 'interface:interface-list' %}">Interfaces</a></li>
     <li><a href="{% url 'firewall:firewall-list' %}">Firewall</a></li>
-    </ul>
-
-    <h2>Manage Routing</h2>
-    <ul>
     <li><a href="{% url 'static:static-list' %}">Static Routing</a></li>
+    <li><a href="{% url 'ntp:ntp-list' %}">NTP</a></li>
+
     <!-- 
     <li><a href="{% url 'arp:arp-list' %}">ARP</a></li>
     <li><a href="{% url 'ospf:ospf-list' %}">OSPF</a></li>
     <li><a href="{% url 'bgp:bgp-list' %}">BGP</a></li>
-    -->
-    </ul>
-
-    <!--
-    <h2>Manage Services</h2>
-    <ul>
     <li><a href="{% url 'dhcp:dhcp-list' %}">DHCP</a></li>
     <li><a href="{% url 'ssh:ssh-list' %}">SSH</a></li>
-    </ul>
-
-    <h2>Manage VPN</h2>
-    <ul>
     <li><a href="{% url 'openvpn:openvpn-list' %}">OpenVPN</a></li>
     <li><a href="{% url 'ipsec:ipsec-list' %}">IPSEC</a></li>
-    </ul>
-
-    <h2>Manage NTP</h2>
-    <ul>
-      <li><a href="{% url 'ntp:ntp-list' %}">NTP</a></li>
-    </ul>
-
-    <h2>Manage NAT</h2>
-    <ul>
-      <li><a href="{% url 'nat:nat-list' %}">NAT</a></li>
-    </ul>
-    <h2>Manage QoS</h2>
-    <ul>
+    <li><a href="{% url 'nat:nat-list' %}">NAT</a></li>
     <li><a href="{% url 'qos:qos-list' %}">QoS</a></li>
-    </ul>    
-
-    <h2>Manage Wan Load Balancing</h2>
-    <ul>
     <li><a href="{% url 'wanlb:wanlb-list' %}">Wan Load Balancing</a></li>
-    </ul>        
     -->
+  </ul>
+
 
     <h2>Manage VyControl</h2>
     <ul>
-      {% if is_superuser %}<li><a href="{% url 'config:instance-add' %}">Add new instance</a></li>{% endif %}
+    {% if is_superuser %}<li><a href="{% url 'config:instance-add' %}">Add new instance</a></li>{% endif %}
     <li><a href="{% url 'config:instances' %}">List instances</a></li>
     {% if is_superuser %}<li><a href="{% url 'config:users-list' %}">List users</a></li>{% endif %}
     {% if is_superuser %}<li><a href="{% url 'config:user-add' %}">Add new user</a></li>{% endif %}