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-3868] Move blocked email domains to post-migrate signal (CenterForOpenScience#9958)

# Conflicts:
#	osf/apps.py
  • Loading branch information
John Tordoff committed Jul 14, 2022
2 parents 952c479 + fc4c982 commit 7d93e52
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/nodes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ class DraftRegistrationLegacySerializer(JSONAPISerializer):
related_view='schemas:registration-schema-detail',
related_view_kwargs={'schema_id': '<registration_schema._id>'},
read_only=False,
required=True
required=True,
)

provider = RegistrationProviderRelationshipField(
Expand Down
10 changes: 8 additions & 2 deletions osf/apps.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import logging

from django.apps import AppConfig as BaseAppConfig
from django.db.models.signals import post_migrate

logger = logging.getLogger(__file__)
from osf.migrations import (
update_waffle_flags,
update_storage_regions,
update_blocked_email_domains,
update_subjects,
update_default_providers,
update_permission_groups,
update_license,
update_permission_groups,
update_waffle_flags,
add_registration_schemas
)

Expand Down Expand Up @@ -63,3 +64,8 @@ def ready(self):
add_registration_schemas,
dispatch_uid='osf.apps.add_registration_schemas'
)

post_migrate.connect(
update_blocked_email_domains,
dispatch_uid='osf.apps.update_blocked_email_domains'
)
3 changes: 3 additions & 0 deletions osf/migrations/0136_preprint_node_divorce.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

logger = logging.getLogger(__name__)


def reverse_func(apps, schema_editor):
PreprintContributor = apps.get_model('osf', 'PreprintContributor')
PreprintTags = apps.get_model('osf', 'Preprint_Tags')
Expand Down Expand Up @@ -83,8 +84,10 @@ def reverse_func(apps, schema_editor):
modified_field.auto_now = True
node_modified_field.auto_now = True


group_format = 'preprint_{self.id}_{group}'


def format_group(self, name):
return group_format.format(self=self, group=name)

Expand Down
12 changes: 12 additions & 0 deletions osf/migrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from api.base import settings as api_settings
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

logger = logging.getLogger(__file__)

Expand Down Expand Up @@ -265,3 +266,14 @@ def add_registration_schemas(sender, verbosity=0, **kwargs):
if getattr(sender, 'label', None) == 'osf':
ensure_schemas()
map_schemas_to_schemablocks()


def update_blocked_email_domains(sender, verbosity=0, **kwargs):
if getattr(sender, 'label', None) == 'osf':
from django.apps import apps
NotableEmailDomain = apps.get_model('osf', 'NotableEmailDomain')
for domain in osf_settings.BLACKLISTED_DOMAINS:
NotableEmailDomain.objects.update_or_create(
domain=domain,
defaults={'note': NotableEmailDomain.Note.EXCLUDE_FROM_ACCOUNT_CREATION},
)
1 change: 0 additions & 1 deletion osf_tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,6 @@ def _create(cls, *args, **kwargs):
registration = kwargs.pop('registration', RegistrationFactory())
registration.is_public = True
user = kwargs.pop('user', registration.creator)

registration.retract_registration(user)
registration.save()
withdrawal = registration.retraction
Expand Down

0 comments on commit 7d93e52

Please sign in to comment.