From d3d5b088cd408483c516ba1bbbc0323e60d9e2cc Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 20 Oct 2024 16:22:56 -0400 Subject: [PATCH] [webdav] Add basic client --- vrobbler/apps/webdav/__init__.py | 0 vrobbler/apps/webdav/client.py | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 vrobbler/apps/webdav/__init__.py create mode 100644 vrobbler/apps/webdav/client.py diff --git a/vrobbler/apps/webdav/__init__.py b/vrobbler/apps/webdav/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vrobbler/apps/webdav/client.py b/vrobbler/apps/webdav/client.py new file mode 100644 index 0000000..f83c7d8 --- /dev/null +++ b/vrobbler/apps/webdav/client.py @@ -0,0 +1,23 @@ +from webdav3.client import Client + +from profiles.models import UserProfile + +def get_webdav_client(user_id): + client = None + profile = UserProfile.objects.filter(user_id=user_id).first() + + if not profile: + logger.info("[get_webdav_client] no profile for user", extra={"user_id": user_id}) + return + + if not profile.webdav_user: + logger.info("[get_webdav_client] no webdave user for profile", extra={"user_id": user_id}) + return + + return Client( + { + 'webdav_hostname': profile.webdav_url, + 'webdav_login': profile.webdav_user, + 'webdav_password': profile.webdav_pass, + } + )