def authenticate(user_id, pass1, newpass1, newpass2,path_to_data=PATH_TO_DATA):
    CONSTANT_DATA = get_constant_data(path_to_data)
    roster_name = CONSTANT_DATA['roster_name']
    R = SheetObject(path_to_data + roster_name,'roster')
    students = R.get({'netid':user_id})
    n = len(students)
    authenticated = 0
    #print(students)
    if n==0:
        message = "invalid user_id and password. <br>"
        authenticated = 0
        #print('n=0')
    if n==1:
        old_entry = students[0]
        password = old_entry['password']
        if password == pass1:
            authenticated = 1
            if newpass1 == newpass2 and len(newpass1) >0:
                new_entry = copyd(old_entry)
                new_entry['password'] = newpass1
                R.remove([old_entry])
                R.append(new_entry)
                R.save()
                message = "new password has been set. <br>"
                
                
            else:
                message = "<i> %s upload report </i> <br>" % user_id
        else:
            #print('In the "else" case')
            authenticated = 0
            message = "invalid user_id and password. <br>"
                
    if n>2:
        authenticated = 0
        message = """
        invalid user_id and password. (multiple users! please copy-paste this entire upload report in an email to [email protected].) <br>
        """
        
    return message, authenticated
예제 #2
0
            snew['new_review1'] = 0

        if time_difference(tnow, trev2) > 2:
            snew['new_review2'] = 0

        cleaned.append(snew)

        f = open(PATH_TO_DATA + 'late_reviews.json', 'w')
        json.dump(late_reviews, f)
        f.close()

update(S, cleaned)
S.save()

#############
#Now we update the participation scores
#############

matched = S.get({'submission_locked': 1})
for m in matched:
    matched_dict[m['netid']].append(m['submission_number'])

for user in users:
    usernew = copyd(user)
    total = 14 + 2 * len(matched_dict[user['netid']])
    num = total - len(late_reviews[user['netid']])
    usernew['participation'] = num / total
    U.remove([user])
    U.append(usernew)
    U.save()