Added getOrCreateTaskSubscriptionForTask to TaskSubscription Logic.
--- a/app/soc/modules/ghop/logic/models/task_subscription.py Fri Sep 18 18:40:17 2009 +0200
+++ b/app/soc/modules/ghop/logic/models/task_subscription.py Fri Sep 18 18:53:14 2009 +0200
@@ -43,5 +43,25 @@
super(Logic, self).__init__(model, base_model=base_model,
id_based=id_based)
+ def getOrCreateTaskSubscriptionForTask(self, task_entity):
+ """Gets or creates a TaskSubscription entity for the given GHOPTask.
+
+ Args:
+ task_entity: GHOPTask entity
+
+ Returns:
+ Existing TaskSubscription entity iff any exists, otherwise a new
+ TaskSubscription entity.
+ """
+
+ fields = {'task': task_entity}
+
+ task_subscription = self.getForFields(fields, unique=True)
+
+ if not task_subscription:
+ task_subscription = self.updateOrCreateFromFields(fields)
+
+ return task_subscription
+
logic = Logic()