forked from sahana/eden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hrm.py
829 lines (726 loc) · 29.5 KB
/
hrm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
# -*- coding: utf-8 -*-
"""
Human Resource Management
"""
module = request.controller
resourcename = request.function
if not deployment_settings.has_module(module):
raise HTTP(404, body="Module disabled: %s" % module)
s3db.hrm_vars()
# =============================================================================
def index():
""" Dashboard """
mode = session.s3.hrm.mode
if mode is not None:
# Go to Personal Profile
redirect(URL(f="person"))
else:
# Bypass home page & go direct to searchable list of Volunteers
redirect(URL(f="staff", args="search"))
# =============================================================================
# People
# =============================================================================
def human_resource():
"""
HR Controller
- combined (unused, except for Imports)
"""
tablename = "hrm_human_resource"
table = s3db[tablename]
# Default to Staff
_type = table.type
_type.default = 1
s3.filter = (_type == 1)
_type.readable = False
_type.writable = False
table.site_id.writable = True
table.site_id.readable = True
list_fields = ["id",
"person_id",
"job_role_id",
"organisation_id",
"site_id",
#"site_contact",
(T("Email"), "email"),
(deployment_settings.get_ui_label_mobile_phone(), "phone"),
(T("Trainings"), "course"),
(T("Certificates"), "certificate"),
(T("Contract End Date"), "end_date"),
"status",
]
s3mgr.configure(tablename,
list_fields = list_fields)
if "expiring" in request.get_vars:
s3.filter = s3.filter & \
(table.end_date < (request.utcnow + datetime.timedelta(weeks=4)))
s3.crud_strings[tablename].title_list = T("Staff with Contracts Expiring in the next Month")
# Remove the big Add button
s3mgr.configure(tablename,
insertable=False)
def prep(r):
if r.method == "form":
return True
if r.interactive:
# Assume staff only between 16-81
s3db.pr_person.date_of_birth.widget = S3DateWidget(past=972, future=-192)
table = r.table
table.site_id.comment = DIV(DIV(_class="tooltip",
_title="%s|%s|%s" % (T("Facility"),
T("The site where this position is based."),
T("Enter some characters to bring up a list of possible matches."))))
if r.method != "read":
# Don't want to see in Create forms
# inc list_create (list_fields over-rides)
field = table.status
field.writable = False
field.readable = False
if r.method == "create" and r.component is None:
pass
elif r.id:
# Redirect to person controller
vars = {
"human_resource.id" : r.id,
"group" : "staff"
}
redirect(URL(f="person",
vars=vars))
return True
s3.prep = prep
def postp(r, output):
if r.interactive:
if not r.component:
s3_action_buttons(r, deletable=deployment_settings.get_hrm_deletable())
if "msg" in deployment_settings.modules:
# @ToDo: Remove this now that we have it in Events?
s3.actions.append({
"url": URL(f="compose",
vars = {"hrm_id": "[id]"}),
"_class": "action-btn",
"label": str(T("Send Message"))})
elif r.representation == "plain" and \
r.method !="search":
# Map Popups
output = s3db.hrm_map_popup(r)
return output
s3.postp = postp
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def staff():
"""
Staff Controller
"""
tablename = "hrm_human_resource"
table = s3db[tablename]
_type = table.type
_type.default = 1
s3.filter = (_type == 1)
table.site_id.writable = True
table.site_id.readable = True
list_fields = ["id",
"person_id",
"job_role_id",
"organisation_id",
"site_id",
#"site_contact",
(T("Email"), "email"),
(deployment_settings.get_ui_label_mobile_phone(), "phone"),
(T("Trainings"), "course"),
(T("Certificates"), "certificate"),
(T("Contract End Date"), "end_date"),
"status",
]
s3.crud_strings[tablename] = s3.crud_strings["hrm_staff"]
if "expiring" in request.get_vars:
s3.filter = s3.filter & \
(table.end_date < (request.utcnow + datetime.timedelta(weeks=4)))
s3.crud_strings[tablename].title_list = T("Staff with Contracts Expiring in the next Month")
# Remove the big Add button
s3mgr.configure(tablename,
insertable=False)
# Remove Type filter from the Search widget
human_resource_search = s3mgr.model.get_config(tablename,
"search_method")
human_resource_search.advanced.pop(1)
s3mgr.configure(tablename,
list_fields = list_fields,
search_method = human_resource_search)
def prep(r):
if r.interactive:
# Assume staff only between 16-81
s3db.pr_person.date_of_birth.widget = S3DateWidget(past=972, future=-192)
table = r.table
table.site_id.comment = DIV(DIV(_class="tooltip",
_title="%s|%s|%s" % (T("Facility"),
T("The site where this position is based."),
T("Enter some characters to bring up a list of possible matches."))))
if r.method != "read":
# Don't want to see in Create forms
# inc list_create (list_fields over-rides)
field = table.status
field.writable = False
field.readable = False
if r.method == "create" and r.component is None:
# Don't redirect
pass
elif r.method == "delete":
# Don't redirect
pass
elif r.id:
# Redirect to person controller
vars = {
"human_resource.id": r.id,
"group": "staff"
}
redirect(URL(f="person",
vars=vars))
return True
s3.prep = prep
def postp(r, output):
if r.interactive:
if not r.component:
s3_action_buttons(r, deletable=deployment_settings.get_hrm_deletable())
if "msg" in deployment_settings.modules:
# @ToDo: Remove this now that we have it in Events?
s3.actions.append({
"url": URL(f="compose",
vars = {"hrm_id": "[id]"}),
"_class": "action-btn",
"label": str(T("Send Message"))
})
elif r.representation == "plain" and \
r.method !="search":
# Map Popups
output = s3db.hrm_map_popup(r)
return output
s3.postp = postp
output = s3_rest_controller("hrm", "human_resource")
return output
# -----------------------------------------------------------------------------
def person():
"""
Person Controller
- used for Personal Profile & Imports
- includes components relevant to HRM
"""
configure = s3mgr.configure
set_method = s3mgr.model.set_method
super_key = s3mgr.model.super_key
# Custom Method for Contacts
set_method("pr", resourcename,
method="contacts",
action=s3db.pr_contacts)
# Custom Method for Identity
set_method("pr", resourcename,
method="identity")
# Custom Method for Education
set_method("pr", resourcename,
method="education")
# Custom Method for Description
set_method("pr", resourcename,
method="physical_description")
# Hide all but those details that we want
# Lock all the fields
pr_desc_table = s3db.pr_physical_description
for field in pr_desc_table.fields:
pr_desc_table[field].writable = False
pr_desc_table[field].readable = False
# Now enable those that we want
pr_desc_table.ethnicity.writable = True
pr_desc_table.ethnicity.readable = True
pr_desc_table.blood_type.writable = True
pr_desc_table.blood_type.readable = True
pr_desc_table.medical_conditions.writable = True
pr_desc_table.medical_conditions.readable = True
pr_desc_table.other_details.writable = True
pr_desc_table.other_details.readable = True
# Plug-in role matrix for Admins/OrgAdmins
realms = auth.user is not None and auth.user.realms or []
if ADMIN in realms or ORG_ADMIN in realms:
set_method("pr", resourcename, method="roles",
action=s3base.S3PersonRoleManager())
if deployment_settings.has_module("asset"):
# Assets as component of people
s3mgr.model.add_component("asset_asset",
pr_person="assigned_to_id")
# Edits should always happen via the Asset Log
# @ToDo: Allow this method too, if we can do so safely
configure("asset_asset",
insertable = False,
editable = False,
deletable = False)
group = request.get_vars.get("group", "staff")
hr_id = request.get_vars.get("human_resource.id", None)
if not str(hr_id).isdigit():
hr_id = None
mode = session.s3.hrm.mode
# Configure human resource table
tablename = "hrm_human_resource"
table = s3db[tablename]
if hr_id and str(hr_id).isdigit():
hr = table[hr_id]
if hr:
group = hr.type == 2 and "volunteer" or "staff"
# Also inform the back-end of this finding
request.get_vars["group"] = group
org = session.s3.hrm.org
if org is not None:
table.organisation_id.default = org
table.organisation_id.comment = None
table.organisation_id.readable = False
table.organisation_id.writable = False
table.site_id.requires = IS_EMPTY_OR(IS_ONE_OF(db,
"org_site.%s" % super_key(db.org_site),
s3db.org_site_represent,
filterby="organisation_id",
filter_opts=[session.s3.hrm.org]))
if hr_id:
table.site_id.writable = True
table.site_id.readable = True
else:
table.location_id.readable = True
table.site_id.readable = True
if session.s3.hrm.mode is not None:
list_fields=["id",
"organisation_id",
"type",
"job_role_id",
"location_id",
"site_id",
"status"
]
else:
list_fields=["id",
"type",
"job_role_id",
"location_id",
"site_id",
"status"
]
configure(tablename,
list_fields=list_fields)
# Configure person table
# - hide fields
tablename = "pr_person"
table = s3db[tablename]
if deployment_settings.get_hrm_experience() == "programme":
table.virtualfields.append(s3db.hrm_programme_person_virtual_fields())
table.pe_label.readable = False
table.pe_label.writable = False
table.missing.readable = False
table.missing.writable = False
table.age_group.readable = False
table.age_group.writable = False
configure(tablename,
deletable=False)
s3.crud_strings[tablename].update(
title_upload = T("Import Staff"))
# No point showing the 'Occupation' field - that's the Job Title in the Staff Record
table.occupation.readable = False
table.occupation.writable = False
# Just have a Home Address
table = s3db.pr_address
#table.type.default = 1
#table.type.readable = False
#table.type.writable = False
_crud = s3.crud_strings.pr_address
_crud.title_create = T("Add Home Address")
_crud.title_update = T("Edit Home Address")
#s3mgr.model.add_component("pr_address",
# pr_pentity=dict(joinby=super_key(s3db.pr_pentity),
# multiple=False))
# Default type for HR
table = s3db.hrm_human_resource
table.type.default = 1
request.get_vars.update(xsltmode="staff")
if session.s3.hrm.mode is not None:
# Configure for personal mode
s3db.hrm_human_resource.organisation_id.readable = True
s3.crud_strings[tablename].update(
title_display = T("Personal Profile"),
title_update = T("Personal Profile"))
# People can view their own HR data, but not edit it
configure("hrm_human_resource",
insertable = False,
editable = False,
deletable = False
)
configure("hrm_certification",
insertable = True,
editable = True,
deletable = True)
configure("hrm_credential",
insertable = False,
editable = False,
deletable = False)
configure("hrm_competency",
insertable = True, # Can add unconfirmed
editable = False,
deletable = False)
configure("hrm_training", # Can add but not provide grade
insertable = True,
editable = False,
deletable = False)
configure("hrm_experience",
insertable = False,
editable = False,
deletable = False)
configure("pr_group_membership",
insertable = False,
editable = False,
deletable = False)
else:
# Configure for HR manager mode
s3.crud_strings[tablename].update(
title_upload = T("Import Staff & Volunteers"))
if group == "staff":
s3.crud_strings[tablename].update(
title_display = T("Staff Member Details"),
title_update = T("Staff Member Details"))
elif group == "volunteer":
s3.crud_strings[tablename].update(
title_display = T("Volunteer Details"),
title_update = T("Volunteer Details"))
# Upload for configuration (add replace option)
s3.importerPrep = lambda: dict(ReplaceOption=T("Remove existing data before import"))
# Import pre-process
def import_prep(data, group=group):
"""
Deletes all HR records (of the given group) of the organisation
before processing a new data import, used for the import_prep
hook in s3mgr
"""
request = current.request
resource, tree = data
xml = s3mgr.xml
tag = xml.TAG
att = xml.ATTRIBUTE
if s3.import_replace:
if tree is not None:
if group == "staff":
group = 1
elif group == "volunteer":
group = 2
else:
return # don't delete if no group specified
root = tree.getroot()
expr = "/%s/%s[@%s='org_organisation']/%s[@%s='name']" % \
(tag.root, tag.resource, att.name, tag.data, att.field)
orgs = root.xpath(expr)
for org in orgs:
org_name = org.get("value", None) or org.text
if org_name:
try:
org_name = json.loads(s3mgr.xml.xml_decode(org_name))
except:
pass
if org_name:
htable = s3db.hrm_human_resource
otable = s3db.org_organisation
query = (otable.name == org_name) & \
(htable.organisation_id == otable.id) & \
(htable.type == group)
resource = s3mgr.define_resource("hrm", "human_resource", filter=query)
ondelete = s3mgr.model.get_config("hrm_human_resource", "ondelete")
resource.delete(ondelete=ondelete, format="xml", cascade=True)
s3mgr.import_prep = import_prep
# CRUD pre-process
def prep(r):
if r.representation == "s3json":
s3mgr.show_ids = True
elif r.interactive and r.method != "import":
if r.component:
if r.component_name == "asset":
# Edits should always happen via the Asset Log
# @ToDo: Allow this method too, if we can do so safely
configure("asset_asset",
insertable = False,
editable = False,
deletable = False)
else:
# Assume volunteers only between 12-81
r.table.date_of_birth.widget = S3DateWidget(past=972, future=-144)
resource = r.resource
if mode is not None:
r.resource.build_query(id=s3_logged_in_person())
else:
if not r.id and not hr_id:
# pre-action redirect => must retain prior errors
if response.error:
session.error = response.error
redirect(URL(r=r, f="human_resource"))
if resource.count() == 1:
resource.load()
r.record = resource.records().first()
if r.record:
r.id = r.record.id
if not r.record:
session.error = T("Record not found")
redirect(URL(f="human_resource",
args=["search"], vars={"group":group}))
if hr_id and r.component_name == "human_resource":
r.component_id = hr_id
configure("hrm_human_resource",
insertable = False)
if not r.component_id or r.method in ("create", "update"):
address_hide(s3db.pr_address)
return True
s3.prep = prep
# CRUD post-process
def postp(r, output):
if r.interactive and r.component and r.component_name == "asset":
# Provide a link to assign a new Asset
# @ToDo: Proper Widget to do this inline
output["add_btn"] = A(T("Assign Asset"),
_href=URL(c="asset", f="asset"),
_id="add-btn",
_class="action-btn")
return output
s3.postp = postp
# REST Interface
if session.s3.hrm.orgname and mode is None:
orgname = session.s3.hrm.orgname
else:
orgname = None
output = s3_rest_controller("pr", resourcename,
native=False,
rheader=s3db.hrm_rheader,
orgname=orgname,
replace_option=T("Remove existing data before import"))
return output
# -----------------------------------------------------------------------------
def person_search():
"""
Person REST controller
- limited to just search.json for use in Autocompletes
- allows differential access permissions
"""
s3mgr.configure("hrm_human_resource",
search_method = s3db.hrm_autocomplete_search,
)
s3.prep = lambda r: r.representation == "json" and \
r.method == "search"
return s3_rest_controller(module, "human_resource")
# =============================================================================
# Teams
# =============================================================================
def group():
"""
Team controller
- uses the group table from PR
"""
tablename = "pr_group"
table = s3db[tablename]
_group_type = table.group_type
_group_type.label = T("Team Type")
table.description.label = T("Team Description")
table.name.label = T("Team Name")
mtable = s3db.pr_group_membership
mtable.group_id.label = T("Team ID")
mtable.group_head.label = T("Team Leader")
# Set Defaults
_group_type.default = 3 # 'Relief Team'
_group_type.readable = _group_type.writable = False
# Only show Relief Teams
# Do not show system groups
s3.filter = (table.system == False) & \
(_group_type == 3)
# CRUD Strings
ADD_TEAM = T("Add Team")
s3.crud_strings[tablename] = Storage(
title_create = ADD_TEAM,
title_display = T("Team Details"),
title_list = T("Teams"),
title_update = T("Edit Team"),
title_search = T("Search Teams"),
subtitle_create = T("Add New Team"),
label_list_button = T("List Teams"),
label_create_button = T("Add New Team"),
label_search_button = T("Search Teams"),
msg_record_created = T("Team added"),
msg_record_modified = T("Team updated"),
msg_record_deleted = T("Team deleted"),
msg_list_empty = T("No Teams currently registered"))
s3.crud_strings["pr_group_membership"] = Storage(
title_create = T("Add Member"),
title_display = T("Membership Details"),
title_list = T("Team Members"),
title_update = T("Edit Membership"),
title_search = T("Search Member"),
subtitle_create = T("Add New Member"),
label_list_button = T("List Members"),
label_create_button = T("Add Team Member"),
label_delete_button = T("Delete Membership"),
msg_record_created = T("Team Member added"),
msg_record_modified = T("Membership updated"),
msg_record_deleted = T("Membership deleted"),
msg_list_empty = T("No Members currently registered"))
s3mgr.configure(tablename, main="name", extra="description",
# Redirect to member list when a new group has been created
create_next = URL(f="group",
args=["[id]", "group_membership"]))
s3mgr.configure("pr_group_membership",
list_fields=["id",
"person_id",
"group_head",
"description"])
# Post-process
def postp(r, output):
if r.interactive:
if not r.component:
update_url = URL(args=["[id]", "group_membership"])
s3_action_buttons(r, deletable=False, update_url=update_url)
if "msg" in deployment_settings.modules:
s3.actions.append({
"url": URL(f="compose",
vars = {"group_id": "[id]"}),
"_class": "action-btn",
"label": str(T("Send Notification"))})
return output
s3.postp = postp
tabs = [
(T("Team Details"), None),
# Team should be contacted either via the Leader or
# simply by sending a message to the group as a whole.
#(T("Contact Data"), "contact"),
(T("Members"), "group_membership")
]
output = s3_rest_controller("pr", resourcename,
rheader=lambda r: s3db.pr_rheader(r, tabs=tabs))
return output
# =============================================================================
# Jobs
# =============================================================================
def job_role():
""" Job Roles Controller """
mode = session.s3.hrm.mode
def prep(r):
if mode is not None:
r.error(403, message=auth.permission.INSUFFICIENT_PRIVILEGES)
return True
s3.prep = prep
output = s3_rest_controller()
return output
# =============================================================================
# Skills
# =============================================================================
def skill():
""" Skills Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def skill_type():
""" Skill Types Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def competency_rating():
""" Competency Rating for Skill Types Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def skill_provision():
""" Skill Provisions Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def course():
""" Courses Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller(rheader=s3db.hrm_rheader)
return output
# -----------------------------------------------------------------------------
def course_certificate():
""" Courses to Certificates Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def certificate():
""" Certificates Controller """
mode = session.s3.hrm.mode
def prep(r):
if mode is not None:
r.error(403, message=auth.permission.INSUFFICIENT_PRIVILEGES)
return True
s3.prep = prep
output = s3_rest_controller(rheader=s3db.hrm_rheader)
return output
# -----------------------------------------------------------------------------
def certificate_skill():
""" Certificates to Skills Controller """
mode = session.s3.hrm.mode
if mode is not None:
session.error = T("Access denied")
redirect(URL(f="index"))
output = s3_rest_controller()
return output
# -----------------------------------------------------------------------------
def training():
""" Training Controller """
return s3db.hrm_training_controller()
# -----------------------------------------------------------------------------
def training_event():
""" Training Events Controller """
return s3db.hrm_training_event_controller()
# =============================================================================
def skill_competencies():
"""
Called by S3FilterFieldChange to provide the competency options for a
particular Skill Type
"""
table = s3db.hrm_skill
ttable = s3db.hrm_skill_type
rtable = s3db.hrm_competency_rating
query = (table.id == request.args[0]) & \
(table.skill_type_id == ttable.id) & \
(rtable.skill_type_id == table.skill_type_id)
records = db(query).select(rtable.id,
rtable.name,
orderby=~rtable.priority)
response.headers["Content-Type"] = "application/json"
return records.json()
# =============================================================================
def staff_org_site_json():
"""
Used by the Asset - Assign to Person page
"""
table = s3db.hrm_human_resource
otable = s3db.org_organisation
#db.req_commit.date.represent = lambda dt: dt[:10]
query = (table.person_id == request.args[0]) & \
(table.organisation_id == otable.id)
records = db(query).select(table.site_id,
otable.id,
otable.name)
response.headers["Content-Type"] = "application/json"
return records.json()
# =============================================================================
# Messaging
# =============================================================================
def compose():
""" Send message to people/teams """
return s3db.hrm_compose()
# END =========================================================================