def change(api, request, type, group): if request.method == 'POST': form = ExternalNetworkForm(request.POST) if form.is_valid(): d=form.cleaned_data params={"avoid_duplicates": d["avoid_duplicates"]} if d["max_devices"]: params["max_devices"] = d["max_devices"] print d api.external_network_change(d["type"], d["group"], params) return index(request) else: for en in api.external_networks(): if en["type"] == type and en["group"] == group: form = ExternalNetworkForm({"type": en["type"], "group": en["group"], "max_devices": (en["max_devices"] if en["max_devices"] else ""), "avoid_duplicates": en["avoid_duplicates"]}) form.fields["type"].widget = forms.widgets.HiddenInput() form.fields["group"].widget = forms.widgets.HiddenInput() return render_to_response("admin/generic_form.html", {'type': "external network", 'name': "%s (%s)" % (type, group), 'form': form})
def index(api, request): return render_to_response("admin/external_networks_index.html", {'list': api.external_networks()})