def organisation_conditions_new(id=None):
    organisations = Organisation.query.order_by(Organisation.organisation_code).all()
    tests = Test.query.order_by(Test.id).all()

    template_args = dict(
        pc={},
        organisations=organisations,
        tests=tests,
        admin=usermanagement.check_perms("admin"),
        loggedinuser=current_user,
    )

    if request.method == "POST":
        pc = OrganisationCondition()
        dqpublishercondition.configure_organisation_condition(pc)
        flash("Created new condition", "success")
        return redirect(url_for("organisation_conditions_editor", id=pc.id))
    else:
        return render_template("organisation_condition_editor.html", **template_args)
def update_organisation_condition(pc_id):
    pc = OrganisationCondition.query.filter_by(id=pc_id).first_or_404()
    dqpublishercondition.configure_organisation_condition(pc)