def favorite_activity(action, profile, activity): node = Profile.objects(pk=profile).first() activity = Activity.objects(pk=activity).first() if (action == 'add'): RelationShips.favorite(node, activity) else: RelationShips.un_favorite(node, activity) return node
def apply(self, query, value): activity = Activity.objects(name__icontains=value).first() return query.filter(activities__in=[activity.id])