Performer will sometimes by None
This commit is contained in:
parent
b77dabd586
commit
a77aeaaef9
1 changed files with 10 additions and 6 deletions
|
@ -1692,17 +1692,21 @@ def delete_org_robot(orgname, robot_shortname):
|
|||
@api_login_required
|
||||
def org_logs_api(orgname):
|
||||
def log_view(log):
|
||||
return {
|
||||
view = {
|
||||
'kind': log.kind.name,
|
||||
'metadata': json.loads(log.metadata_json),
|
||||
'ip': log.ip,
|
||||
'performer': {
|
||||
'username': log.performer.username,
|
||||
'is_robot': log.performer.robot,
|
||||
},
|
||||
'ip': log.ip,
|
||||
'datetime': log.datetime,
|
||||
}
|
||||
|
||||
if log.performer:
|
||||
view['performer'] = {
|
||||
'username': log.performer.username,
|
||||
'is_robot': log.performer.robot,
|
||||
}
|
||||
|
||||
return view
|
||||
|
||||
permission = AdministerOrganizationPermission(orgname)
|
||||
if permission.can():
|
||||
logs = model.list_logs(orgname)
|
||||
|
|
Reference in a new issue