Beispiel #1
0
def display_edit_user_account(cwruid):
    """
    This view allows the user and administrators
    to edit the account information of that user
    """
    import urllib, urlparse

    permissions = check_permissions(cwruid)
    if not permissions[0] and not permissions[1]:
        return permission_denied(cwruid)

    # get the user object for this page
    try:
        user = find_users(1,cwruid=('=', cwruid))[0]
    except IndexError:
        return render_template('404.html'), 404

    main_form = forms.MainUpdateUserForm(None)

    # initialize admin form if this user has
    # admin privileges
    admin_form = None
    if permissions[1]:
        admin_form = forms.AdminUpdateUserForm(None)

        # set the choices
        admin_form.family.choices = get_family_choices()
        admin_form.roles.choices = get_role_choices()

    # populate the main form
    main_form.fname.data = user.fname
    main_form.mname.data = user.mname
    main_form.lname.data = user.lname
    main_form.avatar.data = user.avatar

    # initialize the admin_form if needed
    if admin_form is not None:
        if user.family is not None:
            admin_form.family.data = user.family.name
        if user.big is not None:
            admin_form.big.data = user.big.cwruid

        query = UserRoleModel.all()
        query.filter('user ='******'members/edit_account.html',
                           user=user,
                           permissions=permissions,
                           main_form=main_form,
                           admin_form=admin_form)
def display_edit_user_account(cwruid):
    """
    This view allows the user and administrators
    to edit the account information of that user
    """
    import urllib, urlparse

    permissions = check_permissions(cwruid)
    if not permissions[0] and not permissions[1]:
        return permission_denied(cwruid)

    # get the user object for this page
    try:
        user = find_users(1, cwruid=('=', cwruid))[0]
    except IndexError:
        return render_template('404.html'), 404

    main_form = forms.MainUpdateUserForm(None)

    # initialize admin form if this user has
    # admin privileges
    admin_form = None
    if permissions[1]:
        admin_form = forms.AdminUpdateUserForm(None)

        # set the choices
        admin_form.family.choices = get_family_choices()
        admin_form.roles.choices = get_role_choices()

    # populate the main form
    main_form.fname.data = user.fname
    main_form.mname.data = user.mname
    main_form.lname.data = user.lname
    main_form.avatar.data = user.avatar

    # initialize the admin_form if needed
    if admin_form is not None:
        if user.family is not None:
            admin_form.family.data = user.family.name
        if user.big is not None:
            admin_form.big.data = user.big.cwruid

        query = UserRoleModel.all()
        query.filter('user ='******'members/edit_account.html',
                           user=user,
                           permissions=permissions,
                           main_form=main_form,
                           admin_form=admin_form)
Beispiel #3
0
def display_edit_user_contact(cwruid):
    """
    This view allows the user and administrators
    to edit the contact information of that user
    """
    from flask.ext import wtf
    permissions = check_permissions(cwruid)
    if not permissions[0] and not permissions[1]:
        return permission_denied(cwruid)

    # get the user object and all associated objects
    try:
        user = find_users(1, cwruid=('=', cwruid))[0]
    except IndexError:
        return render_template('404.html'), 404


    # create blank forms
    emails_form = forms.EmailUpdateForm(None)
    addresses_form = forms.AddressUpdateForm(None)
    phones_form = forms.PhoneUpdateForm(None)

    # populate the form

    # get the emails
    query = models.EmailModel.all()
    query.filter('user ='******'user ='******'user ='******'members/edit_contacts.html',
                           emails_form=emails_form,
                           phones_form=phones_form,
                           addresses_form=addresses_form,
                           current_user=current_user,
                           user=user)
def display_edit_user_contact(cwruid):
    """
    This view allows the user and administrators
    to edit the contact information of that user
    """
    from flask.ext import wtf
    permissions = check_permissions(cwruid)
    if not permissions[0] and not permissions[1]:
        return permission_denied(cwruid)

    # get the user object and all associated objects
    try:
        user = find_users(1, cwruid=('=', cwruid))[0]
    except IndexError:
        return render_template('404.html'), 404

    # create blank forms
    emails_form = forms.EmailUpdateForm(None)
    addresses_form = forms.AddressUpdateForm(None)
    phones_form = forms.PhoneUpdateForm(None)

    # populate the form

    # get the emails
    query = models.EmailModel.all()
    query.filter('user ='******'user ='******'user ='******'members/edit_contacts.html',
                           emails_form=emails_form,
                           phones_form=phones_form,
                           addresses_form=addresses_form,
                           current_user=current_user,
                           user=user)