def update_resource(resource, request_body): fields = request_body if "owner" in resource: if "reason_unassigned" in fields: return remove_staff_participant(owner_id=fields['owner_id'], reason=fields['reason_unassigned']) else: change_request_status(int(fields['request_id']), "Rerouted") return assign_owner(int(fields['request_id']), fields['owner_reason'], fields['owner_email']) elif "reopen" in resource: change_request_status(int(fields['request_id']), "Reopened") return fields['request_id'] elif "request_text" in resource: update_obj(attribute="text", val=fields['request_text'], obj_type="Request", obj_id=fields['request_id']) elif "note_text" in resource: update_obj(attribute="text", val=fields['note_text'], obj_type="Note", obj_id=fields['response_id']) # Need to store note text somewhere else (or just do delete here as well) elif "note_delete" in resource: # Need to store note somewhere else remove_obj("Note", int(fields['response_id'])) elif "record_delete" in resource: remove_obj("Record", int(fields['record_id'])) # Need to store record somewhere else and prompt them to delete from Scribd as well, if they'd like else: return False
def update_resource(resource, request_body): fields = request_body if "owner" in resource: if "reason_unassigned" in fields: return remove_staff_participant(owner_id = fields['owner_id'], reason = fields['reason_unassigned']) else: change_request_status(int(fields['request_id']), "Rerouted") return assign_owner(int(fields['request_id']), fields['owner_reason'], fields['owner_email']) elif "reopen" in resource: change_request_status(int(fields['request_id']), "Reopened") return fields['request_id'] elif "request_text" in resource: update_obj(attribute = "text", val = fields['request_text'], obj_type = "Request", obj_id = fields['request_id']) elif "note_text" in resource: update_obj(attribute = "text", val = fields['note_text'], obj_type = "Note", obj_id = fields['response_id']) elif "note_delete" in resource: remove_obj("Note", int(fields['response_id'])) elif "record_delete" in resource: remove_obj("Record", int(fields['record_id'])) else: return False
def update_resource(resource, request_body): fields = request_body if "owner" in resource: if "reason_unassigned" in fields: return remove_staff_participant(owner_id = fields['owner_id'], reason = fields['reason_unassigned']) else: change_request_status(int(fields['request_id']), "Rerouted") return assign_owner(int(fields['request_id']), fields['owner_reason'], fields['owner_email']) elif "reopen" in resource: change_request_status(int(fields['request_id']), "Reopened") return fields['request_id'] elif "request_text" in resource: update_obj(attribute = "text", val = fields['request_text'], obj_type = "Request", obj_id = fields['request_id']) elif "note_text" in resource: update_obj(attribute = "text", val = fields['note_text'], obj_type = "Note", obj_id = fields['response_id']) # Need to store note text somewhere else (or just do delete here as well) elif "note_delete" in resource: # Need to store note somewhere else remove_obj("Note", int(fields['response_id'])) elif "record_delete" in resource: remove_obj("Record", int(fields['record_id'])) # Need to store record somewhere else and prompt them to delete from Scribd as well, if they'd like else: return False