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
|
@api_login_required
|
||||||
def org_logs_api(orgname):
|
def org_logs_api(orgname):
|
||||||
def log_view(log):
|
def log_view(log):
|
||||||
return {
|
view = {
|
||||||
'kind': log.kind.name,
|
'kind': log.kind.name,
|
||||||
'metadata': json.loads(log.metadata_json),
|
'metadata': json.loads(log.metadata_json),
|
||||||
'ip': log.ip,
|
'ip': log.ip,
|
||||||
'performer': {
|
|
||||||
'username': log.performer.username,
|
|
||||||
'is_robot': log.performer.robot,
|
|
||||||
},
|
|
||||||
'datetime': log.datetime,
|
'datetime': log.datetime,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if log.performer:
|
||||||
|
view['performer'] = {
|
||||||
|
'username': log.performer.username,
|
||||||
|
'is_robot': log.performer.robot,
|
||||||
|
}
|
||||||
|
|
||||||
|
return view
|
||||||
|
|
||||||
permission = AdministerOrganizationPermission(orgname)
|
permission = AdministerOrganizationPermission(orgname)
|
||||||
if permission.can():
|
if permission.can():
|
||||||
logs = model.list_logs(orgname)
|
logs = model.list_logs(orgname)
|
||||||
|
|
Reference in a new issue