supply the correct slice id when using the expert window
diff --git a/xos/core/admin.py b/xos/core/admin.py
index 092e216..d5246ae 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -1120,6 +1120,12 @@
inline.model.caller = request.user
yield inline.get_formset(request, obj)
+ def add_extra_context(self, request, extra_context):
+ super(SliceAdmin, self).add_extra_context(request, extra_context)
+ # set context["slice_id"] to the PK passed in the URL to this view
+ if len(request.resolver_match.args)>0:
+ extra_context["slice_id"] = request.resolver_match.args[0]
+
def UNUSED_get_inline_instances(self, request, obj=None):
# HACK for CORD to do something special on vcpe slice page
# this was a good idea, but failed miserably, as something still
diff --git a/xos/core/templates/slice_instance_tab.html b/xos/core/templates/slice_instance_tab.html
index 73f0ca8..f3890c8 100644
--- a/xos/core/templates/slice_instance_tab.html
+++ b/xos/core/templates/slice_instance_tab.html
@@ -1,4 +1,6 @@
-<a href="/admin/core/instance/add/?_to_field=id&slice=1" class="add-another" id="add_instance_advanced"
+{% if slice_id %}
+
+<a href="/admin/core/instance/add/?_to_field=id&slice={{ slice_id }}" class="add-another" id="add_instance_advanced"
onclick="return showAddInstancePopup(this);">
Add Instance using expert settings window
</a>
@@ -35,3 +37,5 @@
}
</script>
+
+{% endif %}