def test_show_enroll(self):
        """
        test of show_enroll function
        when appointment doesn't exist, the request must be to redirected to the homepage
        when the appointment exists, the web page can be loaded
        :return:
        """
        response = self.client.get('/kurse/1/signinapp/')
        self.assertEqual(response.status_code, 302, 'test_show_enroll_01')

        if not(Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(name='c++',
                                    my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        Appointment.objects.create(lesson='2.DS', additional_information='test', current_count_of_participants=0,
                                   my_course=cpp, weekday='Sunday', location='location')
        Appointment.objects.create(additional_information='test', current_count_of_participants=0, my_course=cpp,
                                   location='location')

        response = self.client.get('/kurse/1/signinapp/')
        self.assertEqual(response.status_code, 200, 'test_show_enroll_02')
    def test_show_enroll(self):
        """
        test of show_enroll function
        when appointment doesn't exist, the request must be to redirected to the homepage
        when the appointment exists, the web page can be loaded
        :return:
        """
        response = self.client.get('/kurse/1/signinapp/')
        self.assertEqual(response.status_code, 302, 'test_show_enroll_01')

        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(
            name='c++', my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        Appointment.objects.create(lesson='2.DS',
                                   additional_information='test',
                                   current_count_of_participants=0,
                                   my_course=cpp,
                                   weekday='Sunday',
                                   location='location')
        Appointment.objects.create(additional_information='test',
                                   current_count_of_participants=0,
                                   my_course=cpp,
                                   location='location')

        response = self.client.get('/kurse/1/signinapp/')
        self.assertEqual(response.status_code, 200, 'test_show_enroll_02')
    def setUp(self):
        """
        create three Tutor objects in database
        :return:
        """
        global app1, app2
        for t in Tutor.objects.all():
            t.delete()
        for a in Appointment.objects.all():
            a.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()

        cpp = Course.objects.create(name='c++',
                                    my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        gro = Group.objects.create(name='Tutors')
        gro.save()
        Appointment.objects.create(my_course=cpp, current_count_of_participants=0)
        Appointment.objects.create(my_course=cpp, current_count_of_participants=0)
        Tutor.objects.create_user(email='*****@*****.**',
                                  s_number='s3000001', name_of_user='******')
        Tutor.objects.create_user(name_of_user='******', email='*****@*****.**',
                                  s_number='s3000002')
        Tutor.objects.create_user(name_of_user='******', email='*****@*****.**',
                                  s_number='s3000003')
    def setUp(self):
        """
        create three organizers in database
        :return:
        """
        for o in Organizer.objects.all():
            o.delete()
        for a in Appointment.objects.all():
            a.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        if not (UserManagement.objects.all()):
            um = UserManagement(my_management=Management.objects.all()[0])
            um.save()
        gro = Group.objects.create(name='Organizers')
        gro.save()
        Organizer.objects.create_user(name_of_user='******', email='*****@*****.**',
                                      s_number='s2000001')
        Organizer.objects.create_user(name_of_user='******', email='*****@*****.**',
                                      s_number='s2000002')
        Organizer.objects.create_user(name_of_user='******', email='*****@*****.**',
                                      s_number='s2000003')

        cpp = Course.objects.create(name='c++',
                                    my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        Appointment.objects.create(my_course=cpp, current_count_of_participants=0)
Beispiel #5
0
    def setUp(self):
        """
        create three participant objects in database
        :return:
        """
        for p in Participant.objects.all():
            p.delete()
        for a in Appointment.objects.all():
            a.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(
            name='c++', my_course_management=CourseManagement.objects.all()[0])
        cpp.save()

        Participant.objects.create_user(name_of_user='******',
                                        email='*****@*****.**',
                                        username='******',
                                        s_number='s4000001')
        Participant.objects.create_user(name_of_user='******',
                                        email='*****@*****.**',
                                        username='******',
                                        s_number='s4000002')
        Participant.objects.create_user(name_of_user='******',
                                        email='*****@*****.**',
                                        username='******',
                                        s_number='s4000003')
        Appointment.objects.create(my_course=cpp,
                                   current_count_of_participants=0)
 def setUp(self):
     for c in Course.objects.all():
         c.delete()
     if not(Management.objects.all()):
         m = Management(None)
         m.save()
     if not(CourseManagement.objects.all()):
         cm = CourseManagement(my_management=Management.objects.all()[0])
         cm.save()
     Course.objects.create(name='c++', my_course_management=CourseManagement.objects.all()[0])
 def setUp(self):
     for c in Course.objects.all():
         c.delete()
     if not (Management.objects.all()):
         m = Management(None)
         m.save()
     if not (CourseManagement.objects.all()):
         cm = CourseManagement(my_management=Management.objects.all()[0])
         cm.save()
     Course.objects.create(
         name='c++', my_course_management=CourseManagement.objects.all()[0])
    def test_proc_enroll(self):
        """
        test of proc_enroll functions
        a participant enrolls to a appointment and the count of participants must be increased
        the existing participant enrolls again, the count doesn't increase
        :return:
        """
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(
            name='c++', my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        Appointment.objects.create(lesson='2.DS',
                                   additional_information='test',
                                   current_count_of_participants=0,
                                   my_course=cpp,
                                   weekday='Sunday',
                                   location='location')
        Appointment.objects.create(additional_information='test',
                                   current_count_of_participants=0,
                                   my_course=cpp,
                                   location='location')

        response = self.client.get('/kurse/1/signinappdone/')
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_01')

        participants = Participant.objects.all()
        self.assertEqual(len(participants), 0, 'test_proc_enroll_02')

        response = self.client.post('/kurse/1/signinappdone/',
                                    {'snumber': 's40006'})
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_03')

        participants = Participant.objects.all()
        self.assertNotEqual(len(participants), 1, 'test_proc_enroll_04')

        response = self.client.post('/kurse/1/signinappdone/',
                                    {'snumber': 's40006'})
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_05')

        participants = Participant.objects.all()
        self.assertNotEqual(len(participants), 1, 'test_proc_enroll_06')

        response = self.client.post('/kurse/1/signinappdone/',
                                    {'snumber': 's40007'})
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_07')

        participants = Participant.objects.all()
        self.assertNotEqual(len(participants), 2, 'test_proc_enroll_08')
Beispiel #9
0
    def setUp(self):
        for t in Tutor.objects.all():
            t.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        if not (UserManagement.objects.all()):
            um = UserManagement(my_management=Management.objects.all()[0])
            um.save()

        gro = Group.objects.create(name='Tutors')
        gro.save()
    def setUp(self):
        for t in Tutor.objects.all():
            t.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        if not (UserManagement.objects.all()):
            um = UserManagement(my_management=Management.objects.all()[0])
            um.save()

        gro = Group.objects.create(name='Tutors')
        gro.save()
    def test_proc_enroll(self):
        """
        test of proc_enroll functions
        a participant enrolls to a appointment and the count of participants must be increased
        the existing participant enrolls again, the count doesn't increase
        :return:
        """
        if not(Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(name='c++',
                                    my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        Appointment.objects.create(lesson='2.DS', additional_information='test', current_count_of_participants=0,
                                   my_course=cpp, weekday='Sunday', location='location')
        Appointment.objects.create(additional_information='test', current_count_of_participants=0, my_course=cpp,
                                   location='location')

        response = self.client.get('/kurse/1/signinappdone/')
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_01')

        participants = Participant.objects.all()
        self.assertEqual(len(participants), 0, 'test_proc_enroll_02')

        response = self.client.post('/kurse/1/signinappdone/', {'snumber': 's40006'})
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_03')

        participants = Participant.objects.all()
        self.assertNotEqual(len(participants), 1, 'test_proc_enroll_04')

        response = self.client.post('/kurse/1/signinappdone/', {'snumber': 's40006'})
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_05')

        participants = Participant.objects.all()
        self.assertNotEqual(len(participants), 1, 'test_proc_enroll_06')

        response = self.client.post('/kurse/1/signinappdone/', {'snumber': 's40007'})
        self.assertEqual(response.status_code, 302, 'test_proc_enroll_07')

        participants = Participant.objects.all()
        self.assertNotEqual(len(participants), 2, 'test_proc_enroll_08')
Beispiel #12
0
    def setUp(self):
        """
        create course, appointment, tutor and participant objects in database
        :return:
        """
        global cpp
        for a in Appointment.objects.all():
            a.delete()
        for p in Participant.objects.all():
            p.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(name='c++',
                                    my_course_management=CourseManagement.objects.all()[0])
        cpp.save()

        c = Course.objects.create(name='c',
                                    my_course_management=CourseManagement.objects.all()[0])
        c.save()
        gro = Group.objects.create(name='Tutors')
        gro.save()

        Appointment.objects.create(lesson='2.DS', additional_information='test',
                                   current_count_of_participants=0, my_course=cpp,
                                   weekday='Sunday', location='location')
        Appointment.objects.create(additional_information='test', current_count_of_participants=0,
                                   my_course=cpp, location='location')
        Appointment.objects.create(lesson='2.DS', additional_information='test',
                                   current_count_of_participants=0, my_course=c,
                                   weekday='Sunday', location='location')
        Participant.objects.create_user(name_of_user='******', email='*****@*****.**',
                                        s_number='s4000001', username='******')
        Participant.objects.create_user(name_of_user='******', email='*****@*****.**',
                                        s_number='s4000002', username='******')
        Participant.objects.create_user(name_of_user='******', email='*****@*****.**',
                                        s_number='s4000003', username='******')
        Tutor.objects.create_user(name_of_user='******', s_number='s5000001', email='*****@*****.**')
    def test_user_account_manager(self):
        """
        test of user_account_manager functions
        :return:
        """
        if not(Management.objects.all()):
            m = Management(None)
            m.save()

        cpp = Course.objects.create(name='c++',
                                    my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        appum = Appointment(additional_information='test', attendance=2, current_count_of_participants=0,
                            my_course=cpp, location='location')
        appum.save()
        user = UserAccount.objects.create_user(username='******', s_number='s0000001', name_of_user='******',
                                               email='*****@*****.**')
        self.assertEqual(user.email, '*****@*****.**')
        self.assertEqual(user.s_number, 's0000001')
    def setUp(self):
        """
        create three participant objects in database
        :return:
        """
        for p in Participant.objects.all():
            p.delete()
        for a in Appointment.objects.all():
            a.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        cpp = Course.objects.create(name="c++", my_course_management=CourseManagement.objects.all()[0])
        cpp.save()

        Participant.objects.create_user(
            name_of_user="******",
            email="*****@*****.**",
            username="******",
            s_number="s4000001",
        )
        Participant.objects.create_user(
            name_of_user="******",
            email="*****@*****.**",
            username="******",
            s_number="s4000002",
        )
        Participant.objects.create_user(
            name_of_user="******",
            email="*****@*****.**",
            username="******",
            s_number="s4000003",
        )
        Appointment.objects.create(my_course=cpp, current_count_of_participants=0)
Beispiel #15
0
    def setUp(self):
        """
        create three Tutor objects in database
        :return:
        """
        global app1, app2
        for t in Tutor.objects.all():
            t.delete()
        for a in Appointment.objects.all():
            a.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()

        cpp = Course.objects.create(
            name='c++', my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        gro = Group.objects.create(name='Tutors')
        gro.save()
        Appointment.objects.create(my_course=cpp,
                                   current_count_of_participants=0)
        Appointment.objects.create(my_course=cpp,
                                   current_count_of_participants=0)
        Tutor.objects.create_user(email='*****@*****.**',
                                  s_number='s3000001',
                                  name_of_user='******')
        Tutor.objects.create_user(name_of_user='******',
                                  email='*****@*****.**',
                                  s_number='s3000002')
        Tutor.objects.create_user(name_of_user='******',
                                  email='*****@*****.**',
                                  s_number='s3000003')
    def setUp(self):
        """
        create three organizers in database
        :return:
        """
        for o in Organizer.objects.all():
            o.delete()
        for a in Appointment.objects.all():
            a.delete()
        for c in Course.objects.all():
            c.delete()
        if not (Management.objects.all()):
            m = Management(None)
            m.save()
        if not (CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
        if not (UserManagement.objects.all()):
            um = UserManagement(my_management=Management.objects.all()[0])
            um.save()
        gro = Group.objects.create(name='Organizers')
        gro.save()
        Organizer.objects.create_user(name_of_user='******',
                                      email='*****@*****.**',
                                      s_number='s2000001')
        Organizer.objects.create_user(name_of_user='******',
                                      email='*****@*****.**',
                                      s_number='s2000002')
        Organizer.objects.create_user(name_of_user='******',
                                      email='*****@*****.**',
                                      s_number='s2000003')

        cpp = Course.objects.create(
            name='c++', my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        Appointment.objects.create(my_course=cpp,
                                   current_count_of_participants=0)
Beispiel #17
0
    def test_user_account_manager(self):
        """
        test of user_account_manager functions
        :return:
        """
        if not (Management.objects.all()):
            m = Management(None)
            m.save()

        cpp = Course.objects.create(
            name='c++', my_course_management=CourseManagement.objects.all()[0])
        cpp.save()
        appum = Appointment(additional_information='test',
                            attendance=2,
                            current_count_of_participants=0,
                            my_course=cpp,
                            location='location')
        appum.save()
        user = UserAccount.objects.create_user(username='******',
                                               s_number='s0000001',
                                               name_of_user='******',
                                               email='*****@*****.**')
        self.assertEqual(user.email, '*****@*****.**')
        self.assertEqual(user.s_number, 's0000001')
Beispiel #18
0
def show_form_login(request):
    """
    This view shows our login-site and initializes our database if necessary.\n
    When the login-site is loaded, this view checks if groups have been stored\n
    within our database and creates them if necessary to ensure full\n
    login-functionality.\n
    \n
    For testing purposes, this view may create some accounts, courses and appointments. \n

    :param request: the incoming request
    :return: rendered login-site
    """

    # logout user if he or she navigates back to this page from an executive-view
    logout(request)

    # define account for exception handling
    account = Executive
    # tutor_account_1 = Tutor
    # tutor_account_2 = Tutor
    app1 = Appointment
    app2 = Appointment

    # initialize our User Groups...
    count_of_organizers = len(Group.objects.filter(name="Organizers"))
    count_of_tutors = len(Group.objects.filter(name="Tutors"))
    if count_of_organizers is 0:
        Group.objects.create(name="Organizers")
    if count_of_tutors is 0:
        Group.objects.create(name="Tutors")

    # initialize management objects...
    if not (Management.objects.all()):
        m = Management(None)
        m.save()
    if not (CourseManagement.objects.all()):
        cm = CourseManagement(my_management=Management.objects.all()[0])
        cm.save()
    if not (UserManagement.objects.all()):
        um = UserManagement(my_management=Management.objects.all()[0])
        um.save()

    # if management has been initialized,
    # create a test Organizer and two Tutors for testing
    else:
        if not Organizer.objects.all():
            # create a unique organizer account with the custom UserManager
            # try:

            account = Organizer.objects.create_user(
                email="*****@*****.**",
                password="******",
                name_of_user="******",
                s_number="s196456")

            # not catching these exceptions anymore, vvvvvvvv
            # if something goes wrong i want to know vvvvvvvv

            # catch exception when UNIQUE constraint fails
            # except IntegrityError as e:
            #     print(e.__cause__)
            # # catch exception when account could not be created
            # except (KeyError, account.DoesNotExist):
            #     print("account exception 2")
            # # if everything went well, proceed to model-object creation
            # else:
            #     print("account success")

        # for test purposes, we create a course with several appointments and assign tutors to it
        if not (Course.objects.all()):
            test_course = Course(
                name="Django unchained",
                my_course_management=CourseManagement.objects.all()[0],
                is_visible=True)
            test_course.save()
            app1 = Appointment(my_course=test_course,
                               weekday="Monday",
                               lesson="1.DS",
                               location="here",
                               attendance=15,
                               additional_information="nstr",
                               is_visible=True)
            app1.save()
            app2 = Appointment(my_course=test_course,
                               weekday="Monday",
                               lesson="5.DS",
                               location="over there",
                               attendance=15,
                               additional_information="nstr",
                               is_visible=True)
            app2.save()

        if not Tutor.objects.all() and Appointment.objects.all().count() > 0:
            print("Tutors!")
            # create a unique user account with the custom UserManager

            # try:
            tutor_account_1 = Tutor.objects.create_user(
                email="*****@*****.**",
                password="******",
                name_of_user="******",
                s_number="s198385")

            # not catching these exceptions anymore, vvvvvvvv
            # if something goes wrong i want to know vvvvvvvv

            # # catch exception when UNIQUE constraint fails
            # except IntegrityError as e:
            #     print(e.__cause__)
            # # catch exception when account could not be created
            # except (KeyError, tutor_account_1.DoesNotExist):
            #     print("account exception 2")
            # # if everything went well, proceed to model-object creation
            # else:
            #     print("account success t1")

            # create a unique user account with the custom UserManager
            # try:
            tutor_account_2 = Tutor.objects.create_user(
                email="*****@*****.**",
                password="******",
                name_of_user="******",
                s_number="s195585")
            # # catch exception when UNIQUE constraint fails
            # except IntegrityError as e:
            #     print(e.__cause__)
            # # catch exception when account could not be created
            # except (KeyError, tutor_account_2.DoesNotExist):
            #     print("account exception 2")
            # # if everything went well, proceed to model-object creation
            # else:
            #     print("account success t2")

            # lets assign tutor 1 to both appointments
            if tutor_account_1 and app1:
                app1.add_tutor(tutor_account_1)
                if app2:
                    app2.add_tutor(tutor_account_1)

    form = None
    return render(request, 'cmanagement/login.html', {'form': form})
def show_form_login(request):
    """
    This view shows our login-site and initializes our database if necessary.\n
    When the login-site is loaded, this view checks if groups have been stored\n
    within our database and creates them if necessary to ensure full\n
    login-functionality.\n
    \n
    For testing purposes, this view may create some accounts, courses and appointments. \n

    :param request: the incoming request
    :return: rendered login-site
    """

    # logout user if he or she navigates back to this page from an executive-view
    logout(request)

    # define account for exception handling
    account = Executive
    # tutor_account_1 = Tutor
    # tutor_account_2 = Tutor
    app1 = Appointment
    app2 = Appointment

    # initialize our User Groups...
    count_of_organizers = len(Group.objects.filter(name="Organizers"))
    count_of_tutors = len(Group.objects.filter(name="Tutors"))
    if count_of_organizers is 0:
        Group.objects.create(name="Organizers")
    if count_of_tutors is 0:
        Group.objects.create(name="Tutors")

    # initialize management objects...
    if not(Management.objects.all()):
        m = Management(None)
        m.save()
    if not(CourseManagement.objects.all()):
            cm = CourseManagement(my_management=Management.objects.all()[0])
            cm.save()
    if not(UserManagement.objects.all()):
        um = UserManagement(my_management=Management.objects.all()[0])
        um.save()

    # if management has been initialized,
    # create a test Organizer and two Tutors for testing
    else:
        if not Organizer.objects.all():
            # create a unique organizer account with the custom UserManager
            # try:


            account = Organizer.objects.create_user(
                email="*****@*****.**",
                password="******",
                name_of_user="******",
                s_number="s196456"
            )

            # not catching these exceptions anymore, vvvvvvvv
            # if something goes wrong i want to know vvvvvvvv

            # catch exception when UNIQUE constraint fails
            # except IntegrityError as e:
            #     print(e.__cause__)
            # # catch exception when account could not be created
            # except (KeyError, account.DoesNotExist):
            #     print("account exception 2")
            # # if everything went well, proceed to model-object creation
            # else:
            #     print("account success")

        # for test purposes, we create a course with several appointments and assign tutors to it
        if not (Course.objects.all()):
            test_course = Course(name="Django unchained",
                                 my_course_management=CourseManagement.objects.all()[0],
                                 is_visible=True)
            test_course.save()
            app1 = Appointment(my_course=test_course,
                               weekday="Monday",
                               lesson="1.DS",
                               location="here",
                               attendance=15,
                               additional_information="nstr",
                               is_visible=True)
            app1.save()
            app2 = Appointment(my_course=test_course,
                               weekday="Monday",
                               lesson="5.DS",
                               location="over there",
                               attendance=15,
                               additional_information="nstr",
                               is_visible=True)
            app2.save()

        if not Tutor.objects.all() and Appointment.objects.all().count() > 0:
            print("Tutors!")
            # create a unique user account with the custom UserManager


            # try:
            tutor_account_1 = Tutor.objects.create_user(
                email="*****@*****.**",
                password="******",
                name_of_user="******",
                s_number="s198385"
            )

            # not catching these exceptions anymore, vvvvvvvv
            # if something goes wrong i want to know vvvvvvvv


            # # catch exception when UNIQUE constraint fails
            # except IntegrityError as e:
            #     print(e.__cause__)
            # # catch exception when account could not be created
            # except (KeyError, tutor_account_1.DoesNotExist):
            #     print("account exception 2")
            # # if everything went well, proceed to model-object creation
            # else:
            #     print("account success t1")

            # create a unique user account with the custom UserManager
            # try:
            tutor_account_2 = Tutor.objects.create_user(
                email="*****@*****.**",
                password="******",
                name_of_user="******",
                s_number="s195585"
            )
            # # catch exception when UNIQUE constraint fails
            # except IntegrityError as e:
            #     print(e.__cause__)
            # # catch exception when account could not be created
            # except (KeyError, tutor_account_2.DoesNotExist):
            #     print("account exception 2")
            # # if everything went well, proceed to model-object creation
            # else:
            #     print("account success t2")

            # lets assign tutor 1 to both appointments
            if tutor_account_1 and app1:
                app1.add_tutor(tutor_account_1)
                if app2:
                    app2.add_tutor(tutor_account_1)

    form = None
    return render(request, 'cmanagement/login.html', {'form': form})