Exemplo n.º 1
0
def deleteUser(userName, lab):
    user = searchServer.searchForUser(userName, lab)
    try:
            user!= None
            user.delete()
    except:
            pass
Exemplo n.º 2
0
def changeProjectPermission(
        username, lab, project,
        index):  #index is the order of the access level for a user
    user = searchServer.searchForUser(username, lab)
    member = project.members.get(user.id)
    member.access_level = searchServer.accessArray[index]
    member.save()  #the documentation online
    return
Exemplo n.º 3
0
def addUserToDir(username, lab, dir, index):            #index is the required item of the access array in searchServer.py
    user = searchServer.searchForUser(username, lab)
    try:
        user!=None
        member = dir.members.create({'user_id':user.id,'access_level':searchServer.accessArray[index]})
        print(username, "is now a member for ", dir.name,".")
        return member       #returning member in case we need the member variable
    except:
        print("No user with the username exists.")
        return None
Exemplo n.º 4
0
def addTAFromCSV(lab, semGroup):
    # reading the ta.csv to add the users and classes in the semester we just made
    with open('ta.csv') as file:
        text = csv.reader(file)
        next(text)
        for line in text:
            # combine strings in 6, 7 and 8 indeces of line to make the class code
            classCode = line[6] + line[7] + "-" + line[8]
            # we look for a subgroup in the newly-made semester (this is the semGroup object)
            classGroup = searchServer.searchForGroup(classCode, lab, semGroup)
            try:
                classGroup == None
                classGroup = lab.groups.create({
                    'name': classCode,
                    'path': classCode,
                    'parent_id': semGroup.get_id()
                })
                print("We created a new group with name: ", classCode)
                # after the student-specific groups are made, lets check if the student we just looked at is a user
            except:
                pass
            studentUser = searchServer.searchForUser(line[4], lab)

            try:
                studentUser == None
                studentUser = lab.users.create({
                    'email': line[5],
                    'name': line[0] + " " + line[1],
                    'username': line[4],
                    'password': '******',
                    'skip_confirmation': 'True'
                })
                print("We created a new user with name: ", line[0], line[1],
                      "\n\t\t\t\tusername: "******"TA already a member:", studentUser.username, "of",
                      classGroup.name)
Exemplo n.º 5
0
def changeGroupPermission(username, lab, group, index):
    user = searchServer.searchForUser(username, lab)
    member = group.members.get(user.id)