def delete_realm_export(request: HttpRequest, user: UserProfile, export_id: int) -> HttpResponse: try: audit_log_entry = RealmAuditLog.objects.get( id=export_id, realm=user.realm, event_type="realm_exported") except RealmAuditLog.DoesNotExist: return json_error(_("Invalid data export ID")) export_data = ujson.loads(audit_log_entry.extra_data) if 'deleted_timestamp' in export_data: return json_error(_("Export already deleted")) do_delete_realm_export(user, audit_log_entry) return json_success()
def delete_realm_export(request: HttpRequest, user: UserProfile, export_id: int) -> HttpResponse: try: audit_log_entry = RealmAuditLog.objects.get( id=export_id, realm=user.realm, event_type=RealmAuditLog.REALM_EXPORTED ) except RealmAuditLog.DoesNotExist: raise JsonableError(_("Invalid data export ID")) export_data = orjson.loads(assert_is_not_none(audit_log_entry.extra_data)) if "deleted_timestamp" in export_data: raise JsonableError(_("Export already deleted")) do_delete_realm_export(user, audit_log_entry) return json_success()