Beispiel #1
0
 def test_leave_group_invalid_group_name(self):
     p0 = Person("t0", "t0", "t0", "t0")
     p1 = Person("t1", "t1", "t1", "t1")
     p2 = Person("t2", "t2", "t2", "t2")
     p3 = Person("t3", "t3", "t3", "t3")
     Group("leave group", [p0, p1, p2, p3])
     group.leave_group("leav group", "t1")
     self.assertRaises(Exception)
     group.delete_group("leave group")
Beispiel #2
0
 def test_leave_group(self):
     p0 = Person("t0", "t0", "t0", "t0")
     p1 = Person("t1", "t1", "t1", "t1")
     p2 = Person("t2", "t2", "t2", "t2")
     p3 = Person("t3", "t3", "t3", "t3")
     Group("leave group", [p0, p1, p2, p3])
     group.leave_group("leave group", "t1")
     self.assertEqual(3, len(group.get_all_users_in_group("leave group")))
     group.delete_group("leave group")
Beispiel #3
0
    def delete_user() -> bytes:
        """
        This function deletes a user from all their groups then deletes the user from the database

        :return: (HTML) Redirects the user to the login page
        """
        if 'is_logged' in session:
            username = session['is_logged']
            all_user_groups = group.get_all_user_groups(username)
            for group_name in all_user_groups:
                group.leave_group(username, group_name)
            person.delete_user(username)
            return redirect(url_for('login'))
Beispiel #4
0
    def leave_group_user() -> bytes:
        """This function defines the confirmation page prior to leaving a group

        :return: (HTML) The correct page depending on if they hit confirm or cancel
        """
        username = session['is_logged']
        group_name = session['group_name']
        if request.method == "GET":
            if 'is_logged' in session:
                all_user_groups = group.get_all_user_groups(username)
                return render_template('profile.html',
                                       username=username,
                                       all_user_groups=all_user_groups)
        elif request.method == "POST":
            if 'is_logged' in session:
                group.leave_group(group_name, username)
                all_user_groups = group.get_all_user_groups(username)
                return render_template('profile.html',
                                       username=username,
                                       all_user_groups=all_user_groups)