Пример #1
0
    def handle(self, *args, **options):
        """
        The logic of the command.
        """
        username = '******'
        email = '*****@*****.**'
        try:
            admin = User.objects.create_user(username, email, 'foo')
            admin.is_staff = True
            admin.save()
        except IntegrityError:
            # If the script did not complete the last time it was run,
            # the admin user will already exist.
            admin = User.objects.get(username=username, email=email)

        for user in get_users_with_instructor_role():
            add_user_with_status_granted(admin, user)

        # Some users will be both staff and instructors. Those folks have been
        # added with status granted above, and add_user_with_status_unrequested
        # will not try to add them again if they already exist in the course creator database.
        for user in get_users_with_staff_role():
            add_user_with_status_unrequested(user)

        # There could be users who are not in either staff or instructor (they've
        # never actually done anything in Studio). I plan to add those as unrequested
        # when they first go to their dashboard.

        admin.delete()
Пример #2
0
    def test_get_staff(self):
        # Do this test with staff in 2 different classes.
        create_all_course_groups(self.creator, self.location)
        add_user_to_course_group(self.creator, self.staff, self.location, STAFF_ROLE_NAME)

        location2 = 'i4x', 'mitX', '103', 'course', 'test2'
        staff2 = User.objects.create_user('teststaff2', '*****@*****.**', 'foo')
        create_all_course_groups(self.creator, location2)
        add_user_to_course_group(self.creator, staff2, location2, STAFF_ROLE_NAME)

        self.assertSetEqual({self.staff, staff2, self.creator}, get_users_with_staff_role())
Пример #3
0
    def test_get_staff(self):
        # Do this test with staff in 2 different classes.
        create_all_course_groups(self.creator, self.location)
        add_user_to_course_group(self.creator, self.staff, self.location,
                                 STAFF_ROLE_NAME)

        location2 = Location('i4x', 'mitX', '103', 'course', 'test2')
        staff2 = User.objects.create_user('teststaff2',
                                          '*****@*****.**', 'foo')
        create_all_course_groups(self.creator, location2)
        add_user_to_course_group(self.creator, staff2, location2,
                                 STAFF_ROLE_NAME)

        self.assertSetEqual({self.staff, staff2, self.creator},
                            get_users_with_staff_role())