-
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.
* addes todos * saving * saving * added management commands for list setting and confirm settings * saving * confirm setting active * added issue as todo * clean aws sender records
- Loading branch information
1 parent
69efef6
commit 30eab3e
Showing
10 changed files
with
617 additions
and
16 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
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions
36
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,36 @@ | ||
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 | ||
# # TODO: SEND THIS AS SYSTEM MSG WHEN PR IS MERGED | ||
# 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" |
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
import swapper | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Lists pending project settings. Example: python manage.py list_pending_settings" | ||
|
||
def handle(self, *args, **options): | ||
result = dict() | ||
for project in swapper.load_model("django_project_base", "Project").objects.all(): | ||
for setting in ( | ||
swapper.load_model("django_project_base", "ProjectSettings") | ||
.objects.filter(project=project, pending_value__isnull=False) | ||
.exclude(pending_value="") | ||
): | ||
if project.name not in result: | ||
result[project.name] = {} | ||
result[project.name][setting.name] = { | ||
"value": setting.python_value, | ||
"pending_value": setting.python_pending_value, | ||
} | ||
# if to := getattr(settings, "ADMINS", getattr(settings, "MANAGERS", [])): | ||
# # TODO: SEND THIS AS SYSTEM MSG WHEN PR IS MERGED | ||
# EMailNotificationWithListOfEmails( | ||
# message=DjangoProjectBaseMessage( | ||
# subject=_("Pending settings report"), | ||
# body=json.dumps(result), | ||
# footer="", | ||
# content_type=DjangoProjectBaseMessage.HTML, | ||
# ), | ||
# recipients=to, | ||
# project=None, | ||
# user=None, | ||
# ).send() | ||
self.stdout.write(self.style.WARNING(result)) |
Oops, something went wrong.