diff --git a/.github/workflows/pr-demo-deploy.yml b/.github/workflows/pr-demo-deploy.yml index 8963a01e..0cc7f723 100644 --- a/.github/workflows/pr-demo-deploy.yml +++ b/.github/workflows/pr-demo-deploy.yml @@ -55,9 +55,9 @@ jobs: echo The PR was raised by: ${{ github.event.pull_request.user.login }} eval `ssh-agent -s` ssh-add - <<< "$SSH_PRIVATE_KEY" - echo Creating dokku app ${{ github.head_ref }} + echo Creating dokku app ${{ env.SUBDOMAIN }}.pcpink.co.uk/ ssh dokku@$DOKKU_HOST -C "dokku apps:create ${{ env.SUBDOMAIN }}" | true - echo The url will be ${{ github.head_ref }}.pcpink.co.uk + echo The url will be ${{ env.SUBDOMAIN }}.pcpink.co.uk ssh dokku@$DOKKU_HOST -C "dokku git:initialize ${{ env.SUBDOMAIN }}" ssh dokku@$DOKKU_HOST -C "dokku git:set ${{ env.SUBDOMAIN }} deploy-branch ${{ github.head_ref }}" # set Stripe test keys as env vars dor dokku/docker @@ -82,7 +82,7 @@ jobs: SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} DOKKU_HOST: ${{ secrets.DOKKU_HOST }} run: | - echo Visit your pr here: http://${{ github.head_ref }}.pcpink.co.uk + echo Visit your pr here: http://${{ env.SUBDOMAIN }}.pcpink.co.uk - name: 'Comment PR with web address of application live preview' uses: actions/github-script@v3 if: github.event_name == 'pull_request' @@ -92,7 +92,7 @@ jobs: issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - body: "🙌 Live preview is here: http://${{ github.head_ref }}.pcpink.co.uk" + body: "🙌 Live preview is here: http://${{ env.SUBDOMAIN }}.pcpink.co.uk" }) - uses: actions/setup-node@v3 diff --git a/subscribie/blueprints/admin/__init__.py b/subscribie/blueprints/admin/__init__.py index 67390f47..de9f30a9 100644 --- a/subscribie/blueprints/admin/__init__.py +++ b/subscribie/blueprints/admin/__init__.py @@ -566,7 +566,7 @@ def edit(): plan_requirements.note_to_seller_required = False plan_requirements.note_to_buyer_message = escape( - str(getPlan(form.note_to_buyer_message, index, default="").data) + str(getPlan(form.note_to_buyer_message, index, default="").data).strip() ) try: @@ -615,7 +615,29 @@ def edit(): database.session.commit() # Save flash("Plan(s) updated.") return redirect(url_for("admin.edit")) - return render_template("admin/edit.html", plans=plans, form=form) + + # Form has validation errors, parse them + validation_errors = [] + plansWithErrors = [] + for key, value in form.errors.items(): + # Work out index of error for plan index + try: + plansWithErrors = [i for i, x in enumerate(value) if x] + for planIndex in plansWithErrors: + plans[planIndex].has_errors = True + except Exception as e: + log.error(f"Error parsing plan form errors. {e}") + if key == "note_to_buyer_message": + key = "Customer note" + for sublist in value: + for item in sublist: + # Ensure item is a string before checking if it contains the error msg + if isinstance(item, str): + validation_errors.append(f"{key}: {item}") + + return render_template( + "admin/edit.html", plans=plans, form=form, validation_errors=validation_errors + ) @admin.route("/add", methods=["GET", "POST"]) diff --git a/subscribie/blueprints/admin/templates/admin/edit.html b/subscribie/blueprints/admin/templates/admin/edit.html index 7b3050fb..2d1f7030 100644 --- a/subscribie/blueprints/admin/templates/admin/edit.html +++ b/subscribie/blueprints/admin/templates/admin/edit.html @@ -22,8 +22,8 @@
Oops, something is missing. Please take a look at: