def services_edit(request, service=None, template="cache/services_edit.html"): if request.method == "POST": instance = TileService.objects.get(name=service) service_form = TileServiceForm(request.POST,instance=instance) if service_form.is_valid(): service_form.save() ### context_dict = { 'service': instance, 'service_form': TileServiceForm(instance=instance) } return HttpResponseRedirect(reverse('services_list',args=())) else: return HttpResponse( 'An unknown error has occured.', content_type="text/plain", status=401 ) else: instance = TileService.objects.get(name=service) context_dict = { 'service': instance, 'service_form': TileServiceForm(instance=instance) } return render_to_response( template, RequestContext(request, context_dict))
def services_new(request, source=None, template="cache/services_edit.html"): if request.method == "POST": service_form = TileServiceForm(request.POST) if service_form.is_valid(): service_form.save() ### context_dict = { 'service_form': TileServiceForm() } return HttpResponseRedirect(reverse('services_list',args=())) else: service_form = None if source: source_object = TileSource.objects.get(name=source) service_form = TileServiceForm(initial={'source': source_object, 'name': source_object.name, 'description': source_object.description, 'type': source_object.type, 'url': '/cache/tms/', 'extensions': [u'png']}) else: service_form = TileServiceForm() context_dict = { 'service_form': service_form } return render_to_response( template, RequestContext(request, context_dict))