Exemplo n.º 1
0
def student_canvas_quota():
    student_id = request.args(0)
    if (student_id == None):
        if (session.back):
            redirect(session.back)
        else:
            redirect(URL('faculty', 'manage_student'))

    current_user = Student.GetUsername(student_id)

    row = db(db.student_info.user_id == student_id).select().first()
    form = SQLFORM(db.student_info,
                   row,
                   showid=False,
                   fields=["student_canvas_quota"]).process()

    if (form.accepted):
        # Saved
        quota = request.vars.get('student_canvas_quota', '1')
        Canvas.SetQuota(current_user, quota)
        msg = "Settings Saved!"
        if (len(Canvas._errors) > 0):
            msg += Canvas.GetErrorString()
        response.flash = msg

    return dict(form=form, current_user=current_user)
Exemplo n.º 2
0
def student_toggle_enabled():
    student_id = request.args(0)
    if student_id == None:
        if session.back:
            redirect(session.back)
        else:
            redirect(URL('faculty', 'manage_student'))

    current_user = Student.GetUsername(student_id)

    status_action = "Change Status"

    student = db(db.student_info.user_id == student_id).select().first()
    if (student == None):
        message = 'Invalid Student!'
    else:
        if (student.account_enabled == True):
            # Disable
            r = Student.DisableAccount(student_id)
            if r != "":
                r = " - ERROR trying to disable account - most likely couldn't find LDAP object. Make sure AD Student Cn is configured correctly in  Admin -> Configure App -> Student Settings  (missing cn=<program>)??" + r
            message = "Account disabled. " + r
            status_action = 'Disable Account'
        else:
            # Enable
            r = Student.EnableAccount(student_id)
            if r != "":
                r = " - ERROR trying to enable account - most likely couldn't find LDAP object. Make sure AD Student Cn is configured correctly in  Admin -> Configure App -> Student Settings  (missing cn=<program>)??" + r
            message = "Account enabled. " + r
            status_action = 'Enable Account'
    return dict(message=message,
                current_user=current_user,
                status_action=status_action)
Exemplo n.º 3
0
def student_toggle_upload_media():
    student_id = request.args(0)
    account_id = request.args(1)
    if (student_id == None or account_id == None):
        if (session.back):
            redirect(session.back)
        else:
            redirect(URL('faculty', 'manage_student'))

    current_user = Student.GetUsername(student_id)

    status_action = "Change Status"
    auth = current.auth  # Grab the current auth object

    # Add to the group
    if (auth.has_membership(role='Media Upload', user_id=account_id) == True):
        status_action = "Removing Media Upload Rights"
        auth.del_membership(auth.id_group(role='Media Upload'),
                            user_id=account_id)
    else:
        status_action = "Adding Media Upload Rights"
        auth.add_membership('Media Upload', user_id=account_id)
    message = status_action
    return dict(message=message,
                current_user=current_user,
                status_action=status_action)
Exemplo n.º 4
0
def student_enrollment():
    student_id = request.args(0)
    if (student_id == None):
        if (session.back):
            redirect(session.back)
        else:
            redirect(URL('faculty', 'manage_student'))

    current_user = Student.GetUsername(student_id)

    user = db(db.student_info.user_id == student_id).select().first()
    query = None
    if (user != None):
        query = (db.student_enrollment.parent_id == user['id'])

    fields = (
        db.student_enrollment.course_code,
        db.student_enrollment.enrollment_status,
        db.student_enrollment.enrolled_on,
    )

    #links = [dict(header=T('Enrollment'),body=lambda row: A(Student.GetEnrolledClassesString(row.user_id), _href=URL('faculty', 'student_enrollment', args=[row.user_id], user_signature=True)) ),
    #         ]

    form = SQLFORM.grid(query,
                        fields=fields,
                        orderby=db.student_enrollment.course_code,
                        searchable=False,
                        create=False,
                        deletable=False,
                        paginate=50,
                        csv=False,
                        details=False,
                        editable=False,
                        links=None,
                        links_placement='right',
                        links_in_grid=True)

    return dict(form=form, current_user=current_user)
Exemplo n.º 5
0
def student_change_password():
    student_id = request.args(0)
    if (student_id == None):
        if (session.back):
            redirect(session.back)
        else:
            redirect(URL('faculty', 'manage_student'))

    current_user = Student.GetUsername(student_id)

    default_pw_form = SQLFORM.factory(
        submit_button="Set Default Password",
        _name="default_pw_form").process(formname="default_pw_form")

    custom_pw_form = SQLFORM.factory(Field(
        'new_password',
        'password',
        requires=[
            IS_NOT_EMPTY(),
            IS_STRONG(
                min=6,
                special=1,
                upper=1,
                error_message=
                'minimum 6 characters, and at least 1 uppercase character, 1 lower case character, and 1 special character'
            )
        ]),
                                     Field('confirm_new_password',
                                           'password',
                                           requires=IS_EXPR(
                                               'value==%s' % repr(
                                                   request.vars.get(
                                                       'new_password', None)),
                                               error_message=
                                               "Password fields don't match")),
                                     submit_button="Set New Password",
                                     _name="custom_pw_form").process(
                                         formname="custom_pw_form")

    if (default_pw_form.accepted):
        new_pw = AppSettings.GetValue('student_password_pattern',
                                      'SID<user_id>!')
        # Replace the possible values in this string with real info
        new_pw = Student.process_config_params(student_id,
                                               new_pw,
                                               is_username=False,
                                               row=None)
        #new_pw = new_pw.replace('<user_id>', student_id)
        msg = Student.SetPassword(student_id, new_pw)
        if msg == "":
            response.flash = "Default Password Set!"
        else:
            response.flash = msg

    if (custom_pw_form.accepted):
        pw = request.vars.get('new_password', '')
        if (pw != ""):
            ret = Student.SetPassword(student_id, pw)
            if (ret != ""):
                response.flash = ret
            else:
                response.flash = "Password Changed."
    elif (custom_pw_form.errors):
        response.flash = "Unable to set new password"

    return dict(default_pw_form=default_pw_form,
                custom_pw_form=custom_pw_form,
                current_user=current_user)