def transfer_students_action(request):
    """Do the actual process of transferring students."""
    if "source_act" in request.GET:
        source_act = EighthScheduledActivity.objects.get(id=request.GET.get("source_act"))
    elif "source_act" in request.POST:
        source_act = EighthScheduledActivity.objects.get(id=request.POST.get("source_act"))
    else:
        raise Http404

    dest_act = None
    dest_unsignup = False

    if "dest_act" in request.GET:
        dest_act = EighthScheduledActivity.objects.get(id=request.GET.get("dest_act"))
    elif "dest_act" in request.POST:
        dest_act = EighthScheduledActivity.objects.get(id=request.POST.get("dest_act"))
    elif "dest_unsignup" in request.POST or "dest_unsignup" in request.GET:
        dest_unsignup = True
    else:
        raise Http404

    num = source_act.members.count()

    context = {"admin_page_title": "Transfer Students", "source_act": source_act, "dest_act": dest_act, "dest_unsignup": dest_unsignup, "num": num}

    if request.method == "POST":
        if dest_unsignup and not dest_act:
            source_act.eighthsignup_set.all().delete()
            invalidate_obj(source_act)
            messages.success(request, "Successfully removed signups for {} students.".format(num))
        else:
            source_act.eighthsignup_set.update(scheduled_activity=dest_act)

            invalidate_obj(source_act)
            invalidate_obj(dest_act)
            messages.success(request, "Successfully transfered {} students.".format(num))
        return redirect("eighth_admin_dashboard")
    else:
        return render(request, "eighth/admin/transfer_students.html", context)
Do the actual process of transferring students.