-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added management commands for list setting and confirm settings
- Loading branch information
1 parent
375e399
commit bac843a
Showing
7 changed files
with
283 additions
and
48 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
Empty file.
Empty file.
35 changes: 35 additions & 0 deletions
35
django_project_base/management/commands/confirm_setting.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,35 @@ | ||
import swapper | ||
from django.core.management.base import BaseCommand | ||
from django.shortcuts import get_object_or_404 | ||
|
||
from django_project_base.base.event import ProjectSettingConfirmedEvent | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Confirms project setting. Example: python manage.py confirm_setting 2 email-sender-id" | ||
|
||
def add_arguments(self, parser) -> None: | ||
parser.add_argument("project-id", type=str, help="Project identifier") | ||
parser.add_argument("setting-name", type=str, help="Setting name") | ||
|
||
def handle(self, *args, **options): | ||
project = get_object_or_404(swapper.load_model("django_project_base", "Project"), pk=str(options["project-id"])) | ||
setting = get_object_or_404( | ||
swapper.load_model("django_project_base", "ProjectSettings"), | ||
project=project, | ||
name=str(options["setting-name"]), | ||
) | ||
ProjectSettingConfirmedEvent(user=None).trigger(payload=setting) | ||
# TODO: send email when owner is known | ||
# SystemEMailNotification( | ||
# message=DjangoProjectBaseMessage( | ||
# subject=f"{__('Project setting confirmed')}", | ||
# body=f"{__('Setting')} {setting.name} {__('in project')} " | ||
# f"{project.name} {__('has been confirmed and is now active.')}", | ||
# footer="", | ||
# content_type=DjangoProjectBaseMessage.PLAIN_TEXT, | ||
# ), | ||
# recipients=[], # TODO: find project owner | ||
# user=None, # TODO: find project owner | ||
# ).send() | ||
return "ok" |
34 changes: 34 additions & 0 deletions
34
django_project_base/management/commands/list_pending_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,34 @@ | ||
import swapper | ||
from django.core.management.base import BaseCommand | ||
from django.shortcuts import get_object_or_404 | ||
|
||
from django_project_base.base.event import ProjectSettingConfirmedEvent | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Lists pending project settings. Example: python manage.py list_pending_settings 2" | ||
|
||
def add_arguments(self, parser) -> None: | ||
parser.add_argument("project-id", type=str, help="Project identifier") | ||
|
||
def handle(self, *args, **options): | ||
project = get_object_or_404(swapper.load_model("django_project_base", "Project"), pk=str(options["project-id"])) | ||
setting = get_object_or_404( | ||
swapper.load_model("django_project_base", "ProjectSettings"), | ||
project=project, | ||
name=str(options["setting-name"]), | ||
) | ||
ProjectSettingConfirmedEvent(user=None).trigger(payload=setting) | ||
# TODO: send email when owner is known | ||
# SystemEMailNotification( | ||
# message=DjangoProjectBaseMessage( | ||
# subject=f"{__('Project setting confirmed')}", | ||
# body=f"{__('Setting')} {setting.name} {__('in project')} " | ||
# f"{project.name} {__('has been confirmed and is now active.')}", | ||
# footer="", | ||
# content_type=DjangoProjectBaseMessage.PLAIN_TEXT, | ||
# ), | ||
# recipients=[], # TODO: find project owner | ||
# user=None, # TODO: find project owner | ||
# ).send() | ||
return "ok" |
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
Oops, something went wrong.