Skip to content

Commit

Permalink
Fix #1345 Preserve questions attached to plans upon edit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsimpson committed Jun 5, 2024
1 parent 5a6d3b6 commit eb80169
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions subscribie/blueprints/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
Category,
UpcomingInvoice,
Document,
PlanQuestionAssociation,
)
from .subscription import update_stripe_subscription_statuses
from .stats import (
Expand Down Expand Up @@ -644,6 +645,16 @@ def edit():
filename = images.save(f)
src = url_for("views.custom_static", filename=filename)
draftPlan.primary_icon = src

# Preserve questions
for plan_question_association in plan.questions:
new_plan_question_assoc = PlanQuestionAssociation()
new_plan_question_assoc.question_id = (
plan_question_association.question_id
)
new_plan_question_assoc.plan_id = draftPlan.id
database.session.add(new_plan_question_assoc)

database.session.commit() # Save
flash("Plan(s) updated.")
return redirect(url_for("admin.edit"))
Expand Down

0 comments on commit eb80169

Please sign in to comment.