Skip to content

Commit

Permalink
[#203] Add object creation for PartnerType
Browse files Browse the repository at this point in the history
Add signal to rsr.management that adds the objects for each partner
type to PartnerType if they are not already present
  • Loading branch information
zzgvh committed Jun 13, 2013
1 parent 8d0f7c8 commit f743d79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions akvo/rsr/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,18 @@ def create_limited_change_permissions(sender, **kwargs):
else:
print 'RSR limited change %s Permission already exists in the database' % model_name

def create_partner_types(sender, **kwargs):
print "Adding PartnerType objects"
print
for id, label in rsr.Partnership.PARTNER_TYPES:
partner_type, created = rsr.PartnerType.objects.get_or_create(id=id, label=label)
if created:
print 'Created PartnerType {partner_type}'.format(partner_type=partner_type)
else:
print 'Found existing PartnerType {partner_type}'.format(partner_type=partner_type)

post_syncdb.connect(create_limited_change_permissions, sender=rsr)
post_syncdb.connect(create_partner_types, sender=rsr)



Expand Down

0 comments on commit f743d79

Please sign in to comment.