Пример #1
0
    def create_students(self,teams):
        """

        """

        #get password
        password = MembershipService.encryptPassword("student_pink",
                                                     "citydigits")
        #get name
        student1 = Student.objects.create(firstName="student_pink", team=teams[0])
        student1.save()
        #create auth user for student
        authUser1 = CityDigitsUser(role="STUDENT", username=student1.firstName, password=password,
                                  entityId=student1.id,is_active=True)
        authUser1.save()


        #get password
        password = MembershipService.encryptPassword("student_red",
                                                     "citydigits")
        #get name
        student2 = Student.objects.create(firstName="student_red", team=teams[1])
        student2.save()
        #create auth user for student
        authUser2 = CityDigitsUser(role="STUDENT", username=student2.firstName, password=password,
                                  entityId=student2.id, is_active=True)
        authUser2.save()


        #get password
        password = MembershipService.encryptPassword("student_blue",
                                                     "citydigits")
        #get name
        student3 = Student.objects.create(firstName="student_blue", team=teams[2])
        student3.save()
        #create auth user for student
        authUser3= CityDigitsUser(role="STUDENT", username=student3.firstName, password=password,
                                  entityId=student3.id, is_active=True)
        authUser3.save()


        #get password
        password = MembershipService.encryptPassword("student_green",
                                                     "citydigits")
        #get name
        student4 = Student.objects.create(firstName="student_green", team=teams[3])
        student4.save()
        #create auth user for student
        authUser4 = CityDigitsUser(role="STUDENT", username=student4.firstName, password=password,
                                  entityId=student4.id, is_active=True)
        authUser4.save()


        return (student1,student2,student3,student4)
Пример #2
0
    def create_auth_account(self,teacher):
        """
        """
        cityUser = CityDigitsUser(role="TEACHER", username=teacher.email,
                                          password=MembershipService.encryptPassword(teacher.email,
                                                                                     "citydigits"),
                                          entityId=teacher.id, is_active=True)
        cityUser.save()

        cityUserAdmin = CityDigitsUser(role="TEACHER", username="******",
                                          password=MembershipService.encryptPassword("*****@*****.**",
                                                                                     "citydigits"),
                                          entityId=teacher.id, is_active=True, is_admin=True, is_staff=True, is_superuser=True)
        cityUserAdmin.save()
Пример #3
0
    def create_auth_account(self, teacher):
        """
        """
        cityUser = CityDigitsUser(role="TEACHER",
                                  username=teacher.email,
                                  password=MembershipService.encryptPassword(
                                      teacher.email, "citydigits"),
                                  entityId=teacher.id,
                                  is_active=True)
        cityUser.save()

        cityUserAdmin = CityDigitsUser(
            role="TEACHER",
            username="******",
            password=MembershipService.encryptPassword("*****@*****.**",
                                                       "citydigits"),
            entityId=teacher.id,
            is_active=True,
            is_admin=True,
            is_staff=True,
            is_superuser=True)
        cityUserAdmin.save()
Пример #4
0
 def authenticate(self,role=None, username=None, password=None):
     try:
         # Try to find a user matching your username and role
         #default to role TEACHER if no role is passed
         if(not role):
             role = "TEACHER"
         user = User.objects.get(username=username,role=role)
         #check password
         if user.is_admin:
             password = MembershipService.encryptPassword(username,password)
         if password == user.password:
             return user
         else:
             return None
     except User.DoesNotExist:
         # No user was found, return None - triggers default login failed
         return None
Пример #5
0
    def create_students(self, teams):
        """

        """

        #get password
        password = MembershipService.encryptPassword("student_pink",
                                                     "citydigits")
        #get name
        student1 = Student.objects.create(firstName="student_pink",
                                          team=teams[0])
        student1.save()
        #create auth user for student
        authUser1 = CityDigitsUser(role="STUDENT",
                                   username=student1.firstName,
                                   password=password,
                                   entityId=student1.id,
                                   is_active=True)
        authUser1.save()

        #get password
        password = MembershipService.encryptPassword("student_red",
                                                     "citydigits")
        #get name
        student2 = Student.objects.create(firstName="student_red",
                                          team=teams[1])
        student2.save()
        #create auth user for student
        authUser2 = CityDigitsUser(role="STUDENT",
                                   username=student2.firstName,
                                   password=password,
                                   entityId=student2.id,
                                   is_active=True)
        authUser2.save()

        #get password
        password = MembershipService.encryptPassword("student_blue",
                                                     "citydigits")
        #get name
        student3 = Student.objects.create(firstName="student_blue",
                                          team=teams[2])
        student3.save()
        #create auth user for student
        authUser3 = CityDigitsUser(role="STUDENT",
                                   username=student3.firstName,
                                   password=password,
                                   entityId=student3.id,
                                   is_active=True)
        authUser3.save()

        #get password
        password = MembershipService.encryptPassword("student_green",
                                                     "citydigits")
        #get name
        student4 = Student.objects.create(firstName="student_green",
                                          team=teams[3])
        student4.save()
        #create auth user for student
        authUser4 = CityDigitsUser(role="STUDENT",
                                   username=student4.firstName,
                                   password=password,
                                   entityId=student4.id,
                                   is_active=True)
        authUser4.save()

        return (student1, student2, student3, student4)