Pre-select plan when adding update from toolbar

This commit is contained in:
Stefan Wehrmeyer 2022-03-17 09:18:45 +01:00
parent e6fec572a8
commit 14d7f2b249
2 changed files with 12 additions and 0 deletions

View file

@ -33,6 +33,7 @@ class GovPlanToolbar(CMSToolbar):
"admin:froide_govplan_governmentplanupdate_add", "admin:froide_govplan_governmentplanupdate_add",
current_app="govplanadmin", current_app="govplanadmin",
) )
url = "{}?plan={}".format(url, govplan.id)
menu.add_modal_item(_("Add update"), url=url) menu.add_modal_item(_("Add update"), url=url)

View file

@ -0,0 +1,11 @@
{% extends "admin/change_form.html" %}
{% block after_field_sets %}
{% if not original.pk %}
<script>
(function(){
document.getElementById('id_plan').value = new URLSearchParams(window.location.search).get("plan") || ""
}())
</script>
{% endif %}
{% endblock %}