|
@@ -5,13 +5,20 @@ from django.views.generic import FormView
|
|
|
from profiles.forms import UserProfileForm
|
|
|
|
|
|
|
|
|
-class ProfileDetailView(FormView):
|
|
|
+class ProfileFormView(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
|
|
|
+ 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)
|