def add_engagement_presets(request, pid): prod = get_object_or_404(Product, id=pid) if request.method == 'POST': tform = EngagementPresetsForm(request.POST) if tform.is_valid(): form_copy = tform.save(commit=False) form_copy.product = prod form_copy.save() tform.save_m2m() messages.add_message(request, messages.SUCCESS, 'Engagement Preset Successfully Created.', extra_tags='alert-success') return HttpResponseRedirect( reverse('engagement_presets', args=(pid, ))) else: tform = EngagementPresetsForm() product_tab = Product_Tab(pid, title="New Engagement Preset", tab="settings") return render(request, 'dojo/new_params.html', { 'tform': tform, 'pid': pid, 'product_tab': product_tab })
def edit_engagement_presets(request, pid, eid): prod = get_object_or_404(Product, id=pid) preset = get_object_or_404(Engagement_Presets, id=eid) product_tab = Product_Tab(prod.id, title="Edit Engagement Preset", tab="settings") if request.method == 'POST': tform = EngagementPresetsForm(request.POST, instance=preset) if tform.is_valid(): tform.save() messages.add_message(request, messages.SUCCESS, 'Engagement Preset Successfully Updated.', extra_tags='alert-success') return HttpResponseRedirect( reverse('engagement_presets', args=(pid, ))) else: tform = EngagementPresetsForm(instance=preset) return render(request, 'dojo/edit_presets.html', { 'product_tab': product_tab, 'tform': tform, 'prod': prod })
def edit_engagement_presets(request, pid, eid): prod = get_object_or_404(Product, id=pid) preset = get_object_or_404(Engagement_Presets, id=eid) product_tab = Product_Tab(prod.id, title="Edit Engagement Preset", tab="settings") if request.method == 'POST': tform = EngagementPresetsForm(request.POST, instance=preset) if tform.is_valid(): tform.save() messages.add_message( request, messages.SUCCESS, 'Engagement Preset Successfully Updated.', extra_tags='alert-success') return HttpResponseRedirect(reverse('engagement_presets', args=(pid,))) else: tform = EngagementPresetsForm(instance=preset) return render(request, 'dojo/edit_presets.html', {'product_tab': product_tab, 'tform': tform, 'prod': prod})
def add_engagement_presets(request, pid): prod = get_object_or_404(Product, id=pid) if request.method == 'POST': tform = EngagementPresetsForm(request.POST) if tform.is_valid(): form_copy = tform.save(commit=False) form_copy.product = prod form_copy.save() tform.save_m2m() messages.add_message( request, messages.SUCCESS, 'Engagement Preset Successfully Created.', extra_tags='alert-success') return HttpResponseRedirect(reverse('engagement_presets', args=(pid,))) else: tform = EngagementPresetsForm() product_tab = Product_Tab(pid, title="New Engagement Preset", tab="settings") return render(request, 'dojo/new_params.html', {'tform': tform, 'pid': pid, 'product_tab': product_tab})