本文整理汇总了Python中MHLogin.MHLUsers.models.Office_Manager类的典型用法代码示例。如果您正苦于以下问题:Python Office_Manager类的具体用法?Python Office_Manager怎么用?Python Office_Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Office_Manager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: test_saveViewInfo
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_multicallgroup.saveViewInfo',
args=(self.practice.id, 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_multicallgroup.saveViewInfo',
args=(self.practice.id, 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_multicallgroup.saveViewInfo',
args=(self.practice.id, self.call_group.id)), data=view)
self.assertEqual(response.status_code, 200)
msg = json.loads(response.content)
self.assertEqual(msg['view'], view['view'])
示例3: test_getMembers
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='provider', first_name='tes', last_name="meister", email='[email protected]',
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)
示例4: 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)
示例5: 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)
示例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: setUpClass
def setUpClass(cls):
clean_db_datas()
cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
practice = PracticeLocation(practice_name='test',
practice_longit='0.1',
practice_lat='0.0',)
practice.save()
practice1 = PracticeLocation(practice_name='test1',
practice_longit='0.1',
practice_lat='0.0',)
practice1.save()
OrganizationRelationship.objects.create(organization=practice,\
parent=practice1,create_time=int(time.time()),billing_flag=True)
cls.practice = practice
cls.practice1 = practice1
staff = OfficeStaff()
staff.user = cls.user
staff.office_lat = 0.0
staff.office_longit = 0.0
staff.current_practice = practice
staff.save()
staff.practices.add(practice)
mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
mgr.save()
示例8: changeRole
def changeRole(request):
id = request.POST['pk']
newRole = request.POST['newRole']
practice = request.org
oldRole = str(get_level_by_staff(id, practice))
if newRole == '0':
Office_Manager.objects.filter(user=id, practice=practice).delete()
else:
os = OfficeStaff.objects.get(pk=id)
if oldRole == '0':
obm = Office_Manager(user=os, practice=practice, manager_role=newRole)
obm.save()
else:
om = Office_Manager.objects.get(user=os, practice=practice)
om.manager_role = newRole
om.save()
#after change staff role susscee and delete session
sessions = Session.objects.all()
for session in sessions:
values = session.get_decoded()
if 'MHL_UserIDs' in values and 'MHLUser' in values['MHL_UserIDs']:
staffID = values['MHL_UserIDs']['MHLUser']
session_key = session.session_key
os = OfficeStaff.objects.get(pk=id)
if os.user.id == staffID:
ss = Session.objects.get(session_key=session_key)
ss.delete()
return HttpResponse(json.dumps('OK'))
示例9: test_new_event
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='provider', first_name='tes', last_name="meister",
email='[email protected]', 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='provider2', first_name='tes', last_name="meister",
email='[email protected]', 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)
示例10: setUpClass
def setUpClass(cls):
clean_db_datas()
cls.user = create_user('practicemgr1', 'lin', 'xing', 'demo')
cls.user1 = create_user('practicemgr11', 'y', 'p', 'demo')
cls.broker = create_user("broker1", "bro", "1", "demo",
"123 Main St.", "Phoenix", "AZ", uklass=Broker)
practice = PracticeLocation(practice_name='test',
practice_longit='0.1',
practice_lat='0.0',)
practice.save()
practice1 = PracticeLocation(practice_name='test1',
practice_longit='0.1',
practice_lat='0.0',)
practice1.save()
OrganizationRelationship.objects.create(organization=practice,\
parent=practice1, create_time=int(time.time()), billing_flag=True)
cls.practice = practice
staff = OfficeStaff()
staff.user = cls.user
staff.office_lat = 0.0
staff.office_longit = 0.0
staff.current_practice = practice
staff.save()
staff.practices.add(practice)
cls.provider = Provider(user=cls.user1, office_lat=0.0, office_longit=0.0, current_practice = practice)
cls.provider.mdcom_phone = '5948949899'
cls.provider.save()
#
mgr = Office_Manager(user=staff, practice=practice, manager_role=2)
mgr.save()
示例11: 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)
示例12: 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)
示例13: GetSubTypesICanUseTest
class GetSubTypesICanUseTest(TestCase):
org_type = None
admin = None
manager = None
organization = None
def setUp(self):
clean_db_datas()
OrganizationType.objects.all().delete()
org_setting = OrganizationSetting()
org_setting.save()
self.org_type = OrganizationType(name="Test Org Type1",
organization_setting=org_setting, is_public=True)
# TODO: issue 2030, reserved id's is a hazardous approach, the UT's
# were working with SQLlite but not with MySQL, DB engines recycle
# id's differently and we should not rely on reserved id fields. This
# should be addressed in a separate Redmine as model changes may occur.
self.org_type.id = RESERVED_ORGANIZATION_TYPE_ID_PRACTICE
self.org_type.save()
self.organization = create_organization()
self.organization = PracticeLocation(
practice_name=get_random_username(),
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)
self.organization.save()
self.admin = create_user('admin', 'Morris', 'Kelly', 'demo', uklass=Administrator)
staff = create_user('practicemgr1', 'Practice', 'Mgr', 'demo', uklass=OfficeStaff)
staff.practices.add(self.organization)
staff.save()
self.manager = Office_Manager(user=staff, practice=self.organization, manager_role=1)
self.manager.save()
def test_get_sub_types_I_can_use_empty(self):
self.assertEqual(0, len(get_sub_types_by_typeid(self.org_type.id)))
def test_get_sub_types_I_can_use(self):
create_multiple_organization_types(self.org_type, num=10)
self.assertEqual(10, len(get_sub_types_by_typeid(self.org_type.id)))
create_multiple_organization_types(self.org_type, num=10, is_public=False)
self.assertEqual(10, len(get_sub_types_by_typeid(self.org_type.id)))
self.assertEqual(0, len(get_sub_types_by_typeid(self.org_type.id, is_public=True)))
def tearDown(self):
pass
示例14: member_staff_create
def member_staff_create(request):
context = get_context_for_organization(request)
current_practice = request.org
if request.method == 'POST':
staff_form = CreateOfficeStaffForm(request.POST, current_practice=current_practice)
mhluser_form = CreateMHLUserForm(request.POST, request.FILES)
if staff_form.is_valid() and mhluser_form.is_valid():
mhluser = mhluser_form.save(commit=False)
mhluser.is_active = 0
mhluser.address1 = current_practice.practice_address1
mhluser.address2 = current_practice.practice_address2
mhluser.city = current_practice.practice_city
mhluser.state = current_practice.practice_state
mhluser.zip = current_practice.practice_zip
mhluser.lat = current_practice.practice_lat
mhluser.longit = current_practice.practice_longit
mhluser.save()
staff = staff_form.save(commit=False)
staff.user = mhluser
staff.current_practice = current_practice
staff.save()
staff.practices.add(current_practice)
staff.save()
staff_type = int(staff_form.cleaned_data['staff_type'])
if USER_TYPE_OFFICE_MANAGER == staff_type:
manager = Office_Manager(user=staff, practice=current_practice)
manager.save()
if USER_TYPE_NURSE == staff_type:
nurse = Nurse(user=staff)
nurse.save()
elif USER_TYPE_DIETICIAN == staff_type:
dietician = Dietician(user=staff)
dietician.save()
# TESTING_KMS_INTEGRATION
create_default_keys(mhluser)
sendAccountActiveCode(request, USER_TYPE_OFFICE_STAFF,
current_practice, request.session["MHL_Users"]["MHLUser"])
else:
context['user_form'] = mhluser_form
context['staff_form'] = staff_form
return render_to_response('MHLOrganization/Member/member_staff_create.html', context)
context['user_form'] = CreateMHLUserForm()
staff_form = CreateOfficeStaffForm(current_practice=current_practice)
context['staff_form'] = staff_form
return render_to_response('MHLOrganization/Member/member_staff_create.html', context)
示例15: test_display_scheduler_emptydata
def test_display_scheduler_emptydata(self):
dataEmpty = {}
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()
response = self.client.get(reverse('MHLogin.MHLCallGroups.Scheduler.views.display_scheduler',
args=(self.call_group.id,)), data=dataEmpty)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'schedule.html')
self.assertEqual(-1, response.content.find('fc-event-inner')) # event tag