Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index 62aa96a..bd71db9 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -729,7 +729,7 @@
class SliceAdmin(PlanetStackBaseAdmin):
form = SliceForm
- fieldList = ['backend_status_text', 'name', 'site', 'serviceClass', 'enabled','description', 'service', 'slice_url', 'max_slivers']
+ fieldList = ['backend_status_text', 'site', 'name', 'serviceClass', 'enabled','description', 'service', 'slice_url', 'max_slivers']
fieldsets = [('Slice Details', {'fields': fieldList, 'classes':['suit-tab suit-tab-general']}),]
readonly_fields = ('backend_status_text', )
list_display = ('backend_status_icon', 'slicename', 'site','serviceClass', 'slice_url', 'max_slivers')
@@ -755,13 +755,19 @@
for node in Node.objects.all():
deployment_nodes.append( (node.deployment.id, node.id, node.name) )
+ sites = {}
+ for site in Site.objects.all():
+ sites[site.id] = site.login_base
+
context["deployment_nodes"] = deployment_nodes
+ context["sites"] = sites
return super(SliceAdmin, self).render_change_form(request, context, add, change, form_url, obj)
def formfield_for_foreignkey(self, db_field, request, **kwargs):
if db_field.name == 'site':
kwargs['queryset'] = Site.select_by_user(request.user)
+ kwargs['widget'] = forms.Select(attrs={'onChange': "update_slice_name(this, $($(this).closest('div')[0]).find('.field-name input')[0].id)"})
return super(SliceAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
diff --git a/planetstack/templates/admin/core/slice/change_form.html b/planetstack/templates/admin/core/slice/change_form.html
index c94b580..e97364b 100644
--- a/planetstack/templates/admin/core/slice/change_form.html
+++ b/planetstack/templates/admin/core/slice/change_form.html
@@ -8,6 +8,13 @@
{% endfor %}
];
+sites = [
+{% for s in sites %}
+ [{{ s.0 }}, {{ s.1 }}],
+{% endfor %}
+];
+
+
function update_nodes(deployment_select, node_select_id) {
deployment_id = $(deployment_select).val();
html = "<option value=''>---------</option>\n";
@@ -20,6 +27,15 @@
//console.log(html);
$("#"+node_select_id).empty().append(html);
}
+
+function update_slice_prefix(site_select, slice_name_id) {
+ site_id = $(site_select).val();
+ slice_prefix="";
+ if (site_id in sites) {
+ slice_prefix=sites[site_id]+"_";
+ }
+ $("#"+slice_name_id).val(slice_prefix);
+}
</script>
{% endblock %}