[profiles] Add settings form
This commit is contained in:
28
vrobbler/apps/profiles/forms.py
Normal file
28
vrobbler/apps/profiles/forms.py
Normal 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",
|
||||
]
|
||||
11
vrobbler/apps/profiles/urls.py
Normal file
11
vrobbler/apps/profiles/urls.py
Normal 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"
|
||||
),
|
||||
]
|
||||
17
vrobbler/apps/profiles/views.py
Normal file
17
vrobbler/apps/profiles/views.py
Normal 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
|
||||
Reference in New Issue
Block a user