Ejemplo n.º 1
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.getMembers', args=(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.getMembers', args=(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.getMembers', args=(call_group2.id,)))
		self.assertEqual(response.status_code, 403)
Ejemplo n.º 2
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_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, call_group2.id)), data=newEventInvalidData)
		self.assertEqual(response.status_code, 403)
Ejemplo n.º 3
0
	def test_validateNewEvent(self):
		#invalid data
		eventInvalid = ''
		result = validateNewEvent(eventInvalid)
		self.assertEqual(result, 0)

		#valid data
		call_group = CallGroup(description='test', team='team')
		call_group.save()
		provider = Provider(username='******', first_name='tes', last_name="meister", 
			email='*****@*****.**', office_lat=0.0, office_longit=0.0)
		provider.save()
		callgm = CallGroupMember(call_group=call_group, member=provider, alt_provider=1)
		callgm.save()

		data = '[{"pk":null,"model":"Scheduler.evententry","fields":{"oncallPerson":"' + \
			str(provider.id) + '","eventType":"0","startDate":"2013-01-01 08:00:00",\
				"endDate":"2013-01-02 08:00:00","checkString":"5xTTV2zUPm"}}]'
		for newdsEventObj in serializers.deserialize("json", data):
			newdsEventObj.object.callGroup_id = call_group.id
			newdsEventObj.object.notifyState = 2
			newdsEventObj.object.whoCanModify = 1
			newdsEventObj.object.eventStatus = 1
		result = validateNewEvent(newdsEventObj)
		self.assertEqual(result, 1)
Ejemplo n.º 4
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"')
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
def join_call_group(call_group_id, type, provider):
    ret_data = {"success": True, "message": ""}
    pend_members = CallGroupMemberPending.objects.filter(pk=call_group_id, \
      accept_status=0)
    if not pend_members or not pend_members[0].call_group:
        ret_data["success"] = False
        ret_data["message"] = _(
            'You already have been added to the call group or declined the invitation from other client.'
        )
        return ret_data
    else:
        pend_member = pend_members[0]

    call_group_team = pend_member.call_group.team if pend_member.call_group else ''
    if type == 'Accept':
        pend_member.accept_status = 1
        pend_member.save()
        call_group = pend_member.call_group
        if (not CallGroupMember.objects.filter(call_group=call_group, \
         member=provider).exists()):
            CallGroupMember(call_group=call_group,
                            member=provider,
                            alt_provider=1).save()
        ret_data["message"] = _('You have successfully joined %s call group.')\
           %(call_group_team)
    else:
        pend_member.accept_status = 2
        pend_member.save()
        ret_data["message"] = _('You have declined %s\'s invitation.')\
           %(call_group_team)
    ret_data["success"] = True
    return ret_data
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
def acceptToJoinPractice(mhluser, pending_id, provider=None):
    """
	Accept to join Practice.

	:param mhluser: is an instance of MHLUser.
	:parm pending_id: invitation pending's id.
	:parm provider: is an instance of Provider.
	"""
    try:
        association = Pending_Association.objects.get(pk=pending_id)
        practice = association.practice_location

        if not provider:
            provider = get_object_or_404(Provider, user=mhluser)

        provider.practices.add(practice)
        current_practice = provider.current_practice
        #update current practice if needed
        new_current_practice = get_practice_org(practice)
        if (current_practice == None and new_current_practice):
            provider.current_practice = new_current_practice
            provider.save()

        #remove association record
        log_association = Log_Association()
        log_association.association_id = association.id
        log_association.from_user_id = association.from_user_id
        log_association.to_user_id = association.to_user_id
        log_association.practice_location_id = association.practice_location.id
        log_association.action_user_id = mhluser.id
        log_association.action = 'ACC'
        log_association.created_time = datetime.datetime.now()

        log_association.save()

        association.delete()

        # Add the provider to the call group.
        if (not CallGroupMember.objects.filter(call_group=practice.call_group,
                                               member=provider).exists()):
            CallGroupMember(call_group=practice.call_group,
                            member=provider,
                            alt_provider=1).save()

        # send notification to related users
        thread.start_new_thread(notify_user_tab_changed, (mhluser.id, ))

        return {
          "success": True,
          "message": _('You have successfully joined %s organization.')\
             %(practice.practice_name)
         }
    except Pending_Association.DoesNotExist:
        return {
            "success":
            False,
            "message":
            _("You already have been added to the organization"
              " or your invitation has been canceled from other client.")
        }
Ejemplo n.º 9
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"')
Ejemplo n.º 10
0
def addPrvoderIn(request, practice_id, callgroup_id):
    callgroup_id = checkMultiCallGroupId(practice_id, callgroup_id)
    to_user = request.POST['to_user']
    to_user = Provider.objects.get(id=to_user)
    call_group = CallGroup.objects.get(id=callgroup_id)
    try:
        CallGroupMember(call_group=call_group, member=to_user,
                        alt_provider=1).save()
        msg = 'Congratulations! We have added this member to call group. You can:'
        return HttpResponse(json.dumps({'err': msg}))
    except Exception:
        return HttpResponse(
            json.dumps({'ok': 'There is an error, please refresh page.'}))
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
	def test_checkDSEventConsistency(self):
		#invalid data
		eventInvalid = ''
		result = checkDSEventConsistency(eventInvalid)
		self.assertEqual(result, 0)

		#valid data
		call_group = CallGroup(description='test', team='team')
		call_group.save()
		provider = Provider(username='******', first_name='tes', last_name="meister", 
			email='*****@*****.**', office_lat=0.0, office_longit=0.0)
		provider.save()
		callgm = CallGroupMember(call_group=call_group, member=provider, alt_provider=1)
		callgm.save()
		checkString = 'Ca69J2X6l8'
		event = EventEntry(creator=provider,
						oncallPerson=provider,
						callGroup=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()

		data = '[{"pk":' + str(event.pk) + ',"model":"Scheduler.evententry","fields":{"oncallPerson":"' + \
			str(provider.id) + '","eventType":"0","startDate":"2013-01-01 08:00:00", \
				"endDate":"2013-01-02 08:00:00","checkString":"5xTTV2zUPm"}}]'
		for newdsEventObj in serializers.deserialize("json", data):
			newdsEventObj.object.callGroup_id = call_group.id
			newdsEventObj.object.notifyState = 2
			newdsEventObj.object.whoCanModify = 1
			newdsEventObj.object.eventStatus = 1
		result = checkDSEventConsistency(newdsEventObj)
		self.assertEqual(result, 1)
Ejemplo n.º 13
0
def addProviderToPractice(request):
	if (request.method == 'POST'):
		form = AssociationAssocIdForm(request.POST)
	else:
		form = AssociationAssocIdForm(request.GET)

	if (not form.is_valid()):
		return HttpResponse(json.dumps({'err': _('A server error has occurred.')}), 
			mimetype='application/json')

	assoc_id = form.cleaned_data['assoc_id']
	association = Pending_Association.objects.get(pk=assoc_id)

	#add practice association row
	practice = PracticeLocation.objects.get(pk=association.practice_location.id)
	provider = Provider.objects.get(user=association.from_user)
	provider.practices.add(practice)

	#do not update provider's current practice even if it is NULL, only providers can do it

	log_association = Log_Association()

	log_association.association_id = association.id
	log_association.from_user_id = association.from_user_id
	log_association.to_user_id = association.to_user_id
	log_association.practice_location_id = association.practice_location.id
	log_association.action_user_id = request.user.id
	log_association.action = 'ACC'
	log_association.created_time = datetime.datetime.now()

	log_association.save()

	#remove association record
	association.delete()

	# Add the provider to the call group. ONLY if practice set up before V2 of answering service
	if (practice.uses_original_answering_serice() and not CallGroupMember.objects.filter(
					call_group=practice.call_group, member=provider).exists()):
		CallGroupMember(
				call_group=practice.call_group,
				member=provider,
				alt_provider=1).save()

	# send notification to related users
	thread.start_new_thread(notify_user_tab_changed, (provider.user.id,))

	return HttpResponse(json.dumps('ok'), mimetype='application/json')
Ejemplo n.º 14
0
    def done(self, request, form_list):
        inviteForm = form_list[0]
        providerForm = form_list[1]
        providerInfo = form_list[2]
        extraSetupForm = form_list[3]

        invite = Invitation.objects.get(code=inviteForm.cleaned_data['code'])
        provider = providerForm.save(commit=False)
        provider.set_password(providerForm.cleaned_data['password1'])
        if (invite.typeVerified):
            provider.status_verified = True
            provider.status_verifier = MHLUser.objects.get(id=invite.sender_id)
        provider.save()

        provider.user = MHLUser.objects.get(id=provider.id)
        type = providerForm.cleaned_data['userType']
        if type == '1':
            Physician(
                user=provider,
                specialty=extraSetupForm.cleaned_data['specialty'],
                accepting_new_patients=extraSetupForm.
                cleaned_data['accepting_new_patients'],
                staff_type=extraSetupForm.cleaned_data['staff_type']).save()
        if type == '10':
            Physician(
                user=provider,
                specialty=extraSetupForm.cleaned_data['specialty'],
                accepting_new_patients=extraSetupForm.
                cleaned_data['accepting_new_patients'],
                staff_type=extraSetupForm.cleaned_data['staff_type']).save()
            provider.clinical_clerk = True
        if type == '2':
            NP_PA(user=provider).save()

        lst = extraSetupForm.cleaned_data['sites']
        lst2 = extraSetupForm.cleaned_data['licensed_states']
        sitesList = lst.split(',')
        sitesList2 = lst2.split(',')

        slst = []
        slst2 = []
        for s in sitesList:
            if s:
                slst.append(int(s))

        for s in sitesList2:
            if s:
                slst2.append(int(s))
        if slst:
            provider.sites = Site.objects.filter(id__in=slst)

        if extraSetupForm.cleaned_data['current_site']:
            currentSites = Site.objects.filter(
                id=int(extraSetupForm.cleaned_data['current_site']))
            if currentSites:
                cs = currentSites[0]
                provider.current_site = cs

        if slst2:
            provider.licensure_states = States.objects.filter(id__in=slst2)

        geocode_response = geocode2(providerInfo.cleaned_data['address1'], \
              providerInfo.cleaned_data['city'], \
              providerInfo.cleaned_data['state'], \
              providerInfo.cleaned_data['zip'])
        lat = geocode_response['lat']
        longit = geocode_response['lng']

        # use mhluser's address1, address2, city, state, zip to store "address" information,
        provider.address1 = providerInfo.cleaned_data['address1']
        provider.address2 = providerInfo.cleaned_data['address2']
        provider.city = providerInfo.cleaned_data['city']
        provider.state = providerInfo.cleaned_data['state']
        provider.zip = providerInfo.cleaned_data['zip']
        provider.lat = lat
        provider.longit = longit

        #add by xlin in 20120504 to add current practice
        if invite.assignPractice:
            prac = invite.assignPractice
            provider.current_practice = get_practice_org(prac)

        provider.tos_accepted = True
        if invite.recipient == request.POST['email']:
            provider.email_confirmed = True

        # Generating the user's voicemail box configuration
        config = VMBox_Config(pin='')
        config.owner = provider
        config.save()

        # LocalNumberForm, area_code, pin, mdcom_phone, mdcom_phone_sid
        numberForm = form_list[4]
        mdcom_phone = numberForm.mdcom_phone
        mdcom_phone_sid = numberForm.mdcom_phone_sid
        pin = numberForm.cleaned_data['pin']

        provider.mdcom_phone = mdcom_phone
        provider.mdcom_phone_sid = mdcom_phone_sid

        #add doctorcom number
        if settings.CALL_ENABLE:
            user_type = ContentType.objects.get_for_model(provider)
            config = VMBox_Config.objects.get(owner_type=user_type,
                                              owner_id=provider.id)
            #config.change_pin(request, new_pin=pin)
            config.set_pin(pin)
            config.save()
            twilio_ConfigureProviderLocalNumber(provider, provider.mdcom_phone)
            request.session['userId'] = provider.id
            request.session['pin'] = pin

        provider.save()

        if invite.assignPractice:
            provider.practices.add(prac)
            #add by xlin in 20120504 add new provider in call group
            group = PracticeLocation.objects.get(pk=invite.assignPractice.id)
            #ONLY if practice set up before V2 of answering service
            if (prac.uses_original_answering_serice()):
                cm = CallGroupMember(call_group=group.call_group,
                                     member=provider,
                                     alt_provider=1)
                cm.save()

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

        # Remove the invitation.
        invite.delete(createdUser=provider.user, send_notice=False)
        return HttpResponseRedirect(self.redirect_url)
Ejemplo n.º 15
0
def active_account(request):
	context = get_context(request)
	context['err'] = ''
	if request.method == 'POST':
		active_form = ActiveAccountForm(data=request.POST)
		if active_form.is_valid():
			password1 = active_form.cleaned_data["password1"]
			code = active_form.cleaned_data['activeCode']
			email = active_form.cleaned_data['email']
			acclog, user, valid_code = checkActiveCode(code, email)
			if valid_code:
				if user.is_active == 1:
					return render_to_response("Staff/sucessActive.html", context)
				else:
					user.set_password(password1)
					#user.is_active = 1
					user.save()
					acclog.delete()

					mhuser = MHLUser.objects.get(pk=user.pk)
					#add by xlin 20120629 to set email confirm
					mhuser.email_confirmed = True
					mhuser.tos_accepted = True
					mhuser.save()

					if acclog.userType == 1 or acclog.userType == 2 or acclog.userType == 10:  # provider
						provider = Provider.objects.filter(mhluser_ptr=user.pk)[0]
						prac = PracticeLocation.objects.filter(
							practice_name=acclog.practice.practice_name)[0]
						#ONLY if practice set up before V2 of answering service
						if (prac.uses_original_answering_serice()):
							cm = CallGroupMember(call_group=prac.call_group,
										member=provider, alt_provider=1)
							cm.save()
					else:  # staff TODO
						pass

					if acclog.userType in (1, 2, 10, 300) and settings.CALL_ENABLE:
						request.session['userID'] = user.pk
						return HttpResponseRedirect(reverse(getDoctorNumber))
					else:
						user.is_active = 1
						user.save()
						request.session.clear()
						return render_to_response("Staff/sucessActive.html", context)
			else:
				context['err'] = MSG_ACTIVE_OR_EMAIL_WRONG
				context['active_form'] = active_form
				return render_to_response("Staff/activeAccount.html", context)
		else:
			context['active_form'] = active_form
			return render_to_response("Staff/activeAccount.html", context)
	else:
		active_form = ActiveAccountForm(initial=request.GET)
		activeCode = active_form.cleaned_data['activeCode']
		email = active_form.cleaned_data['email']
		acclog, user, valid_code = checkActiveCode(activeCode, email)

		if valid_code:
			if user.is_active == 1:
				return render_to_response("Staff/sucessActive.html", context)
			if acclog.userType in (1, 2, 10, 300) and settings.CALL_ENABLE:
				context['getNumber'] = True
		else:
			if user and user.is_active == 1:
				return render_to_response("Staff/sucessActive.html", context)
			context['err'] = MSG_ACTIVE_OR_EMAIL_WRONG
		context['active_form'] = active_form
		return render_to_response("Staff/activeAccount.html", context)	
Ejemplo n.º 16
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_multicallgroup.bulkUpdateEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkUpdateEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkUpdateEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkUpdateEvents', 
			args=(self.practice.id, 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_multicallgroup.bulkUpdateEvents', 
			args=(self.practice.id, 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)
Ejemplo n.º 17
0
def addPracticeToProvider(request):
    provider = request.session['MHL_Users']['Provider']
    current_practice = provider.current_practice

    if (request.method == 'POST'):
        form = AddPracticeToProviderForm(request.POST)
    else:
        form = AddPracticeToProviderForm(request.GET)

    if (not form.is_valid()):
        err_obj = {
            'errors': form.errors,
        }
        return HttpResponseBadRequest(json.dumps(err_obj),
                                      mimetype='application/json')

    pract_id = form.cleaned_data['pract_id']
    assoc_id = form.cleaned_data['assoc_id']

    #add practice association row
    practice = PracticeLocation.objects.get(pk=pract_id)
    provider.practices.add(practice)

    #update current practice if needed
    new_current_practice = get_practice_org(practice)
    if (current_practice == None and new_current_practice):
        provider.current_practice = new_current_practice
        provider.save()

    #remove association record
    association = Pending_Association.objects.filter(pk=assoc_id)
    if association and len(association) > 0:
        association = association[0]

        log_association = Log_Association()

        log_association.association_id = association.id
        log_association.from_user_id = association.from_user_id
        log_association.to_user_id = association.to_user_id
        log_association.practice_location_id = association.practice_location.id
        log_association.action_user_id = request.user.id
        log_association.action = 'ACC'
        log_association.created_time = datetime.datetime.now()
        log_association.save()

        association.delete()

        # Add the provider to the call group, ONLY if practice set up before V2 of answering service
        if (practice.uses_original_answering_serice()
                and not CallGroupMember.objects.filter(
                    call_group=practice.call_group, member=provider).exists()):
            CallGroupMember(call_group=practice.call_group,
                            member=provider,
                            alt_provider=1).save()
        # send notification to related users
        thread.start_new_thread(notify_user_tab_changed, (provider.user.id, ))

        ret_data = {
            "success": True,
        }
        return HttpResponse(json.dumps(ret_data), mimetype='application/json')
    else:
        ret_data = {
            "success":
            False,
            "message":
            _("You already have been added to the organization or "
              "your invitation has been canceled from other client.")
        }
        return HttpResponse(json.dumps(ret_data), mimetype='application/json')
Ejemplo n.º 18
0
	def test_checkProviderInCallGroup(self):
		staff = OfficeStaff(user=self.user)
		staff.save()
		staff.practices.add(self.practice)
		manager = Office_Manager(user=staff, practice=self.practice, manager_role=1)
		manager.save()

		#1 provider in practice
		provider = Provider(username='******', first_name='tes', last_name="meister", email='*****@*****.**',
					office_lat=0.0, office_longit=0.0)
		provider.save()
		dataProv = {'id': provider.id}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.checkProviderInCallGroup', 
				args=(self.practice.id, self.group.id)), data=dataProv)
		self.assertEqual(response.status_code, 200)
		self.assertEqual(response.content, '"inpracitce"')

		#1 provider in 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.group, member=provider2, alt_provider=1)
		cgm.save()
		data2 = {'id': provider2.id}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.checkProviderInCallGroup', 
				args=(self.practice.id, self.group.id)), data=data2)
		self.assertEqual(response.status_code, 200)
		self.assertEqual(response.content, '"member"')

		#1 provider in pending list
		provider3 = Provider(username='******', first_name='tes', last_name="meister", email='*****@*****.**',
					office_lat=0.0, office_longit=0.0)
		provider3.save()
		pending = CallGroupMemberPending(from_user=self.user, to_user=provider3, 
			practice=self.practice, call_group=self.group, 
				accept_status=0, created_time=datetime.datetime.now())
		pending.save()
		data3 = {'id': provider3.id}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.checkProviderInCallGroup', 
				args=(self.practice.id, self.group.id)), data=data3)
		self.assertEqual(response.status_code, 200)
		self.assertEqual(response.content, '"pending"')

		#1 provider not in practcie or call group
		practice2 = PracticeLocation(practice_name='teste',
								practice_longit='0.1',
								practice_lat='0.0',)
		practice2.save()
		provider4 = Provider(username='******', first_name='tes', last_name="meister", 
			email='*****@*****.**', office_lat=0.0, office_longit=0.0)
		provider4.save()
		provider4.practices.add(practice2)
		data4 = {'id': provider4.id}
		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.'\
			'views_multicallgroup.checkProviderInCallGroup', 
				args=(self.practice.id, self.group.id)), data=data4)
		self.assertEqual(response.status_code, 200)
		self.assertEqual(response.content, '"ok"')
Ejemplo n.º 19
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_multicallgroup.redo', 
			args=(self.practice.id, call_group2.id)))
		self.assertEqual(response.status_code, 403)

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.redo', 
			args=(self.practice.id, 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_multicallgroup.bulkNewEvents', 
			args=(self.practice.id, self.call_group.id)), data=newEventInvalidData)

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.redo', 
			args=(self.practice.id, 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_multicallgroup.bulkUpdateEvents', 
			args=(self.practice.id, self.call_group.id)), data=updateEventInvalidData)

		response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.redo', 
			args=(self.practice.id, self.call_group.id)))
		msg = json.loads(response.content)
		self.assertEqual(msg['redoSize'], 0)
		self.assertEqual(msg['undoSize'], 2)
		self.assertEqual(msg['operateList'], [])
Ejemplo n.º 20
0
	def done(self, request, form_list):
		inviteForm = form_list[0]
		providerForm = form_list[1]
		providerInfo = form_list[2]
		extraSetupForm = form_list[3]

		invite = Invitation.objects.get(code=inviteForm.cleaned_data['code'])
		provider = providerForm.save(commit=False)
		provider.set_password(providerForm.cleaned_data['password1'])
		if (invite.typeVerified):
			provider.status_verified = True
			provider.status_verifier = MHLUser.objects.get(id=invite.sender_id)
		provider.save()

		provider.user = MHLUser.objects.get(id=provider.id)
		type = providerForm.cleaned_data['userType']
		if type == '1':
			Physician(user=provider,
				specialty=extraSetupForm.cleaned_data['specialty'],
				accepting_new_patients=extraSetupForm.cleaned_data['accepting_new_patients'],
				staff_type=extraSetupForm.cleaned_data['staff_type']
			).save()
		if type == '10':
			Physician(user=provider,
				specialty=extraSetupForm.cleaned_data['specialty'],
				accepting_new_patients=extraSetupForm.cleaned_data['accepting_new_patients'],
				staff_type=extraSetupForm.cleaned_data['staff_type']
			).save()
			provider.clinical_clerk = True
		if type == '2':
			NP_PA(user=provider).save()

		lst = extraSetupForm.cleaned_data['sites']
		lst2 = extraSetupForm.cleaned_data['licensed_states']
		sitesList = lst.split(',')
		sitesList2 = lst2.split(',')

		slst = []
		slst2 = []
		for s in sitesList:
			if s:
				slst.append(int(s))

		for s in sitesList2:
			if s:
				slst2.append(int(s))
		if slst:
			provider.sites = Site.objects.filter(id__in=slst)

		if extraSetupForm.cleaned_data['current_site']:
			currentSites = Site.objects.filter(id=int(extraSetupForm.cleaned_data['current_site']))
			if currentSites:
				cs = currentSites[0]
				provider.current_site = cs

		if slst2:
			provider.licensure_states = States.objects.filter(id__in=slst2)

		geocode_response = geocode2(providerInfo.cleaned_data['address1'], \
								providerInfo.cleaned_data['city'], \
								providerInfo.cleaned_data['state'], \
								providerInfo.cleaned_data['zip'])
		lat = geocode_response['lat']
		longit = geocode_response['lng']

		# use mhluser's address1, address2, city, state, zip to store "address" information,
		provider.address1 = providerInfo.cleaned_data['address1']
		provider.address2 = providerInfo.cleaned_data['address2']
		provider.city = providerInfo.cleaned_data['city']
		provider.state = providerInfo.cleaned_data['state']
		provider.zip = providerInfo.cleaned_data['zip']
		provider.lat = lat
		provider.longit = longit

		#add by xlin in 20120504 to add current practice	
		if invite.assignPractice:
			prac = invite.assignPractice
			provider.current_practice = get_practice_org(prac)

		provider.tos_accepted = True
		if invite.recipient == request.POST['email']:
			provider.email_confirmed = True

		# Generating the user's voicemail box configuration
		config = VMBox_Config(pin='')
		config.owner = provider
		config.save()

		# LocalNumberForm, area_code, pin, mdcom_phone, mdcom_phone_sid
		numberForm = form_list[4]
		mdcom_phone = numberForm.mdcom_phone
		mdcom_phone_sid = numberForm.mdcom_phone_sid
		pin = numberForm.cleaned_data['pin']

		provider.mdcom_phone = mdcom_phone
		provider.mdcom_phone_sid = mdcom_phone_sid

		#add doctorcom number
		if settings.CALL_ENABLE:
			user_type = ContentType.objects.get_for_model(provider)
			config = VMBox_Config.objects.get(owner_type=user_type, owner_id=provider.id)
			#config.change_pin(request, new_pin=pin)
			config.set_pin(pin)
			config.save()
			twilio_ConfigureProviderLocalNumber(provider, provider.mdcom_phone)
			request.session['userId'] = provider.id
			request.session['pin'] = pin

		provider.save()

		if invite.assignPractice:
			provider.practices.add(prac)
			#add by xlin in 20120504 add new provider in call group
			group = PracticeLocation.objects.get(pk=invite.assignPractice.id)
			#ONLY if practice set up before V2 of answering service
			if (prac.uses_original_answering_serice()):
				cm = CallGroupMember(call_group=group.call_group, member=provider, alt_provider=1)
				cm.save()

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

		# Remove the invitation.
		invite.delete(createdUser=provider.user, send_notice=False)
		return HttpResponseRedirect(self.redirect_url)
Ejemplo n.º 21
0
def active_account(request):
    context = get_context(request)
    context['err'] = ''
    if request.method == 'POST':
        active_form = ActiveAccountForm(data=request.POST)
        if active_form.is_valid():
            password1 = active_form.cleaned_data["password1"]
            code = active_form.cleaned_data['activeCode']
            email = active_form.cleaned_data['email']
            acclog, user, valid_code = checkActiveCode(code, email)
            if valid_code:
                if user.is_active == 1:
                    return render_to_response("Staff/sucessActive.html",
                                              context)
                else:
                    user.set_password(password1)
                    #user.is_active = 1
                    user.save()
                    acclog.delete()

                    mhuser = MHLUser.objects.get(pk=user.pk)
                    #add by xlin 20120629 to set email confirm
                    mhuser.email_confirmed = True
                    mhuser.tos_accepted = True
                    mhuser.save()

                    if acclog.userType == 1 or acclog.userType == 2 or acclog.userType == 10:  # provider
                        provider = Provider.objects.filter(
                            mhluser_ptr=user.pk)[0]
                        prac = PracticeLocation.objects.filter(
                            practice_name=acclog.practice.practice_name)[0]
                        #ONLY if practice set up before V2 of answering service
                        if (prac.uses_original_answering_serice()):
                            cm = CallGroupMember(call_group=prac.call_group,
                                                 member=provider,
                                                 alt_provider=1)
                            cm.save()
                    else:  # staff TODO
                        pass

                    if acclog.userType in (1, 2, 10,
                                           300) and settings.CALL_ENABLE:
                        request.session['userID'] = user.pk
                        return HttpResponseRedirect(reverse(getDoctorNumber))
                    else:
                        user.is_active = 1
                        user.save()
                        request.session.clear()
                        return render_to_response("Staff/sucessActive.html",
                                                  context)
            else:
                context['err'] = MSG_ACTIVE_OR_EMAIL_WRONG
                context['active_form'] = active_form
                return render_to_response("Staff/activeAccount.html", context)
        else:
            context['active_form'] = active_form
            return render_to_response("Staff/activeAccount.html", context)
    else:
        active_form = ActiveAccountForm(initial=request.GET)
        activeCode = active_form.cleaned_data['activeCode']
        email = active_form.cleaned_data['email']
        acclog, user, valid_code = checkActiveCode(activeCode, email)

        if valid_code:
            if user.is_active == 1:
                return render_to_response("Staff/sucessActive.html", context)
            if acclog.userType in (1, 2, 10, 300) and settings.CALL_ENABLE:
                context['getNumber'] = True
        else:
            if user and user.is_active == 1:
                return render_to_response("Staff/sucessActive.html", context)
            context['err'] = MSG_ACTIVE_OR_EMAIL_WRONG
        context['active_form'] = active_form
        return render_to_response("Staff/activeAccount.html", context)
Ejemplo n.º 22
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'], [])
Ejemplo n.º 23
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)
Ejemplo n.º 24
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)