async function getRequestHistory(id) {
var response = await fetch(Urls.api_1_add_forge_request_get(id));
var data = await response.json();
var history = data.history;
var item = history.filter(item => item.actor_role === 'MODERATOR');
if (item.length > 0) {
return item[0].actor;
}if has_add_forge_now_permission(request.user):
return '';
}
Inside the data table:
{requests = AddForgeNowRequestSerializer(page.object_list, many=True).data
data: 'id',for item in page.object_list:
name: 'Admin Name', history = AddForgeNowRequestHistory.objects.filter(request=item).order_by(
render: function(data, type, row, meta) { "id"
var adminName = getRequestHistory(data);)
// get value from promisefor request in requests:
adminName.then(function(value) { last_item = history[len(history) - 1]
console.log('Value is ' + value); if request["id"] == last_item.__dict__["request_id"]:
window.adminName = value; request["actor_role"] = last_item.__dict__["actor_role"]
return value; if request["actor_role"] == "MODERATOR":
}); request["actor"] = last_item.__dict__["actor"]
console.log('This is the response ' + window.adminName); //undefined because its synchronous request["last_modified_date"] = last_item.__dict__["date"]
return 'Return Comes Here'; else:
} request["actor"] = "No action taken yet"
request["last_modified_date"] = request["submission_date"]
else:
},requests = AddForgeNowRequestPublicSerializer(page.object_list, many=True).data
results = [dict(request) for request in requests]
table_data["recordsFiltered"] = add_forge_requests.count()
table_data["data"] = results
return JsonResponse(table_data)