Files
vrobbler/vrobbler/apps/profiles/forms.py
Colin Powell 0d6b2c4afc
All checks were successful
build & deploy / test (push) Successful in 1m44s
build & deploy / build-and-deploy (push) Successful in 26s
[tasks] Add unit handling to weigh-ins
2026-05-21 09:42:40 -04:00

45 lines
1.4 KiB
Python

from django import forms
from profiles.models import UserProfile
class UserProfileForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.request = kwargs.pop("request")
self.profile = UserProfile.objects.filter(user=self.request.user).first()
if not self.profile:
raise Exception
super(UserProfileForm, self).__init__(*args, instance=self.profile, **kwargs)
class Meta:
model = UserProfile
fields = [
"timezone",
"lastfm_username",
"lastfm_password",
"lastfm_auto_import",
"retroarch_path",
"retroarch_auto_import",
"archivebox_username",
"archivebox_password",
"archivebox_url",
"bgg_username",
"lichess_username",
"webdav_url",
"webdav_user",
"webdav_pass",
"webdav_auto_import",
"ntfy_url",
"ntfy_enabled",
"redirect_to_webpage",
"enable_public_widgets",
"widget_custom_css",
"home_scrobble_limit",
"weigh_in_units",
]
widgets = {
"lastfm_password": forms.PasswordInput(render_value=True),
"archivebox_password": forms.PasswordInput(render_value=True),
"webdav_pass": forms.PasswordInput(render_value=True),
}