def purge_organizations(): for organization in Organization.objects(deleted__ne=None): log.info('Purging organization "{0}"'.format(organization)) # Remove followers FollowOrg.objects(following=organization).delete() # Remove activity Activity.objects(related_to=organization).delete() Activity.objects(organization=organization).delete() # Remove metrics Metrics.objects(object_id=organization.id).delete() organization.delete()
def purge_organizations(self): for organization in Organization.objects(deleted__ne=None): log.info('Purging organization "{0}"'.format(organization)) # Remove followers FollowOrg.objects(following=organization).delete() # Remove activity Activity.objects(related_to=organization).delete() Activity.objects(organization=organization).delete() # Remove metrics Metrics.objects(object_id=organization.id).delete() # Remove organization.delete()
def followers_org_count(self): """Return the number of followers of user's organizations.""" from udata.models import FollowOrg # Circular imports. return sum(FollowOrg.objects(following=org).count() for org in self.organizations)
def followers_org_count(self): """Return the number of followers of user's organizations.""" from udata.models import FollowOrg # Circular imports. return sum( FollowOrg.objects(following=org).count() for org in self.organizations)