From c0083fab73c907de4dca1705a9f1f7437d908b03 Mon Sep 17 00:00:00 2001 From: Gabriel von Heijne Date: Sat, 13 Apr 2013 12:56:54 +0200 Subject: [PATCH] [#178] Inline form for Organisation.internal_org_ids Add InternalOrganisationIDInline and include it in OrganisationAdmin.inlines Edit organisation/change_form.html to include the InternalOrganisationIDInline at the end of the form --- akvo/rsr/admin.py | 10 +++- .../admin/rsr/organisation/change_form.html | 49 +++++++++++-------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/akvo/rsr/admin.py b/akvo/rsr/admin.py index 62e79a0a45..767119a3ab 100644 --- a/akvo/rsr/admin.py +++ b/akvo/rsr/admin.py @@ -105,13 +105,21 @@ class OrganisationLocationInline(admin.StackedInline): formset = RSR_LocationFormFormSet +class InternalOrganisationIDInline(admin.TabularInline): + model = get_model('rsr', 'Organisation').internal_org_ids.through + extra = 1 + fk_name = 'recording_org' + verbose_name = 'internal organisation ID' + verbose_name_plural = 'internal organisation IDs' + class OrganisationAdmin(admin.ModelAdmin): fieldsets = ( (_(u'General information'), {'fields': ('name', 'long_name', 'organisation_type', 'new_organisation_type', 'logo', 'url', 'iati_org_id', 'language',)}), (_(u'Contact information'), {'fields': ('phone', 'mobile', 'fax', 'contact_person', 'contact_email', ), }), (_(u'About the organisation'), {'fields': ('description', )}), ) - inlines = (OrganisationLocationInline,) + inlines = (OrganisationLocationInline, InternalOrganisationIDInline,) + exclude = ('internal_org_ids',) list_display = ('name', 'long_name', 'website', 'language',) search_fields = ('name', 'long_name',) diff --git a/akvo/templates/admin/rsr/organisation/change_form.html b/akvo/templates/admin/rsr/organisation/change_form.html index 64a84f397a..2dbc0f2a63 100644 --- a/akvo/templates/admin/rsr/organisation/change_form.html +++ b/akvo/templates/admin/rsr/organisation/change_form.html @@ -4,10 +4,10 @@ {% block pretitle %} - {{ block.super }} -

{% trans 'Adding and Editing Organisations.' %}

-

{% trans 'Describe your organisation to the international Akvo community of users: tell us who you are, what you do, and what you as an organisation hope to accomplish. Your audience may include people unfamiliar with the sector or with your sphere of operation, so a bit of explanation in plain language (no acronyms) might be helpful. Details will help viewers get a sense of who you are: do you work on all continents? In both water and sanitation, perhaps even with other goals in mind? Are you part of a network or programme? ' %}

-
+ {{ block.super }} +

{% trans 'Adding and Editing Organisations.' %}

+

{% trans 'Describe your organisation to the international Akvo community of users: tell us who you are, what you do, and what you as an organisation hope to accomplish. Your audience may include people unfamiliar with the sector or with your sphere of operation, so a bit of explanation in plain language (no acronyms) might be helpful. Details will help viewers get a sense of who you are: do you work on all continents? In both water and sanitation, perhaps even with other goals in mind? Are you part of a network or programme? ' %}

+
{% endblock pretitle %} {% block content %} @@ -18,46 +18,55 @@

{% trans 'Adding and Editing Organisations.' %}

{% endif %} {% endif %} {% endblock object-tools %} -
+ {% csrf_token %} {% block form_top %}{% endblock %}
- {% if is_popup %}{% endif %} + {% if is_popup %}{% endif %} {% if save_on_top %}{% submit_row %}{% endif %} {% if errors %}

- {% blocktrans count errors|length as error_count %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %} + {% blocktrans count errors|length as error_count %}Please correct the error below.{% plural %}Please correct + the errors below.{% endblocktrans %}

{{ adminform.form.non_field_errors }} {% endif %} - + {% for fieldset in adminform %} {% include "admin/includes/fieldset.html" %} + {# hack to put the inlines at certain points in the form #} {% if forloop.counter == 2 %} - {% for inline_admin_formset in inline_admin_formsets %} - {% include inline_admin_formset.opts.template %} - {% endfor %} - {% block after_related_objects %}{% endblock %} + {% with inline_admin_formset=inline_admin_formsets.0 %} + {% include inline_admin_formset.opts.template %} + {% endwith %} + {% endif %} + {% if forloop.counter == 3 %} + {% with inline_admin_formset=inline_admin_formsets.1 %} + {% include inline_admin_formset.opts.template %} + {% endwith %} {% endif %} {% endfor %} - + {% block after_related_objects %}{% endblock %} + {% block after_field_sets %}{% endblock %} - + {% submit_row %} - + {% if adminform and add %} - + {% endif %} - + {# JavaScript for prepopulated fields #} {% prepopulated_fields_js %} - +