[webdav] Add basic client
This commit is contained in:
0
vrobbler/apps/webdav/__init__.py
Normal file
0
vrobbler/apps/webdav/__init__.py
Normal file
23
vrobbler/apps/webdav/client.py
Normal file
23
vrobbler/apps/webdav/client.py
Normal file
@ -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,
|
||||||
|
}
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user