Remove mobile_app_settings DynamicSetting (#1268)
# What this PR does Remove checks for `mobile_app_settings` DynamicSetting, so changing `FEATURE_MOBILE_APP_INTEGRATION_ENABLED` is enough for toggling the mobile app backend (aka remove per-org feature flag) Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
This commit is contained in:
parent
3f6e6168a8
commit
08dbab73d2
5 changed files with 1 additions and 55 deletions
6
Makefile
6
Makefile
|
|
@ -137,12 +137,6 @@ _backend-debug-disable:
|
|||
backend-debug-enable: _backend-debug-enable stop start
|
||||
backend-debug-disable: _backend-debug-disable stop start
|
||||
|
||||
_enable-mobile-app-feature-flags:
|
||||
$(shell ./dev/add_env_var.sh FEATURE_MOBILE_APP_INTEGRATION_ENABLED True $(DEV_ENV_FILE))
|
||||
$(call run_engine_docker_command,python manage.py enable_mobile_app)
|
||||
|
||||
enable-mobile-app-feature-flags: _enable-mobile-app-feature-flags stop start
|
||||
|
||||
# The below commands are useful for running backend services outside of docker
|
||||
define backend_command
|
||||
export `grep -v '^#' $(DEV_ENV_FILE) | xargs -0` && \
|
||||
|
|
|
|||
|
|
@ -150,10 +150,6 @@ make build # rebuild images (e.g. when changing requirements.txt)
|
|||
# run Django's `manage.py` script, inside of a docker container, passing `$CMD` as arguments.
|
||||
# e.g. `make engine-manage CMD="makemigrations"` - https://docs.djangoproject.com/en/4.1/ref/django-admin/#django-admin-makemigrations
|
||||
make engine-manage CMD="..."
|
||||
# sets a feature flag, related to mobile app backend functionality, in your ./dev/.env.dev
|
||||
# and sets the necessary database values
|
||||
# NOTE: you need to enable, and configure, the plugin before running this command
|
||||
make enable-mobile-app-feature-flags
|
||||
|
||||
make backend-debug-enable # enable Django's debug mode and Silk profiling (this is disabled by default for performance reasons)
|
||||
make backend-debug-disable # disable Django's debug mode and Silk profiling
|
||||
|
|
|
|||
|
|
@ -37,17 +37,7 @@ class FeaturesAPIView(APIView):
|
|||
enabled_features.append(FEATURE_TELEGRAM)
|
||||
|
||||
if settings.FEATURE_MOBILE_APP_INTEGRATION_ENABLED:
|
||||
mobile_app_settings = DynamicSetting.objects.get_or_create(
|
||||
name="mobile_app_settings",
|
||||
defaults={
|
||||
"json_value": {
|
||||
"org_ids": [],
|
||||
}
|
||||
},
|
||||
)[0]
|
||||
|
||||
if request.auth.organization.pk in mobile_app_settings.json_value["org_ids"]:
|
||||
enabled_features.append(MOBILE_APP_PUSH_NOTIFICATIONS)
|
||||
enabled_features.append(MOBILE_APP_PUSH_NOTIFICATIONS)
|
||||
|
||||
if settings.OSS_INSTALLATION:
|
||||
# Features below should be enabled only in OSS
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from django.conf import settings
|
|||
from fcm_django.models import FCMDevice
|
||||
|
||||
from apps.base.messaging import BaseMessagingBackend
|
||||
from apps.base.models import DynamicSetting
|
||||
from apps.mobile_app.tasks import notify_user_async
|
||||
|
||||
|
||||
|
|
@ -51,18 +50,6 @@ class MobileAppBackend(BaseMessagingBackend):
|
|||
critical=critical,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def is_enabled_for_organization(organization):
|
||||
# Setting FEATURE_MOBILE_APP_INTEGRATION_ENABLED to True is enough to enable mobile app on OSS instances
|
||||
if settings.LICENSE == settings.OPEN_SOURCE_LICENSE_NAME:
|
||||
return True
|
||||
|
||||
mobile_app_settings, _ = DynamicSetting.objects.get_or_create(
|
||||
name="mobile_app_settings", defaults={"json_value": {"org_ids": []}}
|
||||
)
|
||||
|
||||
return organization.pk in mobile_app_settings.json_value["org_ids"]
|
||||
|
||||
|
||||
class MobileAppCriticalBackend(MobileAppBackend):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from apps.base.models.dynamic_setting import DynamicSetting
|
||||
from apps.user_management.models.organization import Organization
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
note = "Note: you will also need to set the appropriate environment variables in your ./dev/.env.dev file."
|
||||
help = f"Handles the database portion of enabling the mobile app related features. {note}"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
org = Organization.objects.first()
|
||||
|
||||
if not org:
|
||||
raise CommandError("No organization exists. Have you enabled, and configured, the plugin?")
|
||||
|
||||
DynamicSetting.objects.update_or_create(
|
||||
name="mobile_app_settings", defaults={"json_value": {"org_ids": [org.pk]}}
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f"Mobile app successfully enabled."))
|
||||
Loading…
Add table
Reference in a new issue