From 3b7e3388089e35c872b3983c8ec1c57f31160cba Mon Sep 17 00:00:00 2001 From: imperosol Date: Fri, 15 Nov 2024 14:47:39 +0100 Subject: [PATCH] fix 500 when accessing preferences MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand on tente d'accéder aux préférences d'un utilisateur relié à un trombi, sans être soi-même dans un trombi, on a une erreur. --- core/views/user.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/core/views/user.py b/core/views/user.py index 2c6b01fc..b758590a 100644 --- a/core/views/user.py +++ b/core/views/user.py @@ -559,10 +559,6 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView): context_object_name = "profile" current_tab = "prefs" - def get_object(self, queryset=None): - user = get_object_or_404(User, pk=self.kwargs["user_id"]) - return user - def get_form_kwargs(self): kwargs = super().get_form_kwargs() pref = self.object.preferences @@ -572,9 +568,7 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView): def get_context_data(self, **kwargs): kwargs = super().get_context_data(**kwargs) - if not ( - hasattr(self.object, "trombi_user") and self.request.user.trombi_user.trombi - ): + if not hasattr(self.object, "trombi_user"): kwargs["trombi_form"] = UserTrombiForm() if hasattr(self.object, "customer"): kwargs["student_card"] = StudentCardFormView.get_template_data(