add make command to configure mobile app feature (#988)
Adds a make command, `enable-mobile-app-feature-flags`, which sets the backend feature flag in `./dev/.env.dev`, and updates a record in the `base_dynamicsetting` database table, which are needed to enable the mobile app backend features.
This commit is contained in:
parent
2b763f376e
commit
ed4be171f6
5 changed files with 63 additions and 0 deletions
|
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## v1.1.8 (2022-12-13)
|
## v1.1.8 (2022-12-13)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Added a `make` command, `enable-mobile-app-feature-flags`, which sets the backend feature flag in `./dev/.env.dev`,
|
||||||
|
and updates a record in the `base_dynamicsetting` database table, which are needed to enable the mobile
|
||||||
|
app backend features.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- removed APNS support
|
- removed APNS support
|
||||||
|
|
|
||||||
6
Makefile
6
Makefile
|
|
@ -126,6 +126,12 @@ engine-manage:
|
||||||
exec-engine:
|
exec-engine:
|
||||||
docker exec -it oncall_engine bash
|
docker exec -it oncall_engine bash
|
||||||
|
|
||||||
|
_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
|
# The below commands are useful for running backend services outside of docker
|
||||||
define backend_command
|
define backend_command
|
||||||
export `grep -v '^#' $(DEV_ENV_FILE) | xargs -0` && \
|
export `grep -v '^#' $(DEV_ENV_FILE) | xargs -0` && \
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,10 @@ 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.
|
# 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
|
# e.g. `make engine-manage CMD="makemigrations"` - https://docs.djangoproject.com/en/4.1/ref/django-admin/#django-admin-makemigrations
|
||||||
make engine-manage CMD="..."
|
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
|
||||||
|
|
||||||
# this will remove all of the images, containers, volumes, and networks
|
# this will remove all of the images, containers, volumes, and networks
|
||||||
# associated with your local OnCall developer setup
|
# associated with your local OnCall developer setup
|
||||||
|
|
|
||||||
26
dev/add_env_var.sh
Executable file
26
dev/add_env_var.sh
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# https://gist.github.com/maxpoletaev/4ed25183427a2cd7e57a
|
||||||
|
|
||||||
|
case "$OSTYPE" in
|
||||||
|
darwin*) PLATFORM="OSX" ;;
|
||||||
|
linux*) PLATFORM="LINUX" ;;
|
||||||
|
bsd*) PLATFORM="BSD" ;;
|
||||||
|
*) PLATFORM="UNKNOWN" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
replace() {
|
||||||
|
if [[ "$PLATFORM" == "OSX" || "$PLATFORM" == "BSD" ]]; then
|
||||||
|
sed -i "" "$1" "$2"
|
||||||
|
elif [ "$PLATFORM" == "LINUX" ]; then
|
||||||
|
sed -i "$1" "$2"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if grep -q $1 $3; then
|
||||||
|
# file contains string, lets replace it
|
||||||
|
# https://stackoverflow.com/a/42667816 - why we need the -i ''
|
||||||
|
replace "s~$1=.*~$1=$2~g" $3
|
||||||
|
else
|
||||||
|
# file doesn't contain string, lets append it
|
||||||
|
echo "$1=$2" >> $3
|
||||||
|
fi
|
||||||
21
engine/engine/management/commands/enable_mobile_app.py
Normal file
21
engine/engine/management/commands/enable_mobile_app.py
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
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