SEBA-457 Core xproto cleanup

Change-Id: Ib99680dd81016694094a5c230afdf9dcf2cb307e
diff --git a/lib/xos-genx/xosgenx/jinja2_extensions/gui.py b/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
index 245bbda..4cb644a 100644
--- a/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
+++ b/lib/xos-genx/xosgenx/jinja2_extensions/gui.py
@@ -96,17 +96,23 @@
 
 
 def xproto_default_to_gui(default):
+    # TODO: Using `eval` here is potentially dangerous as it may allow code injection
     val = "null"
-    if is_number(default):
-        val = str(default)
-    elif eval(default) is True:
-        val = "true"
-    elif eval(default) is False:
-        val = "false"
-    elif eval(default) is None:
+    try:
+        if is_number(default):
+            val = str(default)
+        elif eval(default) is True:
+            val = "true"
+        elif eval(default) is False:
+            val = "false"
+        elif eval(default) is None:
+            val = "null"
+        else:
+            val = str(default)
+    except NameError:
+        # val was a function call, and we can't pass those to the GUI
         val = "null"
-    else:
-        val = str(default)
+
     return val
 
 
diff --git a/lib/xos-genx/xosgenx/targets/mock_classes.xtarget b/lib/xos-genx/xosgenx/targets/mock_classes.xtarget
index 61c2f1f..bc56747 100644
--- a/lib/xos-genx/xosgenx/targets/mock_classes.xtarget
+++ b/lib/xos-genx/xosgenx/targets/mock_classes.xtarget
@@ -225,6 +225,9 @@
 
 model_accessor = ModelAccessor()
 
+def get_first_site():
+    return model_accessor.Site.objects.first().id
+
 class ObjectSet(object):
     def __init__(self, objects):
         self.objects = objects
diff --git a/lib/xos-genx/xosgenx/targets/service.xtarget b/lib/xos-genx/xosgenx/targets/service.xtarget
index 1027680..4c47fab 100644
--- a/lib/xos-genx/xosgenx/targets/service.xtarget
+++ b/lib/xos-genx/xosgenx/targets/service.xtarget
@@ -2,14 +2,14 @@
 {% set legacy_tag = '_decl' %}
 {% set legacy = True %}
 from core.models.xosbase import *
-from core.models import ServiceInstance, TenantWithContainer
+from core.models import ServiceInstance
 {% else %}
 {% set legacy = False %}
 {% set legacy_tag = '' %}
 {% if file_exists('../header.py') or file_exists('header.py')-%}from header import *
 {% else %}
 from core.models.xosbase import *
-from core.models import ServiceInstance, TenantWithContainer
+from core.models import ServiceInstance
 {% endif %}
 {% endif %}