From 943ac4096b8f990ea494280713e641d7ab6d0bcd Mon Sep 17 00:00:00 2001 From: Hasnain Date: Tue, 6 Feb 2018 16:37:40 +0500 Subject: [PATCH] Changing the service users for default clients. --- .../create_sites_and_configurations.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py index 58ba3eddaf..7c8dacb6ae 100644 --- a/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py +++ b/openedx/core/djangoapps/theming/management/commands/create_sites_and_configurations.py @@ -117,6 +117,32 @@ class Command(BaseCommand): checkout_on_ecommerce_service=True ) + def _update_default_clients(self): + """ + These two clients is being created by default without service + users so we have to associate the service users to them. + """ + ecommerce_queryset = Client.objects.filter( + redirect_uri="https://ecommerce-{dns_name}.sandbox.edx.org/complete/edx-oidc/".format( + dns_name=self.dns_name + ) + ) + + if ecommerce_queryset: + ecommerce_client = ecommerce_queryset[0] + ecommerce_client.user = self.ecommerce_user + ecommerce_client.save() + + discovery_queryset = Client.objects.filter( + redirect_uri="https://discovery-{dns_name}.sandbox.edx.org/complete/edx-oidc/".format( + dns_name=self.dns_name + ) + ) + if discovery_queryset: + discovery_client = discovery_queryset[0] + discovery_client.user = self.discovery_user + discovery_client.save() + def _get_sites_data(self): """ Reads the json files from theme directory and returns the site data in JSON format. @@ -174,6 +200,7 @@ class Command(BaseCommand): self.ecommerce_user = self.get_or_create_service_user("ecommerce_worker") all_sites = self._get_sites_data() + self._update_default_clients() # creating Sites, SiteThemes, SiteConfigurations and oauth2 clients for site_name, site_data in all_sites.items():