45 lines
1.4 KiB
Python
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),
|
|
}
|