mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-27 22:03:58 +00:00
Refactor Omada class methods for clarity; update device blocking logic in DeviceBlockAPIView and improve user verification error handling
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 3m14s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 3m14s
This commit is contained in:
20
api/tasks.py
20
api/tasks.py
@ -55,14 +55,6 @@ def deactivate_expired_devices():
|
||||
}
|
||||
|
||||
|
||||
def get_existing_omada_devices():
|
||||
"""
|
||||
Get existing Omada devices from Omada API via Omada class.
|
||||
:return: List of existing device names.
|
||||
"""
|
||||
return omada_client.get_existing_omada_devices()
|
||||
|
||||
|
||||
@shared_task
|
||||
def add_new_devices_to_omada(new_devices: list[dict]):
|
||||
"""
|
||||
@ -77,7 +69,13 @@ def verify_user_with_person_api_task(user_id: int):
|
||||
Verify the user with the Person API.
|
||||
:param user_id: The ID of the user to verify.
|
||||
"""
|
||||
if not user_id:
|
||||
logger.error("User ID is not provided.")
|
||||
return None
|
||||
user = get_object_or_404(User, id=user_id)
|
||||
if not user:
|
||||
logger.error(f"User with ID {user_id} not found.")
|
||||
return None
|
||||
# Call the Person API to verify the user
|
||||
|
||||
verification_failed_message = f"""
|
||||
@ -91,7 +89,7 @@ def verify_user_with_person_api_task(user_id: int):
|
||||
Visit [SAR Link Portal](https://portal.sarlink.net) to manually verify this user.
|
||||
"""
|
||||
|
||||
logger.info(verification_failed_message)
|
||||
# logger.info(verification_failed_message)
|
||||
PERSON_VERIFY_BASE_URL = env.str("PERSON_VERIFY_BASE_URL", default="") # type: ignore
|
||||
|
||||
if not PERSON_VERIFY_BASE_URL:
|
||||
@ -174,5 +172,7 @@ def verify_user_with_person_api_task(user_id: int):
|
||||
return False
|
||||
else:
|
||||
# Handle the error case
|
||||
print(f"Error verifying user: {response.status_code} - {response.text}")
|
||||
print(
|
||||
f"Error verifying user with api: {response.status_code} - {response.text}"
|
||||
)
|
||||
return
|
||||
|
Reference in New Issue
Block a user