move plan choice into form
This commit is contained in:
parent
928bd0818e
commit
aa4ec33c93
4 changed files with 56 additions and 7 deletions
|
@ -26,7 +26,7 @@ def contact_form(request):
|
|||
lead = Lead(
|
||||
name=form.cleaned_data["name"],
|
||||
email=form.cleaned_data["email"],
|
||||
message=form.cleaned_data["message"],
|
||||
message=form.cleaned_data["message"] or "",
|
||||
company=form.cleaned_data["company"],
|
||||
phone=form.cleaned_data["phone"],
|
||||
)
|
||||
|
@ -87,6 +87,22 @@ def contact_form(request):
|
|||
if plan_name:
|
||||
service_info.append(f"Plan: {plan_name}")
|
||||
|
||||
# Handle selected choice if present
|
||||
selected_choice = request.POST.get("selected_choice", "")
|
||||
if selected_choice:
|
||||
try:
|
||||
choice_id, choice_name = selected_choice.split("|", 1)
|
||||
# Add selected choice to message
|
||||
service_info.append(f"Selected Plan: {choice_name}")
|
||||
|
||||
# Try to set the plan based on the choice_id
|
||||
try:
|
||||
lead.plan = Plan.objects.get(id=choice_id)
|
||||
except Plan.DoesNotExist:
|
||||
pass
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if service_info:
|
||||
context_info.append("Service Information: " + ", ".join(service_info))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue