Make the add button for linked objects configurable
authorMagnus Hagander <magnus@hagander.net>
Wed, 12 Sep 2018 11:56:28 +0000 (13:56 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 12 Sep 2018 11:56:28 +0000 (13:56 +0200)
Default is off, but turn it on for sponsorship levels, the only
currently existing one.

postgresqleu/confsponsor/backendforms.py
template/confreg/admin_backend_form_content.html

index 5924debb9f67e527992793486cadc93920176628..6a88d32c3e5a568dd9089f846269e71e86c6444c 100644 (file)
@@ -79,6 +79,7 @@ class BackendSponsorshipLevelBenefitForm(BackendForm):
 class BackendSponsorshipLevelBenefitManager(object):
        title = 'Benefits'
        singular = 'benefit'
+       can_add = True
 
        def get_list(self, instance):
                return [(b.id, b.benefitname, b.benefitdescription) for b in instance.sponsorshipbenefit_set.all()]
index aaf734dad10c2b3a7d4363fe6d7849b2aa38e8a5..690f2c489a61f9013e6ffe89bbfa618c7c5ddbca 100644 (file)
@@ -33,7 +33,7 @@
     </tr>
 {%endfor%}
     </table>
-{%if form.instance.id%}
+{%if form.instance.id and handler.can_add%}
     <a href="{{url}}/new/" class="btn btn-default">Add {{handler.singular}}</a>
 {%endif%}
   </div>