Files
vrobbler/vrobbler/apps/profiles/views.py
Colin Powell 9ce6dd8876
Some checks failed
build & deploy / deploy (push) Has been cancelled
build & deploy / test (push) Has been cancelled
[tasks] Fix todoist login link on settings
2026-04-01 12:07:18 -04:00

33 lines
1.2 KiB
Python

from django.contrib.auth.mixins import LoginRequiredMixin
from django.http.response import HttpResponseBadRequest
from django.urls import reverse_lazy
from django.views.generic import FormView
from profiles.forms import UserProfileForm
from tasks.todoist import generate_todoist_oauth_url
class ProfileFormView(LoginRequiredMixin, FormView):
form_class = UserProfileForm
template_name = "profiles/settings_form.html"
success_url = reverse_lazy("profiles:profile_settings")
def get_form_kwargs(self):
"""Passes the request object to the form class.
This is necessary to only display members that belong to a given user"""
kwargs = super(ProfileFormView, self).get_form_kwargs()
kwargs["request"] = self.request
return kwargs
def form_valid(self, form):
form.save()
return super(ProfileFormView, self).form_valid(form)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["user_id"] = self.request.user.id
context["profile"] = self.request.user.profile
context["todoist_oauth_url"] = generate_todoist_oauth_url(self.request.user.id)
return context