Exemplo n.º 1
0
def courseman_users_post(req):
    ''' The "ids" list, set previously on the form, is used to ensure that only viewed signup instances are added. '''
    form = req.POST
    
    # get filtered signups and update
    form = req.POST
    ids = ast.literal_eval(form.get('ids')) # conv. str repr. of lst. to lst.
    signups = Signup.objects.filter(id__in=ids)
    utils.update_signups(signups, form)
    
    cs = form['course_selector']
    if re.match('\-\-\sselect', cs):
        req.session['message'] = 'Please select a course.'
        return redirect('/coursemanage/users')
    
    courses = [cs] + COURSES_MANDATORY
    utils.assign_courses(signups, courses)
    
    override_ldap = False
    if form.get('override_ldap'):
        override_ldap = True
    
    # perform the appropriate add-user actions for each signup
    req.session['message'] = 'All signups were added succesfully.'
    for signup in signups:
        utils.adduser(signup, ldap_password=req.session['ldap_password'], accept_ldap_exists=override_ldap)
        if signup.fail_str != '':
            req.session['message'] = 'Some signups reported an error. Use the override checkbox if you think the user already exists in mcweb.'
    
    return redirect('/coursemanage/users')
Exemplo n.º 2
0
def userlist_au_post(req):
    ''' handles list form submission '''
    
    # get filtered signups and update
    form = req.POST
    ids = ast.literal_eval(form.get('ids')) # conv. str repr. of lst. to lst.
    objs = Signup.objects.filter(id__in=ids)
    utils.update_signups(objs, form)
    
    # perform the appropriate add-user actions for each signup
    for signup in objs:
        utils.adduser(signup, ldap_password=req.session['ldap_password'])
    
    # return to the list 
    if len(utils.get_signups()) > 0:
        return redirect('/userlist_au/new')
    elif len(utils.get_signups_limbo()) > 0:
        return redirect('/userlist_au/limbo')
    else:
        return redirect('/userlist_au/added')