-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added command to reset settings to default, removed app ready hook
added button to admin page for reseting renamed method, added unit tests
- Loading branch information
Showing
10 changed files
with
148 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
26 changes: 26 additions & 0 deletions
26
extra_settings/management/commands/reset_extra_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
""" | ||
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.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends 'admin/change_list.html' %} | ||
{% load i18n admin_urls %} | ||
|
||
{% block object-tools-items %} | ||
{% if has_add_permission %} | ||
<li> | ||
<a href="{% url opts|admin_urlname:'reset' %}" class="historylink">{% translate "Reset settings" %}</a> | ||
</li> | ||
{% endif %} | ||
{{ block.super }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters