merge
diff --git a/planetstack/core/admin.py b/planetstack/core/admin.py
index fad99a0..3ddf871 100644
--- a/planetstack/core/admin.py
+++ b/planetstack/core/admin.py
@@ -762,20 +762,19 @@
for deployment in flavor.deployments.all():
deployment_flavors.append( (deployment.id, flavor.id, flavor.name) )
- sites = {}
- for site in Site.objects.all():
- sites[site.id] = site.login_base
-
+ site_login_bases = []
+ for site in Site.objects.all():
+ site_login_bases.append((site.id, site.login_base))
+
context["deployment_nodes"] = deployment_nodes
context["deployment_flavors"] = deployment_flavors
- context["sites"] = sites
-
+ context["site_login_bases"] = site_login_bases
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)"})
+ kwargs['widget'] = forms.Select(attrs={'onChange': "update_slice_prefix(this, $($(this).closest('fieldset')[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 9fb9758..1084004 100644
--- a/planetstack/templates/admin/core/slice/change_form.html
+++ b/planetstack/templates/admin/core/slice/change_form.html
@@ -14,13 +14,12 @@
{% endfor %}
];
-sites = [
-{% for s in sites %}
- [{{ s.0 }}, {{ s.1 }}],
+site_login_bases = [
+{% for s in site_login_bases %}
+ [{{ s.0 }}, "{{ s.1 }}"],
{% endfor %}
];
-
function update_nodes(deployment_select, node_select_id) {
deployment_id = $(deployment_select).val();
html = "<option value=''>---------</option>\n";
@@ -63,8 +62,10 @@
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]+"_";
+ for (i in site_login_bases) {
+ if (site_login_bases[i][0] == site_id) {
+ slice_prefix=site_login_bases[i][1]+"_";
+ }
}
$("#"+slice_name_id).val(slice_prefix);
}