def ready(self): from django.conf import settings settings = settings._wrapped.__dict__ settings.setdefault('JIRA_RELEASE_FIELD_MAP', self.DEFAULT_JIRA_RELEASE_FIELD_MAP) settings.setdefault( 'FILE_CLEAN_UP_PREFIX', self.get_env_variable("FILE_CLEAN_UP_PREFIX", "hybris/bin/custom"))
def app_with_scout(**settings): """ Context manager that simply overrides settings. Unlike the other web frameworks, Django is a singleton application, so we can't smoothly uninstall and reinstall scout per test. """ settings.setdefault("SCOUT_MONITOR", True) settings["SCOUT_CORE_AGENT_LAUNCH"] = False with override_settings(**settings): # Have to create a new WSGI app each time because the middleware stack # within it is static yield get_wsgi_application()
def app_with_scout(**settings): """ Context manager that simply overrides settings. Unlike the other web frameworks, Django is a singleton application, so we can't smoothly uninstall and reinstall scout per test. """ settings.setdefault("SCOUT_MONITOR", True) settings["SCOUT_CORE_AGENT_LAUNCH"] = False with override_settings(**settings): # Have to create a new WSGI app each time because the middleware stack # within it is static app = get_wsgi_application() # Run Django checks on first use if not getattr(app_with_scout, "startup_ran", False): call_command("migrate") call_command("check") app_with_scout.startup_ran = True yield app
def localize_users_to_org(org, users, sort=False): # Set cached state for when the users are viewed from a particular Organization. # For each user, set: # * user_settings_task, which holds the account project's settings Task, if created # * user_settings_dict, which holds that Task's current answers as a dict, if the Task was created # * can_see_org_settings, which holds whether the user is in the org's organization project org_members = org.get_organization_project().get_members() if len(users) > 1: org_members = set(org_members) # pre-load # Get the account projects of all of the users in batch. account_project_root_tasks = { } for pm in ProjectMembership.objects.filter( user__in=users, project__organization=org, project__is_account_project=True)\ .select_related("project", "project__root_task", "project__root_task__module"): account_project_root_tasks[pm.user] = pm.project.root_task # Get the account_settings answer object for all of the account projects in batch. # Load all TaskAnswerHistory objects that answer the "account_settings" question # in each account project. This gives us the whole history of answers. Take the # most recent (reverse sort + take first) for each project. from guidedmodules.models import TaskAnswerHistory account_project_settings = { } for ansh in TaskAnswerHistory.objects\ .filter( taskanswer__task__in=account_project_root_tasks.values(), taskanswer__question__key="account_settings", )\ .select_related("taskanswer__task__module", "taskanswer__question", "answered_by")\ .prefetch_related("answered_by_task__module__questions")\ .order_by('-id'): account_project_settings.setdefault( ansh.taskanswer.task, ansh.answered_by_task.first() ) # Get all of the current answers for the settings tasks. from guidedmodules.models import Task settings = { } for task, question, answer in Task.get_all_current_answer_records(account_project_settings.values()): settings.setdefault(task, {})[question.key] = (answer.get_value() if answer else None) # Set attributes on each user instance. for user in users: user.localized_to = org user.user_settings_task = account_project_settings.get(account_project_root_tasks.get(user)) user.user_settings_task_answers = settings.get(user.user_settings_task, None) user.can_see_org_settings = (user in org_members) # Apply a standard sort. if sort: users.sort(key = lambda user : user.name_and_email())
def ready(self): from django.conf import settings settings = settings._wrapped.__dict__ settings.setdefault( 'JIRA_SERVER', self.get_env_variable_with_exception("JIRA_SERVER")) settings.setdefault( 'JIRA_USERNAME', self.get_env_variable_with_exception("JIRA_USERNAME")) settings.setdefault( 'JIRA_PASSWORD', self.get_env_variable_with_exception("JIRA_PASSWORD")) settings.setdefault('JIRA_PROJECT_IDS', ['TBC'])
def ready(self): from django.conf import settings settings = settings._wrapped.__dict__ settings.setdefault( "CANTO_OAUTH_URL", "https://oauth.canto.com:8443/oauth/api/oauth2/authorize") settings.setdefault( "CANTO_OAUTH_TOKEN_URL", "https://oauth.canto.com:8443/oauth/api/oauth2/token", ) settings.setdefault("CANTO_FILTER_SCHEMES", "") # eg image or image|video if not settings.get("CANTO_API_URL"): raise ImproperlyConfigured("setting CANTO_API_URL is required.") if not settings.get("CANTO_APP_ID"): raise ImproperlyConfigured("setting CANTO_APP_ID is required.") if not settings.get("CANTO_APP_SECRET"): raise ImproperlyConfigured("setting CANTO_APP_SECRET is required.")
def ready(self): from django.conf import settings settings = settings._wrapped.__dict__ settings.setdefault('GROUP_SYNC_FILENAME', 'groups_permissions.json')
def ready(self): from django.conf import settings settings = settings._wrapped.__dict__ # set to True if you want to force use sync instead # this can be useful if you don't want to set up Cloud Tasks # and your project is simple enough that you don't need long running # tasks settings.setdefault('DATA_SYNC_FORCE_SYNC', False) settings.setdefault('DATA_SYNC_CLOUD_TASKS_QUEUE_ID', 'data-sync') settings.setdefault('DATA_SYNC_CLOUD_TASKS_LOCATION', 'europe-west1') settings.setdefault('DATA_SYNC_GOOGLE_CLOUD_PROJECT', os.getenv('GOOGLE_CLOUD_PROJECT', '')) # noqa settings.setdefault('DATA_SYNC_GAE_VERSION', os.getenv('GAE_VERSION', '')) # noqa settings.setdefault('DATA_SYNC_GAE_SERVICE', os.getenv('GAE_SERVICE')), settings.setdefault('DATA_SYNC_SERVICE_ACCOUNT_EMAIL', os.getenv('DATA_SYNC_SERVICE_ACCOUNT_EMAIL', '')) # noqa