Fix typo in getSponsorFromLinkName (key_name variable name instead of sponsor_key_name). Add deleteSponsor function for deleting Sponsor entities from datastore.
--- a/app/soc/logic/sponsor.py Sun Oct 05 13:27:49 2008 +0000
+++ b/app/soc/logic/sponsor.py Wed Oct 08 21:22:50 2008 +0000
@@ -50,7 +50,7 @@
# lookup by Sponsor key name
sponsor_key_name = getSponsorKeyNameForLinkName(link_name)
- if key_name:
+ if sponsor_key_name:
sponsor = soc.models.sponsor.Sponsor.get_by_key_name(sponsor_key_name)
else:
sponsor = None
@@ -136,4 +136,15 @@
# there is no way to be sure if get_or_insert() returned a new Sponsor or
# got an existing one due to a race, so update with sponsor_properties anyway,
# in a transaction
- return soc.logic.model.updateModelProperties(sponsor, **sponsor_properties)
\ No newline at end of file
+ return soc.logic.model.updateModelProperties(sponsor, **sponsor_properties)
+
+
+def deleteSponsor(sponsor):
+ """Delete Sponsor entity.
+
+ Args:
+ sponsor: existing Sponsor entity
+ """
+ # TODO(pawel.solyga): check if Sponsor can be deleted
+ # If Sponsor has Hosts or Programs it cannot be deleted
+ sponsor.delete()
\ No newline at end of file