-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reset settings and fix for AppConfig.ready #128
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
from django.apps import AppConfig | ||
from django.conf import settings | ||
from django.db.models.signals import post_migrate | ||
|
||
|
||
class ExtraSettingsConfig(AppConfig): | ||
|
@@ -10,6 +9,3 @@ class ExtraSettingsConfig(AppConfig): | |
|
||
def ready(self): | ||
from extra_settings import signals # noqa: F401 | ||
from extra_settings.models import Setting | ||
|
||
post_migrate.connect(Setting.set_defaults_from_settings, sender=self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this line current tests fail. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Command to reset extra settings. | ||
""" | ||
|
||
import logging | ||
|
||
from django.core.management import BaseCommand | ||
from extra_settings.models import Setting | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Django-command for refreshing extra settings to default values""" | ||
|
||
help = """ | ||
This command will remove all extra settings and recreate only those | ||
that described in `settings.EXTRA_SETTINGS_DEFAULTS`. | ||
""" | ||
|
||
def handle(self, *_, **__) -> None: | ||
""" | ||
Handle command. | ||
""" | ||
log.info("Start refreshing extra settings...") | ||
Setting.reset_to_default() | ||
log.info("Refreshing of extra settings is done.") |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that these tests are not enough and they don't cover well real usage, I try to explain better what I mean:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure that running this command before
migrate
on first install will raise anException
.