[profiles] Add settings form

This commit is contained in:
2025-02-23 22:49:18 -05:00
parent b03da9ab37
commit 93c16d80ec
5 changed files with 113 additions and 1 deletions

View File

@ -0,0 +1,28 @@
from django import forms
from profiles.models import UserProfile
class UserProfileForm(forms.ModelForm):
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",
]

View File

@ -0,0 +1,11 @@
from django.urls import path
from profiles import views
app_name = "profiles"
urlpatterns = [
path(
"settings/", views.ProfileDetailView.as_view(), name="profile_settings"
),
]

View File

@ -0,0 +1,17 @@
from django.urls import reverse_lazy
from django.http.response import HttpResponseBadRequest
from django.views.generic import FormView
from profiles.forms import UserProfileForm
class ProfileDetailView(FormView):
form_class = UserProfileForm
template_name = "profiles/settings_form.html"
success_url = reverse_lazy("profiles:profile_settings")
def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
if self.request.user.is_anonymous:
return HttpResponseBadRequest
return context_data