Skip to content

Commit

Permalink
Merge branch 'feature/django_upgrade' of https://github.com/CenterFor…
Browse files Browse the repository at this point in the history
…OpenScience/osf.io into upguard-indexes

* 'feature/django_upgrade' of https://github.com/CenterForOpenScience/osf.io:
  [ENG-3867] Create Storage Regions on post migration signal (CenterForOpenScience#9965)

# Conflicts:
#	osf/migrations/__init__.py
  • Loading branch information
John Tordoff committed Jul 22, 2022
2 parents 3000c8d + 65b0360 commit 8905777
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
6 changes: 6 additions & 0 deletions osf/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
update_blocked_email_domains,
update_license,
update_permission_groups,
update_storage_regions,
update_waffle_flags,
)

Expand Down Expand Up @@ -53,3 +54,8 @@ def ready(self):
update_blocked_email_domains,
dispatch_uid='osf.apps.update_blocked_email_domains'
)

post_migrate.connect(
update_storage_regions,
dispatch_uid='osf.apps.update_storage_regions'
)
1 change: 0 additions & 1 deletion osf/migrations/0099_add_default_storage_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,4 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunPython(add_osfstorage_addon, remove_osfstorage_addon),
]
30 changes: 15 additions & 15 deletions osf/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

from django.db.utils import ProgrammingError
from website.settings import APP_PATH
from addons.osfstorage.settings import DEFAULT_REGION_ID, DEFAULT_REGION_NAME

from django.apps import apps
from website import settings

from django.core.management import call_command

from addons.osfstorage.settings import DEFAULT_REGION_ID, DEFAULT_REGION_NAME
from osf.management.commands.manage_switch_flags import manage_waffle
from osf.utils.migrations import ensure_schemas, map_schemas_to_schemablocks
from website import settings as osf_settings
Expand Down Expand Up @@ -169,20 +169,6 @@ def update_storage_regions(sender, verbosity=0, **kwargs):
ensure_default_storage_region()


def ensure_default_storage_region():
osfstorage_config = apps.get_app_config('addons_osfstorage')
Region = apps.get_model('addons_osfstorage', 'Region')
Region.objects.update_or_create(
_id=DEFAULT_REGION_ID,
defaults={
'name': DEFAULT_REGION_NAME,
'waterbutler_credentials': osfstorage_config.WATERBUTLER_CREDENTIALS,
'waterbutler_settings': osfstorage_config.WATERBUTLER_SETTINGS,
'waterbutler_url': settings.WATERBUTLER_URL
}
)


def ensure_subjects():
Subject = apps.get_model('osf.subject')
PreprintProvider = apps.get_model('osf.preprintprovider')
Expand Down Expand Up @@ -275,3 +261,17 @@ def update_blocked_email_domains(sender, verbosity=0, **kwargs):
domain=domain,
defaults={'note': NotableEmailDomain.Note.EXCLUDE_FROM_ACCOUNT_CREATION},
)


def ensure_default_storage_region():
osfstorage_config = apps.get_app_config('addons_osfstorage')
Region = apps.get_model('addons_osfstorage', 'Region')
Region.objects.get_or_create(
_id=DEFAULT_REGION_ID,
name=DEFAULT_REGION_NAME,
defaults={
'waterbutler_credentials': osfstorage_config.WATERBUTLER_CREDENTIALS,
'waterbutler_settings': osfstorage_config.WATERBUTLER_SETTINGS,
'waterbutler_url': osf_settings.WATERBUTLER_URL
}
)
1 change: 1 addition & 0 deletions website/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,4 +2108,5 @@ def from_node_usage(cls, usage_bytes, private_limit=None, public_limit=None):
CAS_LOG_LEVEL = 3 # ERROR

PREPRINT_METRICS_START_DATE = datetime.datetime(2019, 1, 1)

WAFFLE_VALUES_YAML = 'osf/features.yaml'

0 comments on commit 8905777

Please sign in to comment.