Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README-docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@
```bash
docker compose run --rm web python3 -m scripts.parse_citation_styles
```
- Populate Notification Types
- Needed for notifications.
```bash
docker compose run --rm web python3 manage.py populate_notification_types
```
- _NOTE: The waffle switch `POPULATE_NOTIFICATION_TYPES` needs to be turned on.
- Start ember_osf_web
- Needed for ember app:
- `docker-compose up -d ember_osf_web`
Expand Down
1 change: 1 addition & 0 deletions osf/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ def ready(self):
)
post_migrate.connect(
populate_notification_types,
sender=self, # run only once
dispatch_uid='osf.apps.populate_notification_types'
)
5 changes: 5 additions & 0 deletions osf/features.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,8 @@ switches:
name: enable_no_login_emails
note: This is used to enable no-login email reminders to users who have not logged in for a specified period.
active: true

- flag_name: POPULATE_NOTIFICATION_TYPES
name: populate_notification_types
note: This is used to enable auto population of notification types.
active: false
9 changes: 9 additions & 0 deletions osf/management/commands/populate_notification_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import sys
import yaml
from django.apps import apps
from waffle import switch_is_active
from osf import features

from django.db.utils import ProgrammingError
from website import settings
Expand All @@ -17,6 +20,11 @@
}

def populate_notification_types(*args, **kwargs):
if not switch_is_active(features.POPULATE_NOTIFICATION_TYPES):
if 'pytest' not in sys.modules:
logger.info('POPULATE_NOTIFICATION_TYPES switch is off; skipping population of notification types.')
return
logger.info('Populating notification types...')
from django.contrib.contenttypes.models import ContentType
from osf.models.notification_type import NotificationType
try:
Expand Down Expand Up @@ -71,6 +79,7 @@ def populate_notification_types(*args, **kwargs):
nt.save()
except ProgrammingError:
logger.info('Notification types failed potential side effect of reverse migration')
logger.info('Finished populating notification types.')


class Command(BaseCommand):
Expand Down
Loading