diff --git a/akvo/rsr/migrations/0038_limit_org_partner_types.py b/akvo/rsr/migrations/0038_limit_org_partner_types.py index dac8bf15d3..7bc3cdd0b4 100644 --- a/akvo/rsr/migrations/0038_limit_org_partner_types.py +++ b/akvo/rsr/migrations/0038_limit_org_partner_types.py @@ -16,9 +16,16 @@ def forwards(self, orm): partner_types_for_org.add(partner_type) partner_types = orm['rsr.PartnerType'].objects.all() partner_types_dict = {partner_type.id: partner_type for partner_type in partner_types} + print "Partner types lookup: {partner_types_dict}".format(partner_types_dict=partner_types_dict) for organisation, allowed_partner_types in organisations.items(): + allowed_list = [] + for id in list(allowed_partner_types): + print "ID:", id + print "Lookup: {partner_types_dict}".format(partner_types_dict=partner_types_dict[id].id) + allowed_list += [partner_types_dict[id]] + print "Allowed list: {allowed_list}".format(allowed_list=allowed_list) organisation.partner_types.add( - *[partner_types_dict[id] for id in list(allowed_partner_types)] + *allowed_list ) print u"Organisation {org_name} partner types: {allowed_partner_types}".format( org_name=organisation.name, allowed_partner_types=', '.join(list(allowed_partner_types))