def start_follow(request, username, success_url=None): user = get_object_or_404(User, username=username) follower = ActivityFollower(to_user=user, from_user=request.user) follower.save() create_activity_item("started_following", request.user, user) if not success_url: success_url = request.META.get('HTTP_REFERER', '/') if notification: notification.send([user], "new_follower", {"follower": request.user}) return HttpResponseRedirect(success_url)
def start_follow(request, username, success_url=None): user = get_object_or_404(User, username=username) follower = ActivityFollower(to_user=user, from_user=request.user) follower.save() create_activity_item("started_following", request.user, user) if not success_url: success_url = request.META.get('HTTP_REFERER','/') if notification: notification.send([user], "new_follower", {"follower": request.user}) return HttpResponseRedirect(success_url)
def handle_noargs(self, **options): normalize_dates() users = get_users(200000) # loop through the users and save them for user in users: was_stored = MigratedItem.objects.filter(type="user", old_id=user["user_id"]).count() if was_stored: print "USER: %s was stored already!"%user["user_id"] else: stored_user = store_user(user) # contacts contacts = get_contacts() for contact in contacts: try: from_user = User.objects.get(pk=get_new_id("user", contact["user_id"])) to_user = User.objects.get(pk=get_new_id("user", contact["contact"])) following = ActivityFollower(to_user=to_user, from_user=from_user) following.save() follower = ActivityFollower(to_user=from_user, from_user=to_user) follower.save() migrated_contact = MigratedItem(type="contact", old_id=contact["contact"], new_id=following.pk) migrated_contact.save() except: print "Could not make activity follower" for user in User.objects.all(): p = re.compile( '([^a-zA-Z_0-9])') oldname = user.username user.username = p.sub("_", oldname) user.save() print "Replaced username: %s with username: %s"%(oldname,user.username)