feat: added undo of rejected join requests

Also improved the dispaly of timestamp, showing the diff now.

Issue #271
This commit is contained in:
Anand Chitipothu
2021-12-04 22:47:23 +05:30
parent e0c73e26ee
commit fb447a30e4
2 changed files with 65 additions and 3 deletions

View File

@@ -108,3 +108,24 @@ def reject_cohort_join_request(join_request):
r.status = "Rejected"
r.save(ignore_permissions=True)
return {"ok": True}
@frappe.whitelist()
def undo_reject_cohort_join_request(join_request):
r = frappe.get_doc("Cohort Join Request", join_request)
sg = r and frappe.get_doc("Cohort Subgroup", r.subgroup)
# keeping Pending as well to consider the case of duplicate requests
if not sg or r.status not in ["Pending", "Rejected"]:
return {
"ok": False,
"error": "Invalid Join Request"
}
if not sg.is_manager(frappe.session.user):
return {
"ok": False,
"error": "Permission Deined"
}
r.status = "Pending"
r.save(ignore_permissions=True)
return {"ok": True}