# HG changeset patch # User Lennard de Rijk # Date 1253292957 -7200 # Node ID 3c024d61290cc7a0717109e2fe07758500166733 # Parent c063bb466376a647f51a176e3a674c2a10c10c36 Use getOrCreateTaskSubscriptionForTask in the TaskSubscription View. diff -r c063bb466376 -r 3c024d61290c app/soc/modules/ghop/views/models/task_subscription.py --- a/app/soc/modules/ghop/views/models/task_subscription.py Fri Sep 18 18:53:14 2009 +0200 +++ b/app/soc/modules/ghop/views/models/task_subscription.py Fri Sep 18 18:55:57 2009 +0200 @@ -95,23 +95,17 @@ user_account = user_logic.logic.getForCurrentAccount() - fields = { - 'task': task_entity, - } - - entity = ghop_task_subscription_logic.logic.getForFields( - fields, unique=True) + entity = params['logic'].getOrCreateTaskSubscriptionForTask(task_entity) subscribers = db.get(entity.subscribers) # TODO: this should not loop over all subscribers but use GET argument remove = False - if entity: - for subscriber in subscribers: - if subscriber.key() == user_account.key(): - remove = True - break + for subscriber in subscribers: + if subscriber.key() == user_account.key(): + remove = True + break if remove: subscribers.remove(subscriber)