add expert mode for adding instances
diff --git a/xos/core/admin.py b/xos/core/admin.py
index 93486a2..092e216 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -1041,6 +1041,7 @@
normal_inlines = [SlicePrivilegeInline, InstanceInline, TagInline, ReservationInline, SliceNetworkInline]
inlines = normal_inlines
admin_inlines = [ControllerSliceInline]
+ suit_form_includes = (('slice_instance_tab.html', 'bottom', 'instances'),)
user_readonly_fields = fieldList
@@ -1291,11 +1292,7 @@
self.readonly_fields = ('backend_status_text', 'ssh_command', 'all_ips_string', 'slice', 'flavor', 'image', 'node')
for inline in self.get_inline_instances(request, obj):
- # hide MyInline in the add view
- if obj is None:
- continue
- if isinstance(inline, InstanceInline):
- inline.model.caller = request.user
+ # dead code was eliminated here
yield inline.get_formset(request, obj)
#def save_model(self, request, obj, form, change):
diff --git a/xos/core/templates/slice_instance_tab.html b/xos/core/templates/slice_instance_tab.html
new file mode 100644
index 0000000..73f0ca8
--- /dev/null
+++ b/xos/core/templates/slice_instance_tab.html
@@ -0,0 +1,37 @@
+<a href="/admin/core/instance/add/?_to_field=id&slice=1" class="add-another" id="add_instance_advanced"
+onclick="return showAddInstancePopup(this);">
+Add Instance using expert settings window
+</a>
+<!-- div id="instance_advanced" style="display: node;" onchange="console.log('changed');" -->
+<input type="hidden" id="instance_advanced" name="instance_advanced" onchange="console.log('changed');" value="initial">
+
+<script>
+
+// ugly - poll for djange to change "instance_advanced", and it it does, then refresh the
+// page so the instance list gets updated.
+var last_instance_advanced = $("#instance_advanced").val();
+checkInstanceAdvanced = function() {
+ cur = $("#instance_advanced").val();
+ if (cur != last_instance_advanced) {
+ last_instance_advanced = cur;
+ location.reload();
+ }
+};
+
+setInterval(function() { checkInstanceAdvanced(); }, 1000);
+
+function showAddInstancePopup(triggeringLink) {
+ var name = triggeringLink.id.replace(/^add_/, '');
+ name = id_to_windowname(name);
+ var href = triggeringLink.href;
+ if (href.indexOf('?') == -1) {
+ href += '?_popup=1';
+ } else {
+ href += '&_popup=1';
+ }
+ var win = window.open(href, name, 'height=500,width=1080,resizable=yes,scrollbars=yes');
+ win.focus();
+ return false;
+}
+
+</script>