def add_meta_data(request, pid): prod = Product.objects.get(id=pid) if request.method == 'POST': form = DojoMetaDataForm(request.POST, instance=DojoMeta(product=prod)) if form.is_valid(): form.save() messages.add_message(request, messages.SUCCESS, 'Metadata added successfully.', extra_tags='alert-success') if 'add_another' in request.POST: return HttpResponseRedirect( reverse('add_meta_data', args=(pid, ))) else: return HttpResponseRedirect( reverse('view_product', args=(pid, ))) else: form = DojoMetaDataForm() product_tab = Product_Tab(pid, title="Add Metadata", tab="settings") return render(request, 'dojo/add_product_meta_data.html', { 'form': form, 'product_tab': product_tab, 'product': prod, })
def add_meta_data(request, eid): endpoint = Endpoint.objects.get(id=eid) if request.method == 'POST': form = DojoMetaDataForm(request.POST, instance=DojoMeta(endpoint=endpoint)) if form.is_valid(): form.save() messages.add_message(request, messages.SUCCESS, 'Metadata added successfully.', extra_tags='alert-success') if 'add_another' in request.POST: return HttpResponseRedirect( reverse('add_meta_data', args=(eid, ))) else: return HttpResponseRedirect( reverse('view_endpoint', args=(eid, ))) else: form = DojoMetaDataForm() add_breadcrumb(parent=endpoint, title="Add Metadata", top_level=False, request=request) product_tab = Product_Tab(endpoint.product.id, "Add Metadata", tab="endpoints") return render(request, 'dojo/add_endpoint_meta_data.html', { 'form': form, 'product_tab': product_tab, 'endpoint': endpoint, })
def add_meta_data(request, pid): prod = Product.objects.get(id=pid) if request.method == 'POST': form = DojoMetaDataForm(request.POST, instance=DojoMeta(product=prod)) if form.is_valid(): form.save() messages.add_message(request, messages.SUCCESS, 'Metadata added successfully.', extra_tags='alert-success') if 'add_another' in request.POST: return HttpResponseRedirect(reverse('add_meta_data', args=(pid,))) else: return HttpResponseRedirect(reverse('view_product', args=(pid,))) else: form = DojoMetaDataForm() product_tab = Product_Tab(pid, title="Add Metadata", tab="settings") return render(request, 'dojo/add_product_meta_data.html', {'form': form, 'product_tab': product_tab, 'product': prod, })
def add_meta_data(request, pid): prod = Product.objects.get(id=pid) if request.method == 'POST': form = DojoMetaDataForm(request.POST) if form.is_valid(): cf, created = DojoMeta.objects.get_or_create( name=form.cleaned_data['name'], model_name='Product', model_id=prod.id, value=form.cleaned_data['value']) cf.save() prod.product_meta.add(cf) prod.save() messages.add_message(request, messages.SUCCESS, 'Metadata added successfully.', extra_tags='alert-success') if 'add_another' in request.POST: return HttpResponseRedirect( reverse('add_meta_data', args=(pid, ))) else: return HttpResponseRedirect( reverse('view_product', args=(pid, ))) else: form = DojoMetaDataForm() product_tab = Product_Tab(pid, title="Add Metadata", tab="settings") return render(request, 'dojo/add_product_meta_data.html', { 'form': form, 'product_tab': product_tab, 'product': prod, })
def add_meta_data(request, eid): endpoint = Endpoint.objects.get(id=eid) if request.method == 'POST': form = DojoMetaDataForm(request.POST, instance=DojoMeta(endpoint=endpoint)) if form.is_valid(): form.save() messages.add_message(request, messages.SUCCESS, 'Metadata added successfully.', extra_tags='alert-success') if 'add_another' in request.POST: return HttpResponseRedirect(reverse('add_meta_data', args=(eid,))) else: return HttpResponseRedirect(reverse('view_endpoint', args=(eid,))) else: form = DojoMetaDataForm() add_breadcrumb(parent=endpoint, title="Add Metadata", top_level=False, request=request) product_tab = Product_Tab(endpoint.product.id, "Add Metadata", tab="endpoints") return render(request, 'dojo/add_endpoint_meta_data.html', {'form': form, 'product_tab': product_tab, 'endpoint': endpoint, })
def add_meta_data(request, eid): endpoint = Endpoint.objects.get(id=eid) if request.method == 'POST': form = DojoMetaDataForm(request.POST) if form.is_valid(): cf, created = DojoMeta.objects.get_or_create( name=form.cleaned_data['name'], model_name='Endpoint', model_id=endpoint.id, value=form.cleaned_data['value']) cf.save() messages.add_message(request, messages.SUCCESS, 'Metadata added successfully.', extra_tags='alert-success') if 'add_another' in request.POST: return HttpResponseRedirect( reverse('add_meta_data', args=(eid, ))) else: return HttpResponseRedirect( reverse('view_endpoint', args=(eid, ))) else: form = DojoMetaDataForm(initial={'content_type': endpoint}) add_breadcrumb(parent=endpoint, title="Add Metadata", top_level=False, request=request) product_tab = Product_Tab(endpoint.product.id, "Add Metadata", tab="endpoints") return render(request, 'dojo/add_endpoint_meta_data.html', { 'form': form, 'product_tab': product_tab, 'endpoint': endpoint, })