mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
return 404 when accessing not existing account
This commit is contained in:
@ -632,6 +632,12 @@ class UserAccountBase(UserTabsMixin, DetailView):
|
||||
return super().dispatch(request, *arg, **kwargs)
|
||||
raise PermissionDenied
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
obj = super().get_object(queryset)
|
||||
if not hasattr(obj, "customer"):
|
||||
raise Http404(_("User has no account"))
|
||||
return obj
|
||||
|
||||
|
||||
class UserAccountView(UserAccountBase):
|
||||
"""Display a user's account."""
|
||||
@ -671,11 +677,6 @@ class UserAccountDetailView(UserAccountBase, YearMixin, MonthMixin):
|
||||
|
||||
template_name = "core/user_account_detail.jinja"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if not hasattr(self.get_object(), "customer"):
|
||||
raise Http404(_("This user has no account"))
|
||||
return super().get(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs = super().get_context_data(**kwargs)
|
||||
kwargs["profile"] = self.object
|
||||
|
Reference in New Issue
Block a user