Example #1
0
    def test_checkeUserInCallGroup(self):
        call_group = CallGroup(description='test', team='team')
        call_group.save()
        request = HttpRequest()
        user = create_user('practicemgr1', 'lin', 'xing', 'demo')
        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            user=user,
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        mem = CallGroupMember(call_group=call_group,
                              member=provider,
                              alt_provider=1)
        mem.save()
        request.method = 'POST'
        request.POST['userId'] = user.pk
        response = checkeUserInCallGroup(request, call_group.id)
        self.assertEqual(response.content, '"ok"')

        call_group2 = CallGroup(description='test', team='team')
        call_group2.save()

        response = checkeUserInCallGroup(request, call_group2.id)
        self.assertEqual(response.content, '"err"')
Example #2
0
 def _add_practices(self):
     org_setting = OrganizationSetting(can_have_answering_service=True)
     org_setting.save()
     for pract in self.practice_data:
         practice = PracticeLocation.objects.create(
             practice_name=pract["practice_name"],
             practice_address1=pract["practice_address1"],
             practice_address2=pract["practice_address2"],
             practice_city=pract["practice_city"],
             practice_state=pract["practice_state"],
             practice_zip=pract["practice_zip"],
             mdcom_phone=pract["mdcom_phone"],
             practice_phone=pract["practice_phone"],
             time_zone=pract["time_zone"],
             practice_lat=pract["practice_lat"],
             practice_longit=pract["practice_longit"],
             organization_setting=org_setting)
         practice.save()
         self.practices.append(practice)
     self.callgroup1 = CallGroup(description="Team A",
                                 team="Team A",
                                 number_selection=2)
     self.callgroup1.save()
     self.callgroup2 = CallGroup(description="Team B",
                                 team="Team B",
                                 number_selection=3)
     self.callgroup2.save()
     self.callgroup3 = CallGroup(description="Team C",
                                 team="Team C",
                                 number_selection=4)
     self.callgroup3.save()
     self.callgroup4 = CallGroup(description="Team D",
                                 team="Team D",
                                 number_selection=5)
     self.callgroup4.save()
     p1 = self.practices[0]
     p1.call_group = self.callgroup1
     p1.save()
     p2 = self.practices[1]
     p2.call_groups.add(self.callgroup2)
     p2.save()
     p3 = self.practices[2]
     p3.call_groups.add(self.callgroup3)
     p3.call_groups.add(self.callgroup4)
     p3.save()
     self.specialty1 = Specialty()
     self.specialty1.name = 'Cardiology'
     self.specialty1.practice_location = self.practices[2]
     self.specialty1.number_selection = 3
     self.specialty1.save()
     self.specialty1.call_groups.add(self.callgroup3)
     self.specialty2 = Specialty()
     self.specialty2.name = 'ENT'
     self.specialty2.practice_location = self.practices[2]
     self.specialty2.number_selection = 4
     self.specialty2.save()
     self.specialty2.call_groups.add(self.callgroup4)
Example #3
0
    def setUpClass(cls):
        clean_db_datas()
        user = create_user(
            'practicemgr1',
            'lin',
            'xing',
            'demo',
            '',
            '',
            '',
            '',
        )
        cls.user = user
        call_group = CallGroup(description='test', team='team')
        call_group.save()
        cls.group = call_group

        practice = PracticeLocation(
            practice_name='Test Org',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        cls.practice = practice
        provider = Provider()
        provider.user = cls.user
        provider.office_lat = 0.0
        provider.office_longit = 0.0
        provider.current_practice = practice
        provider.save()
        provider.practices.add(practice)
        cls.provider = provider

        practice.call_groups.add(call_group)
        cls.practice = practice
Example #4
0
    def setUpClass(cls):
        clean_db_datas()
        cls.user = create_user(
            'practicemgr1',
            'lin',
            'xing',
            'demo',
            '',
            '',
            '',
            '',
        )

        call_group = CallGroup(description='test', team='team')
        call_group.save()
        cls.call_group = call_group

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        practice.call_groups.add(call_group)
        cls.practice = practice
Example #5
0
    def test_canAccessCallGroup(self):
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(practice_name='test',
                                    practice_longit='0.1',
                                    practice_lat='0.0',
                                    call_group=call_group)
        practice.save()
        practice.call_groups.add(call_group)

        user = create_user('user-CallGroup2', 'us', 'er', 'demo')
        staff = OfficeStaff(user=user)
        staff.save()
        staff.practices.add(practice)

        #a staff call this method
        result = canAccessCallGroup(staff, long(call_group.pk))
        self.assertEqual(result, False)

        #a manager call this method
        #		manager = Office_Manager(user=staff, practice=practice, manager_role=1)
        #		manager.save()
        #
        #		result = canAccessCallGroup(manager, long(call_group.pk))
        #		self.assertEqual(result, True)

        #admin call this method
        admin = create_user('user-CallGroup', 'us', 'er', 'demo', '', '', '',
                            '', Administrator)
        result = canAccessCallGroup(admin.user, call_group)
        self.assertEqual(result, True)

        Administrator.objects.all().delete()
Example #6
0
    def test_checkUserCrossDay(self):
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        user = User(username='******',
                    email='*****@*****.**',
                    password='******',
                    first_name='li',
                    last_name='ds')
        user.save()

        result = checkUserCrossDay(user)
        self.assertEqual(result, True)
        startDate = datetime.datetime.now() + datetime.timedelta(days=-10)
        endDate = datetime.datetime.now() + datetime.timedelta(days=10)
        event = EventEntry(creator=user,
                           oncallPerson=user,
                           callGroup=call_group,
                           startDate=startDate,
                           endDate=endDate,
                           title='test event',
                           oncallLevel='0',
                           eventStatus=1,
                           checkString='abc')
        event.save()
        result = checkUserCrossDay(user)
        self.assertEqual(result, False)
Example #7
0
    def test_isCallGroupStaff(self):
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.call_group = call_group
        practice.save()

        user = create_user('user5', 'us', 'er', 'demo')

        #a mhluser call this method
        result = isCallGroupStaff(user, call_group.pk)
        self.assertEqual(result, False)

        staff = OfficeStaff(user=user)
        staff.save()
        staff.practices.add(practice)

        #a staff call this method
        result = isCallGroupStaff(user, call_group.pk)
        self.assertEqual(result, True)

        #a manager call this method
        manager = Office_Manager(user=staff, practice=practice, manager_role=1)
        manager.save()

        result = isCallGroupStaff(user, call_group.pk)
        self.assertEqual(result, True)
Example #8
0
    def test_isMultiCallGroupManager(self):
        #init practice and call group
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        practice.call_groups.add(call_group)

        user = create_user('user1', 'us', 'er', 'demo')

        #only mhluser call method
        result = isMultiCallGroupManager(user, practice.id, call_group.id)
        self.assertEqual(result, False)

        #staff call method
        staff = OfficeStaff(user=user)
        staff.save()
        result = isMultiCallGroupManager(user, call_group.id, practice.id)
        self.assertEqual(result, False)

        practice2 = PracticeLocation(
            practice_name='test2',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice2.save()
        practice2.call_groups.add(call_group)

        #manager call method
        staff.practices.add(practice)
        staff.save()
        manager = Office_Manager(user=staff, practice=practice, manager_role=1)
        manager.save()
        result = isMultiCallGroupManager(user, call_group.id, practice.id)
        self.assertEqual(result, True)

        #manager with specialty call method
        specialty_name = 'Specialty A'
        specialty1 = Specialty()
        specialty1.name = specialty_name
        specialty1.practice_location = practice
        specialty1.number_selection = 3
        specialty1.save()
        specialty1.call_groups.add(call_group)

        manager2 = Office_Manager(user=staff,
                                  practice=practice2,
                                  manager_role=1)
        manager2.save()

        result = isMultiCallGroupManager(user, call_group.id, practice.id)
        self.assertEqual(result, True)
Example #9
0
    def test_getMembers(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #0 member found
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.views_multicallgroup.getMembers',
                    args=(
                        self.practice.id,
                        self.call_group.id,
                    )))
        self.assertEqual(response.status_code, 200)

        #1 member found
        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        member = CallGroupMember(call_group=self.call_group,
                                 member=provider,
                                 alt_provider=1)
        member.save()
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.views_multicallgroup.getMembers',
                    args=(
                        self.practice.id,
                        self.call_group.id,
                    )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(len(msg), 1)
        self.assertEqual(msg[0][0], provider.id)

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.views_multicallgroup.getMembers',
                    args=(
                        self.practice.id,
                        call_group2.id,
                    )))
        self.assertEqual(response.status_code, 403)
Example #10
0
    def test_getViewInfo(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #post method
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')

        #get method without session
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(call_group2.id, )))
        self.assertEqual(response.status_code, 403)

        #get method with session---TODO
        view = '{"name":"agendaWeek","start":"2012-12-16 00:00:00","end":"2012-12-23 00:00:00"}'
        self.client.session[SessionHelper.SCHEDULE_LASTVIEW] = view
        self.client.session.save()
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.getViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')
Example #11
0
    def test_checkMultiCallGroupId(self):
        #init practice and call group
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        practice.call_groups.add(call_group)

        #pass a valid parameter
        result = checkMultiCallGroupId(practice.id, call_group.id)
        self.assertEqual(call_group.id, result)

        #practice not exist
        #		result = checkMultiCallGroupId(117, 0)
        #		self.assertRaises(PracticeLocation.DoesNotExist, result)

        #pass a invalid call group parameter
        result = checkMultiCallGroupId(practice.id, 0)
        self.assertEqual(call_group.id, result)

        #ther is a specialty
        practice2 = PracticeLocation(
            practice_name='test2',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice2.save()

        specialty_name = 'Specialty A'
        specialty1 = Specialty()
        specialty1.name = specialty_name
        specialty1.practice_location = practice2
        specialty1.number_selection = 3
        specialty1.save()
        specialty1.call_groups.add(call_group)

        result = checkMultiCallGroupId(practice2.id, 0)
        self.assertEqual(call_group.id, result)
Example #12
0
    def test_saveViewInfo(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #get method
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.saveViewInfo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], '')

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.saveViewInfo',
                    args=(call_group2.id, )))
        self.assertEqual(response.status_code, 403)

        #post method without session
        view = {
            'view':
            '{"name":"month", "start":"2012-12-01 00:00:00", "end":"2013-01-01 00:00:00"}'
        }
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.saveViewInfo',
            args=(self.call_group.id, )),
                                    data=view)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['view'], view['view'])
Example #13
0
    def test_canAccessMultiCallGroup(self):
        #init practice and call group
        call_group = CallGroup(description='test', team='team')
        call_group.save()

        practice = PracticeLocation(
            practice_name='test',
            practice_longit='0.1',
            practice_lat='0.0',
        )
        practice.save()
        practice.call_groups.add(call_group)

        #admin call this method
        admin = create_user('user-access-group2', 'us', 'er', 'demo', '', '',
                            '', '', Administrator)
        result = canAccessMultiCallGroup(admin.user, call_group, practice.id)
        self.assertEqual(result, True)

        #not admin call this method
        user = create_user('user-access-group', 'us', 'er', 'demo')
        result = canAccessMultiCallGroup(user, call_group, practice.id)
        self.assertEqual(result, False)
Example #14
0
    def test_isCallGroupMember(self):
        call_group = CallGroup(description='test', team='team')
        call_group.save()
        user = create_user('user6', 'us', 'er', 'demo')

        result = isCallGroupMember(user, call_group.id)
        self.assertEqual(result, False)

        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            user=user,
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        call_groupm = CallGroupMember(call_group=call_group,
                                      member=provider,
                                      alt_provider=1)
        call_groupm.save()

        result = isCallGroupMember(provider, call_group.id)
        self.assertEqual(result, True)
Example #15
0
    def test_bulkUpdateEvents(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        checkString = 'Ca69J2X6l8'
        #init a schecule event
        event = EventEntry(creator=self.user,
                           oncallPerson=provider,
                           callGroup=self.call_group,
                           startDate=datetime.datetime(2012, 12, 1),
                           endDate=datetime.datetime(2012, 12, 30),
                           title='test event',
                           oncallLevel='0',
                           eventStatus=1,
                           checkString=checkString)
        event.save()

        #get method
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.bulkUpdateEvents',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, "bulkOperation.html")

        #post method

        #not save new event,provider is not in the call group
        newEventInvalidData = {
            'data':
            '[{"pk":' + str(event.pk) +
            ',"model":"Scheduler.evententry","fields":{"oncallPerson":"' +
            str(provider.id) +
            '","eventType":"0","startDate":"2012-12-19 08:00:00",\
				"endDate":"2012-12-20 08:00:00","checkString":"' + checkString + '"}}]',
            'view':
            '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'
        }

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkUpdateEvents',
            args=(self.call_group.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(
            msg['error'][0].find(
                str(event.pk) + ', error updating object ' + checkString +
                ' obj '), 0)

        #save new event, provider is in the call group
        provider2 = Provider(username='******',
                             first_name='tes',
                             last_name="meister",
                             email='*****@*****.**',
                             office_lat=0.0,
                             office_longit=0.0)
        provider2.save()

        cgm = CallGroupMember(call_group=self.call_group,
                              member=provider2,
                              alt_provider=1)
        cgm.save()

        checkString = 'Ca69J2X6l8'
        newEventInvalidData = {
            'data':
            '[{"pk":' + str(event.pk) +
            ',"model":"Scheduler.evententry","fields":{"oncallPerson":"' +
            str(provider2.id) +
            '","eventType":"0","startDate":"2012-12-19 08:00:00",\
					"endDate":"2012-12-20 08:00:00","checkString":"' + checkString + '"}}]',
            'view':
            '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'
        }

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkUpdateEvents',
            args=(self.call_group.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(EventEntry.objects.count(), 1)

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkUpdateEvents',
            args=(call_group2.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 403)

        #invlid checkstring event update
        checkString = 'xxxxxxs'
        newEventInvalidData = {
            'data':
            '[{"pk":' + str(event.pk) +
            ',"model":"Scheduler.evententry","fields":{"oncallPerson":"' +
            str(provider2.id) +
            '","eventType":"0","startDate":"2012-12-19 08:00:00",\
					"endDate":"2012-12-20 08:00:00","checkString":"' + checkString + '"}}]',
            'view':
            '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'
        }

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkUpdateEvents',
            args=(self.call_group.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(
            msg['error'][0].find(
                str(event.pk) +
                ', update failed - invalid checkString xxxxxxs obj'), 0)
Example #16
0
    def test_getEvents(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=2)
        manager.save()

        errData = {}
        successDate = {
            'fromDate': datetime.datetime(2012, 12, 12),
            'toDate': datetime.datetime(2012, 12, 17)
        }

        #get method
        response = self.client.get(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.getEvents',
            args=(self.call_group.id, )),
                                   data=successDate)
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'DateEntry.html')

        #error data
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.getEvents',
            args=(self.call_group.id, )),
                                    data=errData)
        self.assertEqual(response.status_code, 403)

        #success data and find 0 event
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.getEvents',
            args=(self.call_group.id, )),
                                    data=successDate)
        self.assertEqual(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEqual(data['redoSize'], 0)
        self.assertEqual(data['undoSize'], 0)
        self.assertEqual(data['datas'], '[]')

        #success data and find 0 event and call group in form
        successDateForm = {
            'fromDate': datetime.datetime(2012, 12, 12),
            'toDate': datetime.datetime(2012, 12, 17),
            'callGroup': self.call_group.id
        }
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.getEvents',
            args=(self.call_group.id, )),
                                    data=successDateForm)
        self.assertEqual(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEqual(data['redoSize'], 0)
        self.assertEqual(data['undoSize'], 0)
        self.assertEqual(data['datas'], '[]')

        #success data and find 1 event
        event = EventEntry(creator=self.user,
                           oncallPerson=self.user,
                           callGroup=self.call_group,
                           startDate=datetime.datetime(2012, 12, 1),
                           endDate=datetime.datetime(2012, 12, 30),
                           title='test event',
                           oncallLevel='0',
                           eventStatus=1,
                           checkString='abc')
        event.save()

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.getEvents',
            args=(self.call_group.id, )),
                                    data=successDate)
        self.assertEqual(response.status_code, 200)
        data = json.loads(response.content)
        self.assertEqual(data['redoSize'], 0)
        self.assertEqual(data['undoSize'], 0)
        d = json.loads(data['datas'])
        self.assertEqual(len(d), 1)
        self.assertEqual(d[0]['pk'], event.pk)

        #error call group
        call_group2 = CallGroup(description='test', team='team')
        call_group2.save()
        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.getEvents',
            args=(call_group2.id, )),
                                    data=errData)
        self.assertEqual(response.status_code, 403)
Example #17
0
    def test_new_event(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #get method
        response = self.client.get(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.bulkNewEvents',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, "bulkOperation.html")

        #post method

        #not save new event,provider is not in the call group
        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            office_lat=0.0,
                            office_longit=0.0)
        provider.save()
        checkString = 'Ca69J2X6l8'
        newEventInvalidData = {'data': '[{"pk":null,"model":"Scheduler.evententry","fields":{"oncallPerson":"' + \
         str(provider.id) + '","eventType":"0","startDate":"2012-12-19 08:00:00",\
				"endDate":"2012-12-20 08:00:00","checkString":"'                                                           + checkString + '"}}]',
           'view': '{"name": "month","start": "2012-12-01 00:00:00","end": "2013-01-01 00:00:00"}'}

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkNewEvents',
            args=(self.call_group.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['error'][0],
                         checkString + ', error saving new object')

        #save new event, provider is in the call group
        provider2 = Provider(username='******',
                             first_name='tes',
                             last_name="meister",
                             email='*****@*****.**',
                             office_lat=0.0,
                             office_longit=0.0)
        provider2.save()

        cgm = CallGroupMember(call_group=self.call_group,
                              member=provider2,
                              alt_provider=1)
        cgm.save()

        checkString = 'Ca69J2X6l8'
        newEventInvalidData = {
            'data':
            '[{"pk":null,"model":"Scheduler.evententry","fields":{"oncallPerson":"'
            + str(provider2.id) +
            '","eventType":"0","startDate":"2012-12-19 08:00:00",\
				"endDate":"2012-12-20 08:00:00","checkString":"' + checkString + '"}}]',
            'view':
            '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'
        }

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkNewEvents',
            args=(self.call_group.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(EventEntry.objects.count(), 1)

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkNewEvents',
            args=(call_group2.id, )),
                                    data=newEventInvalidData)
        self.assertEqual(response.status_code, 403)
Example #18
0
    def test_redo(self):
        staff = OfficeStaff(user=self.user)
        staff.save()
        staff.practices.add(self.practice)
        staff.current_practice = self.practice
        staff.save()
        manager = Office_Manager(user=staff,
                                 practice=self.practice,
                                 manager_role=1)
        manager.save()

        #403
        call_group2 = CallGroup(description='test2', team='team')
        call_group2.save()
        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.redo',
                    args=(call_group2.id, )))
        self.assertEqual(response.status_code, 403)

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.redo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['count'], 0)

        #create a new event, and redo
        provider = Provider(username='******',
                            first_name='tes',
                            last_name="meister",
                            email='*****@*****.**',
                            office_lat=0.0,
                            office_longit=0.0,
                            current_practice=self.practice)
        provider.save()
        provider.practices.add(self.practice)
        cgm = CallGroupMember(call_group=self.call_group,
                              member=provider,
                              alt_provider=1)
        cgm.save()
        checkString = 'Ca69J2X6l8'
        newEventInvalidData = {
            'data':
            '[{"pk":null,"model":"Scheduler.evententry","fields":{"oncallPerson":"'
            + str(provider.id) +
            '","eventType":"0","startDate":"2012-12-19 08:00:00",\
			"endDate":"2012-12-20 08:00:00","checkString":"' + checkString + '"}}]',
            'view':
            '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'
        }

        new_event = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkNewEvents',
            args=(self.call_group.id, )),
                                     data=newEventInvalidData)

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.redo',
                    args=(self.call_group.id, )))
        self.assertEqual(response.status_code, 200)
        msg = json.loads(response.content)
        self.assertEqual(msg['undoSize'], 1)
        self.assertEqual(msg['redoSize'], 0)
        self.assertEqual(EventEntry.objects.count(), 1)

        #create a new and change event 1 time
        event = EventEntry.objects.get(checkString=checkString)
        #update
        updateEventInvalidData = {
            'data':
            '[{"pk":' + str(event.pk) +
            ',"model":"Scheduler.evententry","fields":{"oncallPerson":"' +
            str(provider.id) +
            '","eventType":"0","startDate":"2012-12-20 08:00:00","endDate":"2012-12-21 08:00:00",\
				"eventStatus":1,"checkString":"' + checkString + '"}}]',
            'view':
            '{"name":"month","start":"2012-12-01 00:00:00","end":"2013-01-01 00:00:00"}'
        }

        response = self.client.post(reverse(
            'MHLogin.MHLCallGroups.Scheduler.views.bulkUpdateEvents',
            args=(self.call_group.id, )),
                                    data=updateEventInvalidData)

        response = self.client.post(
            reverse('MHLogin.MHLCallGroups.Scheduler.views.redo',
                    args=(self.call_group.id, )))
        msg = json.loads(response.content)
        self.assertEqual(msg['redoSize'], 0)
        self.assertEqual(msg['undoSize'], 2)
        self.assertEqual(msg['operateList'], [])
Example #19
0
    def done(self, request, form_list):
        inviteform = form_list[0]
        userform = form_list[1]
        invite = Invitation.objects.get(code=inviteform.cleaned_data['code'],
                                        userType=100)
        if len(form_list) > 2:
            practiceform = form_list[2]
            practice = practiceform.save(commit=False)
            practice.practice_lat = practiceform.cleaned_data['practice_lat']
            practice.practice_longit = practiceform.cleaned_data[
                'practice_longit']
            practice.organization_type_id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
            callgroup = CallGroup(
                description=practiceform.cleaned_data['practice_name'])
            callgroup.save()
            practice.call_group = callgroup
            practice.save()
            org_relation = OrganizationRelationship(
                organization=practice,
                parent_id=RESERVED_ORGANIZATION_ID_DOCTORCOM,
                create_time=time.time())
            org_relation.save()
            manager_role = 2
        else:
            practice = invite.assignPractice
            manager_role = 1

        user = userform.save(commit=False)
        user.set_password(userform.cleaned_data['password1'])
        # use mhluser's address1, address2, city, state, zip to store "address" information,
        user.address1 = practice.practice_address1
        user.address2 = practice.practice_address2
        user.city = practice.practice_city
        user.state = practice.practice_state
        user.zip = practice.practice_zip
        user.lat = practice.practice_lat
        user.longit = practice.practice_longit
        user.tos_accepted = True
        if invite.recipient == request.POST['email']:
            user.email_confirmed = True

        user.save()

        staff = OfficeStaff(user=user, current_practice=practice)
        staff.save()
        staff.practices.add(practice)

        manager = Office_Manager(user=staff,
                                 practice=practice,
                                 manager_role=manager_role)
        manager.save()

        # TESTING_KMS_INTEGRATION
        create_default_keys(user, userform.cleaned_data['password1'])

        # Remove the invitation.
        invite.delete(createdUser=user,
                      createdPractice=practice,
                      send_notice=False)
        msg = render_to_string(
            'MHLSignup/practice_notification_email.txt', {
                'practice_name': practice.practice_name,
                'practice_id': practice.id,
                'timestamp': datetime.datetime.now().strftime("%I:%M %m/%d/%Y")
            })
        send_mail("new practice created", msg, '*****@*****.**',
                  ["*****@*****.**"])
        return HttpResponseRedirect(self.redirect_url)