def _needs_upgrade(): version_configured = options.get('sentry:version-configured') if not version_configured: # If we were never previously upgraded (being a new install) # we want to force an upgrade, even if the values are set. return True smtp_disabled = not is_smtp_enabled() # Check all required options to see if they've been set for key in options.filter(flag=options.FLAG_REQUIRED): # ignore required flags which can be empty if key.flags & options.FLAG_ALLOW_EMPTY: continue # Ignore mail.* keys if smtp is disabled if smtp_disabled and key.name[:5] == 'mail.': continue if not options.isset(key.name): return True if version_configured != sentry.get_version(): # Everything looks good, but version changed, so let's bump it options.set('sentry:version-configured', sentry.get_version()) return False
def get(self, request): query = request.GET.get('query') if query == 'is:required': option_list = options.filter(flag=options.FLAG_REQUIRED) elif query: return Response('{} is not a supported search query'.format(query), status=400) else: option_list = options.all() smtp_disabled = not is_smtp_enabled() results = {} for k in option_list: disabled, disabled_reason = False, None if smtp_disabled and k.name[:5] == 'mail.': disabled_reason, disabled = 'smtpDisabled', True elif bool(k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)): # TODO(mattrobenolt): Expose this as a property on Key. disabled_reason, disabled = 'diskPriority', True # TODO(mattrobenolt): help, placeholder, title, type results[k.name] = { 'value': options.get(k.name), 'field': { 'default': k.default(), 'required': bool(k.flags & options.FLAG_REQUIRED), 'disabled': disabled, 'disabledReason': disabled_reason, 'isSet': options.isset(k.name), 'allowEmpty': bool(k.flags & options.FLAG_ALLOW_EMPTY), } } return Response(results)
def get(self, request): query = request.GET.get('query') if query == 'is:required': option_list = options.filter(flag=options.FLAG_REQUIRED) elif query: raise ValueError('{} is not a supported search query'.format(query)) else: option_list = options.all() results = {} for k in option_list: # TODO(mattrobenolt): Expose this as a property on Key. diskPriority = bool(k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)) # TODO(mattrobenolt): help, placeholder, title, type results[k.name] = { 'value': options.get(k.name), 'field': { 'default': k.default, 'required': bool(k.flags & options.FLAG_REQUIRED), # We're disabled if the disk has taken priority 'disabled': diskPriority, 'disabledReason': 'diskPriority' if diskPriority else None, } } return Response(results)
def get(self, request): query = request.GET.get('query') if query == 'is:required': option_list = options.filter(flag=options.FLAG_REQUIRED) elif query: return Response('{} is not a supported search query'.format(query), status=400) else: option_list = options.all() results = {} for k in option_list: # TODO(mattrobenolt): Expose this as a property on Key. diskPriority = bool(k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)) # TODO(mattrobenolt): help, placeholder, title, type results[k.name] = { 'value': options.get(k.name), 'field': { 'default': k.default(), 'required': bool(k.flags & options.FLAG_REQUIRED), # We're disabled if the disk has taken priority 'disabled': diskPriority, 'disabledReason': 'diskPriority' if diskPriority else None, } } return Response(results)
def get(self, request): results = { k.name: { 'value': options.get(k.name), 'field': { 'default': k.default, 'required': True, # TODO(mattrobenolt): help, placeholder, title, type }, } for k in options.filter(flag=options.FLAG_REQUIRED) } return Response(results)
def _needs_upgrade(): version_configured = options.get('sentry:version-configured') if not version_configured: # If we were never previously upgraded (being a new install) # we want to force an upgrade, even if the values are set. return True # Check all required options to see if they've been set for key in options.filter(flag=options.FLAG_REQUIRED): if not options.get(key.name): return True if version_configured != sentry.get_version(): # Everything looks good, but version changed, so let's bump it options.set('sentry:version-configured', sentry.get_version()) return False
def get(self, request): query = request.GET.get('query') if query == 'is:required': option_list = options.filter(flag=options.FLAG_REQUIRED) elif query: return Response('{} is not a supported search query'.format(query), status=400) else: option_list = options.all() # This is a fragile, hardcoded list of mail backends, but the likelihood of # someone using something custom here is slim, and even if they did, the worst # is they'd be prompted for SMTP information. These backends are guaranteed # to not need SMTP information. smtp_disabled = get_mail_backend() in ( 'django.core.mail.backends.dummy.EmailBackend', 'django.core.mail.backends.console.EmailBackend', 'django.core.mail.backends.locmem.EmailBackend', 'django.core.mail.backends.filebased.EmailBackend', 'sentry.utils.email.PreviewBackend', ) results = {} for k in option_list: disabled, disabled_reason = False, None if smtp_disabled and k.name[:5] == 'mail.': disabled_reason, disabled = 'smtpDisabled', True elif bool(k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)): # TODO(mattrobenolt): Expose this as a property on Key. disabled_reason, disabled = 'diskPriority', True # TODO(mattrobenolt): help, placeholder, title, type results[k.name] = { 'value': options.get(k.name), 'field': { 'default': k.default(), 'required': bool(k.flags & options.FLAG_REQUIRED), 'disabled': disabled, 'disabledReason': disabled_reason, 'isSet': options.isset(k.name), 'allowEmpty': bool(k.flags & options.FLAG_ALLOW_EMPTY), } } return Response(results)
def get(self, request): results = {} for k in options.filter(flag=options.FLAG_REQUIRED): # TODO(mattrobenolt): Expose this as a property on Key. diskPriority = bool(k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)) # TODO(mattrobenolt): help, placeholder, title, type results[k.name] = { 'value': options.get(k.name), 'field': { 'default': k.default, 'required': bool(k.flags & options.FLAG_REQUIRED), # We're disabled if the disk has taken priority 'disabled': diskPriority, 'disabledReason': 'diskPriority' if diskPriority else None, } } return Response(results)
def get(self, request): query = request.GET.get("query") if query == "is:required": option_list = options.filter(flag=options.FLAG_REQUIRED) elif query: return Response( u"{} is not a supported search query".format(query), status=400) else: option_list = options.all() smtp_disabled = not is_smtp_enabled() results = {} for k in option_list: disabled, disabled_reason = False, None if smtp_disabled and k.name[:5] == "mail.": disabled_reason, disabled = "smtpDisabled", True elif bool(k.flags & options.FLAG_PRIORITIZE_DISK and settings.SENTRY_OPTIONS.get(k.name)): # TODO(mattrobenolt): Expose this as a property on Key. disabled_reason, disabled = "diskPriority", True # TODO(mattrobenolt): help, placeholder, title, type results[k.name] = { "value": options.get(k.name), "field": { "default": k.default(), "required": bool(k.flags & options.FLAG_REQUIRED), "disabled": disabled, "disabledReason": disabled_reason, "isSet": options.isset(k.name), "allowEmpty": bool(k.flags & options.FLAG_ALLOW_EMPTY), }, } return Response(results)