Show settings view for admin

This commit is contained in:
app@dynamicweb-production 2024-02-09 16:37:34 +01:00
parent 2e335fc574
commit 7afa9d2f4c
1 changed files with 11 additions and 2 deletions

View File

@ -554,14 +554,23 @@ class SettingsView(LoginRequiredMixin, FormView):
Check if the user already saved contact details. If so, then show Check if the user already saved contact details. If so, then show
the form populated with those details, to let user change them. the form populated with those details, to let user change them.
""" """
username = self.request.GET.get('username')
if self.request.user.is_admin and username:
user = CustomUser.objects.get(username=username)
else:
user = self.request.user
return form_class( return form_class(
instance=self.request.user.billing_addresses.first(), instance=user.billing_addresses.first(),
**self.get_form_kwargs()) **self.get_form_kwargs())
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(SettingsView, self).get_context_data(**kwargs) context = super(SettingsView, self).get_context_data(**kwargs)
# Get user # Get user
user = self.request.user username = self.request.GET.get('username')
if self.request.user.is_admin and username:
user = CustomUser.objects.get(username=username)
else:
user = self.request.user
stripe_customer = None stripe_customer = None
if hasattr(user, 'stripecustomer'): if hasattr(user, 'stripecustomer'):
stripe_customer = user.stripecustomer stripe_customer = user.stripecustomer