From 7afa9d2f4c10115cfce7b07b5a095ccaf9f52c0d Mon Sep 17 00:00:00 2001 From: "app@dynamicweb-production" Date: Fri, 9 Feb 2024 16:37:34 +0100 Subject: [PATCH 1/2] Show settings view for admin --- hosting/views.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 6b93fdb4..3ac8c023 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -554,14 +554,23 @@ class SettingsView(LoginRequiredMixin, FormView): Check if the user already saved contact details. If so, then show 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( - instance=self.request.user.billing_addresses.first(), + instance=user.billing_addresses.first(), **self.get_form_kwargs()) def get_context_data(self, **kwargs): context = super(SettingsView, self).get_context_data(**kwargs) # 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 if hasattr(user, 'stripecustomer'): stripe_customer = user.stripecustomer From 41461538a3c8480fb5650026ef3ce1fbead0f637 Mon Sep 17 00:00:00 2001 From: "app@dynamicweb-production" Date: Fri, 9 Feb 2024 16:38:10 +0100 Subject: [PATCH 2/2] Changes on prod --- .../commands/change_ch_vatrate_2023.py | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/hosting/management/commands/change_ch_vatrate_2023.py b/hosting/management/commands/change_ch_vatrate_2023.py index 46ca2312..612b246e 100644 --- a/hosting/management/commands/change_ch_vatrate_2023.py +++ b/hosting/management/commands/change_ch_vatrate_2023.py @@ -29,25 +29,25 @@ class Command(BaseCommand): logger.debug("VAT rate for %s is %s" % (country_to_change, vat_rate.rate)) logger.debug("vat_rate object = %s" % vat_rate) logger.debug("Create end date for the VATRate %s" % vat_rate.id) - if MAKE_MODIFS: - vat_rate.stop_date = datetime.date(2023, 12, 31) - vat_rate.save() - print("Creating a new VATRate for CH") - obj, created = VATRates.objects.get_or_create( - start_date=datetime.date(2024, 1, 1), - stop_date=None, - territory_codes=country_to_change, - currency_code=currency_to_change, - rate=new_rate, - rate_type="standard", - description="Switzerland standard VAT (added manually on %s)" % datetime.datetime.now() - ) - if created: - logger.debug("Created new VAT Rate for %s with the new rate %s" % (country_to_change, new_rate)) - logger.debug(obj) - else: - logger.debug("VAT Rate for %s already exists with the rate %s" % (country_to_change, new_rate)) - + # if MAKE_MODIFS: + # vat_rate.stop_date = datetime.date(2023, 12, 31) + # vat_rate.save() + # print("Creating a new VATRate for CH") + # obj, created = VATRates.objects.get_or_create( + # start_date=datetime.date(2024, 1, 1), + # stop_date=None, + # territory_codes=country_to_change, + # currency_code=currency_to_change, + # rate=new_rate, + # rate_type="standard", + # description="Switzerland standard VAT (added manually on %s)" % datetime.datetime.now() + # ) + # if created: + # logger.debug("Created new VAT Rate for %s with the new rate %s" % (country_to_change, new_rate)) + # logger.debug(obj) + # else: + # logger.debug("VAT Rate for %s already exists with the rate %s" % (country_to_change, new_rate)) + # logger.debug("Getting all subscriptions of %s that need a VAT Rate change") subscriptions = stripe.Subscription.list(limit=100) # Increase the limit to 100 per page (maximum) ch_subs = []