本文整理汇总了Python中MHLogin.MHLUsers.models.OfficeStaff类的典型用法代码示例。如果您正苦于以下问题:Python OfficeStaff类的具体用法?Python OfficeStaff怎么用?Python OfficeStaff使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OfficeStaff类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cancel_invite
def test_cancel_invite(self):
invitation_id = 0
email = '[email protected]'
request = generateHttpRequest()
#an office staff login
staff = OfficeStaff(user=request.user)
staff.save()
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 101
assn.save(request)
result = cancel_invite(request, invitation_id)
self.assertEqual(result.status_code, 403)
#a provider login
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 1
assn.save(request)
#404 not found invitation
try:
cancel_invite(request, invitation_id)
except Http404:
self.assertRaises(Http404())
code = 'abcdefg'
usertype = 1
invite = Invitation(code=code, sender=request.user, recipient=email,
userType=usertype)
invite.save()
result = cancel_invite(request, invite.pk)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(msg['data'], {})
self.assertEqual(Invitation.objects.count(), 0)
示例2: test_isCallGroupStaff
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)
示例3: test_checkoutUserManager
def test_checkoutUserManager(self):
practice = PracticeLocation(practice_name='test', practice_longit='0.1', practice_lat='0.0',)
practice.save()
user = create_user('staff', 'lin', 'xing', 'demo', '', '', '', '',)
staff = OfficeStaff(user=user)
staff.save()
staff.practices.add(practice)
provider = Provider.objects.create(username='healmeister', first_name='heal',
last_name='meister', address1="555 Bryant St.", city="Palo Alto", state="CA",
lat=0.0, longit=0.0, office_lat=0.0, office_longit=0.0, is_active=True,
tos_accepted=True, mobile_confirmed=True, mdcom_phone='123', mobile_phone='456')
provider.user = provider # for our unique prov-user reln
provider.save()
# try provider
result = user_is_mgr_of_practice(provider, practice)
self.assertEqual(False, result)
# try just staff
result = user_is_mgr_of_practice(staff.user, practice)
self.assertEqual(False, result)
# now office manager (make staff an OM)
om = Office_Manager.objects.create(user=staff, practice=practice, manager_role=1)
result = user_is_mgr_of_practice(om.user.user, practice)
self.assertEqual(True, result)
result = user_is_mgr_of_practice(staff.user, practice)
self.assertEqual(True, result)
示例4: test_practice_info
def test_practice_info(self):
organization_type = create_org_type()
practice = ct_practice('name', organization_type)
request = generateHttpRequest()
#a provider login
result = practice_info(request, practice.id)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(msg['data']['id'], practice.id)
#a staff login
staff = OfficeStaff(user=request.user)
staff.save()
manager = Office_Manager(user=staff, practice=practice, manager_role=2)
manager.save()
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 100
assn.save(request)
#invalid practice
result = practice_info(request, 0)
self.assertEqual(result.status_code, 400)
msg = json.loads(result.content)
self.assertEqual(msg['errno'], 'PF003')
#valid practice
result = practice_info(request, practice.id)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(msg['data']['id'], practice.id)
示例5: test_canAccessCallGroup
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()
示例6: test_getLevelByStaff
def test_getLevelByStaff(self):
practice = PracticeLocation(
practice_address1='555 Pleasant Pioneer Grove',
practice_address2='Trailer Q615',
practice_city='Mountain View',
practice_state='CA',
practice_zip='94040-4104',
practice_lat=37.36876,
practice_longit= -122.081864)
practice.save()
user = create_user('practicemgr1', 'lin', 'xing', 'demo')
#not a manager login
result = get_level_by_staff(user, practice)
self.assertEqual(result, 0)
staff = OfficeStaff(user=user)
staff.save()
manager = Office_Manager(user=staff, practice=practice, manager_role=2)
manager.save()
#a manager login
result = get_level_by_staff(staff.id, practice)
self.assertEqual(result, 2)
示例7: test_local_office
def test_local_office(self):
request = generateHttpRequest()
#a provider call this method
result = local_office(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['data']['practices']), 0)
#a office manager login but has not current practice
organization_type = create_org_type()
practice = ct_practice('name', organization_type)
staff = OfficeStaff(user=request.user)
staff.save()
manager = Office_Manager(user=staff, practice=practice, manager_role=2)
manager.save()
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 100
assn.save(request)
result = local_office(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['data']['practices']), 0)
#a office manager login and has current practice
staff.current_practice = practice
result = local_office(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['data']['practices']), 0)
示例8: test_getCurrentPractice
def test_getCurrentPractice(self):
practice = PracticeLocation(practice_name='test',
practice_longit='0.1',
practice_lat='0.0',)
practice.save()
user = create_user('practicemgr1', 'lin', 'xing', 'demo')
#a mhluser login and call this method
result = getCurrentPractice(user)
self.assertEqual(result, '')
#a provider login and call this method
provider = Provider(username='provider', first_name='tes', last_name="meister", email='[email protected]',
user=user, office_lat=0.0, office_longit=0.0)
provider.current_practice = practice
provider.save()
result = getCurrentPractice(user)
self.assertEqual(result, 'test')
#a staff login and call this method
staff = OfficeStaff(user=user)
staff.current_practice = practice
staff.save()
result = getCurrentPractice(user)
self.assertEqual(result, 'test')
示例9: test_getEvents
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_multicallgroup.getEvents', args=(self.practice.id, self.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_multicallgroup.getEvents',
args=(self.practice.id, self.group.id)), data=errData)
self.assertEqual(response.status_code, 403)
#error call group
group2 = CallGroup(description='test', team='team')
group2.save()
response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.getEvents',
args=(self.practice.id, group2.id)), data=errData)
self.assertEqual(response.status_code, 403)
#success data and find 0 event
response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.views_multicallgroup.getEvents',
args=(self.practice.id, self.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 1 event
event = EventEntry(creator=self.user,
oncallPerson=self.user,
callGroup=self.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_multicallgroup.getEvents',
args=(self.practice.id, self.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)
示例10: test_community_providers
def test_community_providers(self):
request = generateHttpRequest()
#find 0 provider
result = community_providers(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['data']['users']), 0)
#find 1 provider
phy = Physician(user=request.provider)
phy.save()
result = community_providers(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['data']['users']), 1)
organization_type = create_org_type()
practice = ct_practice('name', organization_type)
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 100
assn.save(request)
staff = OfficeStaff(user=request.user, current_practice=practice)
staff.save()
result = community_providers(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['data']['users']), 1)
示例11: test_display_scheduler_403
def test_display_scheduler_403(self):
data403 = {}
staff = OfficeStaff(user=self.user)
staff.save()
response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views.display_scheduler',
args=(self.call_group.id,)), data=data403)
self.assertEqual(response.status_code, 403)
示例12: test_resend_invite
def test_resend_invite(self):
email = '[email protected]'
invitation_id = 0
request = generateHttpRequest()
#get method
request.method = 'GET'
result = resend_invite(request, invitation_id)
self.assertEqual(result.status_code, 400)
msg = json.loads(result.content)
self.assertEqual(msg['errno'], 'GE002')
#post method
request.method = 'POST'
#an office staff login
staff = OfficeStaff(user=request.user)
staff.save()
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 101
assn.save(request)
result = resend_invite(request, invitation_id)
self.assertEqual(result.status_code, 403)
#a provider login
assn = SmartPhoneAssn.all_objects.get(device_id=request.REQUEST['DCOM_DEVICE_ID'])
assn.user_type = 1
assn.save(request)
#invalid invitation id
note = 'test'
request.POST['note'] = note
try:
resend_invite(request, invitation_id)
except Http404:
self.assertRaises(Http404())
usertype = 1
#another email
errEmail = '[email protected]'
code = '12345'
invite = Invitation(code=code, sender=request.user, recipient=errEmail,
userType=usertype)
invite.save()
result = resend_invite(request, invite.pk)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(msg['data']['id'], invite.id)
#use time setting
request.POST['use_time_setting'] = True
errEmail = '[email protected]'
code = '12wsxs'
invite = Invitation(code=code, sender=request.user, recipient=errEmail,
userType=usertype)
invite.save()
result = resend_invite(request, invite.pk)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(msg['data']['id'], invite.id)
示例13: test_get_all_providers_and_staffs
def test_get_all_providers_and_staffs(self):
request = generateHttpRequest()
#get method
request.method = 'GET'
result = get_all_providers_and_staffs(request)
self.assertEqual(result.status_code, 400)
msg = json.loads(result.content)
self.assertEqual(msg['errno'], 'GE002')
#post method
request.method = 'POST'
#find 0 any type user
result = get_all_providers_and_staffs(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['users']), 0)
#has 1 nppa
user = create_user('np1', 'abc', '', 'demo')
provider = Provider(user=user, username='p1', first_name='abc', last_name='',
office_lat=0.0, office_longit=0.0)
provider.save()
nppa = NP_PA(user=provider)
nppa.save()
request.POST['name'] = unicode('abc')
result = get_all_providers_and_staffs(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['users']), 1)
self.assertEqual(msg['users'][0]['first_name'], 'abc')
phy = Physician(user=provider)
phy.save()
result = get_all_providers_and_staffs(request)
self.assertEqual(result.status_code, 200)
msg = json.loads(result.content)
self.assertEqual(len(msg['users']), 2)
self.assertEqual(msg['users'][0]['first_name'], 'abc')
#staff
organization_type = create_org_type()
practice = PracticeLocation(practice_name='test',
practice_longit='0.1',
practice_lat='0.0',
mdcom_phone='8005550085',
organization_type=organization_type)
practice.save()
staff = OfficeStaff(user=request.user, current_practice=practice)
staff.save()
staff.practices.add(practice)
request.POST['name'] = unicode(request.user.first_name)
result = get_all_providers_and_staffs(request)
self.assertEqual(result.status_code, 200)
self.assertEqual(len(msg['users']), 2)
self.assertEqual(msg['users'][0]['first_name'], 'abc')
示例14: test_display_scheduler_403
def test_display_scheduler_403(self):
staff = OfficeStaff(user=self.user)
staff.save()
staff.practices.add(self.practice)
data403 = {}
response = self.client.post(reverse('MHLogin.MHLCallGroups.Scheduler.'\
'views_multicallgroup.display_scheduler',
args=(self.practice.id, self.group.id)), data=data403)
self.assertEqual(response.status_code, 403)
示例15: done
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, '[email protected]', ["[email protected]"])
return HttpResponseRedirect(self.redirect_url)