def preferences_view(request):
    """View and process updates to the preferences page."""
    user = request.user

    if request.method == "POST":
        logger.debug(dict(request.POST))
        phone_formset, email_formset, website_formset, errors = save_personal_info(request, user)
        if user.is_student:
            preferred_pic_form = save_preferred_pic(request, user)
            bus_route_form = save_bus_route(request, user)
        else:
            preferred_pic_form = None
            bus_route_form = None
        privacy_options_form = save_privacy_options(request, user)
        notification_options_form = save_notification_options(request, user)

        for error in errors:
            messages.error(request, error)

        try:
            save_gcm_options(request, user)
        except AttributeError:
            pass

        return redirect("preferences")

    else:
        phone_formset = PhoneFormset(instance=user, prefix='pf')
        email_formset = EmailFormset(instance=user, prefix='ef')
        website_formset = WebsiteFormset(instance=user, prefix='wf')

        if user.is_student:
            preferred_pic = get_preferred_pic(user)
            bus_route = get_bus_route(user)
            logger.debug(preferred_pic)
            preferred_pic_form = PreferredPictureForm(user, initial=preferred_pic)
            bus_route_form = BusRouteForm(user, initial=bus_route)
        else:
            bus_route_form = None
            preferred_pic = None
            preferred_pic_form = None

        privacy_options = get_privacy_options(user)
        logger.debug(privacy_options)
        privacy_options_form = PrivacyOptionsForm(user, initial=privacy_options)

        notification_options = get_notification_options(user)
        logger.debug(notification_options)
        notification_options_form = NotificationOptionsForm(user, initial=notification_options)

    context = {
        "phone_formset": phone_formset,
        "email_formset": email_formset,
        "website_formset": website_formset,
        "preferred_pic_form": preferred_pic_form,
        "privacy_options_form": privacy_options_form,
        "notification_options_form": notification_options_form,
        "bus_route_form": bus_route_form if settings.ENABLE_BUS_APP else None
    }
    return render(request, "preferences/preferences.html", context)
View and process updates to the preferences page.