Remove updateOrCreateFromFields and it's uses
All uses of updateOrCreateFromFields were replaced with
updateOrCreateFromKeyname. This way the logic API is not as cluttered
with a bunch of helper methods.
Patch by: Sverre Rabbelier
--- a/app/soc/logic/helper/notifications.py Thu Feb 26 16:48:02 2009 +0000
+++ b/app/soc/logic/helper/notifications.py Thu Feb 26 16:49:06 2009 +0000
@@ -149,10 +149,10 @@
'scope_path' : to_user.link_id
}
- key_fields = model_logic.notification.logic.getKeyFieldsFromFields(fields)
+ key_name = model_logic.notification.logic.getKeyNameFromFields(fields)
# create and put a new notification in the datastore
- model_logic.notification.logic.updateOrCreateFromFields(fields, key_fields)
+ model_logic.notification.logic.updateOrCreateFromKeyName(fields, key_name)
def sendNewNotificationMessage(notification_entity):
--- a/app/soc/logic/models/base.py Thu Feb 26 16:48:02 2009 +0000
+++ b/app/soc/logic/models/base.py Thu Feb 26 16:49:06 2009 +0000
@@ -402,15 +402,6 @@
return entity
- def updateOrCreateFromFields(self, properties, key_fields):
- """Like updateOrCreateFromKeyName, but resolves fields to a key_name first.
- """
-
- # attempt to retrieve the existing entity
- key_name = self.getKeyNameFromFields(key_fields)
-
- return self.updateOrCreateFromKeyName(properties, key_name)
-
def isDeletable(self, entity):
"""Returns whether the specified entity can be deleted.
--- a/app/soc/logic/models/club.py Thu Feb 26 16:48:02 2009 +0000
+++ b/app/soc/logic/models/club.py Thu Feb 26 16:49:06 2009 +0000
@@ -69,8 +69,8 @@
continue
properties['link_id'] = admin.link_id
- key_fields = request_logic.logic.getKeyFieldsFromFields(properties)
- request_logic.logic.updateOrCreateFromFields(properties, key_fields)
+ key_name = request_logic.logic.getKeyNameFromFields(properties)
+ request_logic.logic.updateOrCreateFromKeyName(properties, key_name)
# set the application to completed
fields = {'status' : 'completed'}
--- a/app/soc/logic/models/organization.py Thu Feb 26 16:48:02 2009 +0000
+++ b/app/soc/logic/models/organization.py Thu Feb 26 16:49:06 2009 +0000
@@ -78,8 +78,8 @@
continue
properties['link_id'] = admin.link_id
- key_fields = request_logic.logic.getKeyFieldsFromFields(properties)
- request_logic.logic.updateOrCreateFromFields(properties, key_fields)
+ key_name = request_logic.logic.getKeyNameFromFields(properties)
+ request_logic.logic.updateOrCreateFromKeyName(properties, key_name)
# set the application to completed
fields = {'status': 'completed'}
--- a/app/soc/views/models/program.py Thu Feb 26 16:48:02 2009 +0000
+++ b/app/soc/views/models/program.py Thu Feb 26 16:49:06 2009 +0000
@@ -153,11 +153,12 @@
timeline_logic = program_logic.logic.TIMELINE_LOGIC[workflow]
- key_fields = timeline_logic.getKeyFieldsFromFields(fields)
- properties = key_fields.copy()
+ properties = timeline_logic.getKeyFieldsFromFields(fields)
+ key_name = timeline_logic.getKeyNameFromFields(properties)
+
properties['scope'] = fields['scope']
- timeline = timeline_logic.updateOrCreateFromFields(properties, properties)
+ timeline = timeline_logic.updateOrCreateFromKeyName(properties, key_name)
return timeline
@decorators.merge_params