-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List partner as support partner #203
Comments
OK, understood as a requirement but this has a few implications:
|
As we talked about briefly yesterday, it should be like this: |
I see two solutions, one simple and klunky, one complex and cool. The simple and "Djangoish" way of solving this is to write a validator that checks if an organisation can be a partner of the selected type when the form is submitted. If not, the form is returned to the user with an error message that lists the allowed choices of partner type. To make a cool solution for this is non-trivial. The reason is that the selection of partner types is dynamically dependent on the choice of organisation. This is not supported by the Django admin. This is not the first time someone has a problem like this however, so there's code to be used as the basis for this like https://bitbucket.org/mlavin/django-selectable which seems to be actively maintained. It uses jqueryui to do its magic. We have other reasons for working on this problem too. The organisation list is already waaaaaay too long and really needs an auto-complete feature. Another area where this would be very cool is in the project listing where you'd want to change the possible choices for country and continent when an organisation is selected in the filter (and the other way around too, limit the org list to the relevant ones for a country or continent). |
hi @zzgvh. could we shortly skype about this? Would be easier to make clear what kind of sulution the partner team is looking for. I also agree with you the organisation list is too long. |
The PartnerType is a helper model containing one object for each partner type organisations can assume in a Partnership. Add the model definition to rsr.models. Add Organisation.partner_types many-to-many field that enumerates the types of partner a certain organisation can assume. Add schema migration 0037 for PartnerType. Add data migration 0038 that populates Organisation.partner_types based on the current partnerships for each organisation.
Add signal to rsr.management that adds the objects for each partner type to PartnerType if they are not already present
Set Organisation.partner_types to be read only unless you have change permission on Organisation. Change the help text for Organisation.partner_types field in the admin depending on the read only status.
RSR_PartnershipInlineForm.clean_partner_type() RSR_PartnershipInlineForm.clean_partner_type() checks if the organisation is allowed to assume the given partner type based on the objects in Organisation.partner_types for the org in question. Small refactorings in RSR_PartnershipInlineFormFormSet.
The list is only visible if you have change permission on Organisation, currently meaning Akvo staff groups only
To try debug the migration that fails when deployed to UAT
The migration depends on the PartnerType objects being present, but they were created by a signal that wasn't run until after the migrations. Fix by adding the PartnerType objects as part of the data migration.
since ths is now done in migration 0038 instead
Deployed to UAT |
@peeb can you please code check this? |
If I click on any organisation in http://uat.akvo.org admin, we can select if a partner is support/sponsor/funding/field partner. This is what we want. Great! |
Can you also check the negative fo this: If a partner is not already tagged as a Field/Fudning/Sponsor/Support that they should not be selectable as this? |
Unfortunately they are selectable as all kinds of partners, but the validation only lets you save if you've chosen valid ones. Otherwise you'll get an error message when saving telling you what the problem is. As mentioned above this can't be solved in a nicer way without some AJAX magic that populates the Partner type field when you select an organisation. Doable but outside the scope of the regular Django admin's capabilities. |
Works for me - all functionality is as expected. |
The text was updated successfully, but these errors were encountered: