def admin_get_subscriptions(self, user_query=''): user_query = user_query.strip() for obj, sub_id, subscription in utils.walk_subscriptions( self.getSite()): user = subscription.to_string(obj) if not user_query or re.match('.*%s.*' % user_query, user, re.IGNORECASE): yield { 'user': user, 'location': path_in_site(obj), 'sub_id': sub_id, 'lang': subscription.lang, 'notif_type': subscription.notif_type, }
def admin_get_subscriptions(self, user_query=''): user_query = user_query.strip() for obj, sub_id, subscription in utils.walk_subscriptions( self.getSite()): user = subscription.to_string(obj) if not user_query or re.match('.*%s.*' % user_query, user, re.IGNORECASE): yield { 'user': user, 'location': relative_object_path(obj, self.getSite()), 'sub_id': sub_id, 'lang': subscription.lang, 'notif_type': subscription.notif_type, 'content_types': getattr(subscription, 'content_types', []), }
def user_subscriptions(self, user, cutoff_level=None): """ Returns all user subscriptions in the portal. Use with caution as this iterates almost all the objects in site. You can use `cutoff_level` to limit the depth. """ out = [] user_id = user.getId() for obj, n, subscription in utils.walk_subscriptions(self.getSite(), cutoff_level): if not isinstance(subscription, AccountSubscription): continue if subscription.user_id != user_id: continue out.append({ 'object': obj, 'notif_type': subscription.notif_type, 'lang': subscription.lang }) return out
def user_subscriptions(self, user, cutoff_level=None): """ Returns all user subscriptions in the portal. Use with caution as this iterates almost all the objects in site. You can use `cutoff_level` to limit the depth. """ out = [] user_id = user.getId() for obj, n, subscription in utils.walk_subscriptions(self.getSite(), cutoff_level): if not isinstance(subscription, AccountSubscription): continue if subscription.user_id != user_id: continue out.append({ 'object': obj, 'notif_type': subscription.notif_type, 'content_types': getattr(subscription, 'content_types', []), 'lang': subscription.lang }) return out