[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
|
||||||
54
vrobbler/templates/profiles/settings_form.html
Normal file
54
vrobbler/templates/profiles/settings_form.html
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
{% extends "base_detail.html" %}
|
||||||
|
{% load mathfilters %}
|
||||||
|
{% load static %}
|
||||||
|
{% load naturalduration %}
|
||||||
|
|
||||||
|
{% block head_extra %}
|
||||||
|
<style>
|
||||||
|
.container {
|
||||||
|
max-width: 500px;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="checkbox"] {
|
||||||
|
margin-left: 5px;
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #007bff;
|
||||||
|
box-shadow: 0 0 5px rgba(0, 123, 255, 0.2);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}Settings{% endblock %}
|
||||||
|
{% block details %}
|
||||||
|
<form action="." method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{form.as_p}}
|
||||||
|
<input type="submit" value="Save">
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
@ -36,6 +36,7 @@ from vrobbler.apps.sports.api.views import (
|
|||||||
TeamViewSet,
|
TeamViewSet,
|
||||||
)
|
)
|
||||||
from vrobbler.apps.tasks import urls as tasks_urls
|
from vrobbler.apps.tasks import urls as tasks_urls
|
||||||
|
from vrobbler.apps.profiles import urls as profiles_urls
|
||||||
from vrobbler.apps.trails import urls as trails_urls
|
from vrobbler.apps.trails import urls as trails_urls
|
||||||
from vrobbler.apps.beers import urls as beers_urls
|
from vrobbler.apps.beers import urls as beers_urls
|
||||||
from vrobbler.apps.foods import urls as foods_urls
|
from vrobbler.apps.foods import urls as foods_urls
|
||||||
@ -63,7 +64,7 @@ router.register(r"players", PlayerViewSet)
|
|||||||
router.register(r"sport-events", SportEventViewSet)
|
router.register(r"sport-events", SportEventViewSet)
|
||||||
router.register(r"teams", TeamViewSet)
|
router.register(r"teams", TeamViewSet)
|
||||||
router.register(r"users", UserViewSet)
|
router.register(r"users", UserViewSet)
|
||||||
router.register(r"user_profiles", UserProfileViewSet)
|
router.register(r"profiles", UserProfileViewSet)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("api/v1/", include(router.urls)),
|
path("api/v1/", include(router.urls)),
|
||||||
@ -88,6 +89,7 @@ urlpatterns = [
|
|||||||
path("", include(lifeevents_urls, namespace="life-events")),
|
path("", include(lifeevents_urls, namespace="life-events")),
|
||||||
path("", include(moods_urls, namespace="moods")),
|
path("", include(moods_urls, namespace="moods")),
|
||||||
path("", include(scrobble_urls, namespace="scrobbles")),
|
path("", include(scrobble_urls, namespace="scrobbles")),
|
||||||
|
path("", include(profiles_urls, namespace="profiles")),
|
||||||
path(
|
path(
|
||||||
"", scrobbles_views.RecentScrobbleList.as_view(), name="vrobbler-home"
|
"", scrobbles_views.RecentScrobbleList.as_view(), name="vrobbler-home"
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user