Ejemplo n.º 1
0
def supply(request, page_name):
    """Supply view_objects for My_Info and process the POST command."""
    _ = page_name

    session = request.session
    form = None
    if "form_dict" in session:
        form_dict = session.pop("form_dict")
        form = ProfileForm(
            initial={
                "display_name": form_dict["display_name"],
                "contact_email": form_dict["contact_email"],
                "contact_text": form_dict["contact_text"],
                "contact_carrier": form_dict["contact_carrier"],
                "theme": form_dict["theme"],
            })
        form.message = session.pop("message")
        form._errors = session.pop("form_errors")

    if not form:
        user = request.user
        profile = user.profile
        user_theme = profile.theme
        if not user_theme:
            user_theme = challenge_mgr.get_challenge().theme
        form = ProfileForm(
            initial={
                "display_name": profile.name,
                "contact_email": user.email,
                "contact_text": profile.contact_text,
                "contact_carrier": profile.contact_carrier,
                "theme": user_theme,
            })

        if "changed_avatar" in request.GET:
            form.message = "Your avatar has been updated."

    return {
        "form": form,
    }
Ejemplo n.º 2
0
def supply(request, page_name):
    """Supply view_objects for My_Info and process the POST command."""
    _ = page_name

    session = request.session
    form = None
    if "form_dict" in session:
        form_dict = session.pop("form_dict")
        form = ProfileForm(initial={
            "display_name": form_dict["display_name"],
            "contact_email": form_dict["contact_email"],
            "contact_text": form_dict["contact_text"],
            "contact_carrier": form_dict["contact_carrier"],
            "theme": form_dict["theme"],
        })
        form.message = session.pop("message")
        form._errors = session.pop("form_errors")

    if not form:
        user = request.user
        profile = user.profile
        user_theme = profile.theme
        if not user_theme:
            user_theme = challenge_mgr.get_challenge().theme
        form = ProfileForm(initial={
            "display_name": profile.name,
            "contact_email": user.email,
            "contact_text": profile.contact_text,
            "contact_carrier": profile.contact_carrier,
            "theme": user_theme,
            })

        if "changed_avatar" in request.GET:
            form.message = "Your avatar has been updated."

    return {
        "form": form,
    }