Fix not working delete Sponsor functionality after recent commit. Add delete() method to Base class. Make soc.views.site.sponsor.delete() request handler use this method.
Patch by: Pawel Solyga
Review by: to-be-reviewed
--- a/app/soc/logic/model.py Sun Oct 12 08:43:41 2008 +0000
+++ b/app/soc/logic/model.py Sun Oct 12 08:46:05 2008 +0000
@@ -344,3 +344,12 @@
key_name = self.getKeyNameForFields(**kwargs)
return self.updateOrCreateFromKeyName(properties, key_name)
+
+ def delete(self, entity):
+ """Delete existing entity from datastore.
+
+ Args:
+ entity: an existing entity in datastore
+ """
+ entity.delete()
+
--- a/app/soc/views/site/sponsor/profile.py Sun Oct 12 08:43:41 2008 +0000
+++ b/app/soc/views/site/sponsor/profile.py Sun Oct 12 08:46:05 2008 +0000
@@ -222,13 +222,15 @@
# try to fetch Sponsor entity corresponding to link_name if one exists
try:
- existing_sponsor = soc.logic.sponsor.getSponsorIfLinkName(link_name)
+ existing_sponsor = soc.logic.sponsor_logic.getIfFields(link_name=link_name)
except out_of_band.ErrorResponse, error:
# show custom 404 page when link name doesn't exist in Datastore
error.message = error.message + DEF_CREATE_NEW_SPONSOR_MSG
return simple.errorResponse(request, error, template, context)
if existing_sponsor:
- sponsor.deleteSponsor(existing_sponsor)
+ # TODO(pawel.solyga): Create specific delete method for Sponsor model
+ # Check if Sponsor can be deleted (has no Hosts and Programs)
+ soc.logic.sponsor_logic.delete(existing_sponsor)
return http.HttpResponseRedirect('/site/sponsor/list')
\ No newline at end of file