-
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: templates saving + fix date format (#514)
Signed-off-by: Trey <73353716+TreyWW@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
42 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
from django.views.decorators.http import require_GET | ||
from django.contrib import messages | ||
from django.shortcuts import render | ||
from django.views.decorators.http import require_POST | ||
|
||
from backend.core.service.defaults.get import get_account_defaults | ||
from backend.decorators import web_require_scopes | ||
from backend.core.types.requests import WebRequest | ||
|
||
|
||
@require_GET | ||
@web_require_scopes("email_templates:read") | ||
def get_current_email_template(request: WebRequest): ... | ||
@require_POST | ||
@web_require_scopes(["email_templates:write", "account_defaults:write"], True, True) | ||
def save_email_template(request: WebRequest, template: str): | ||
template = template.lower().strip() | ||
content = request.POST.get("content") | ||
|
||
if template not in ["invoice_created", "invoice_overdue", "invoice_cancelled"]: | ||
messages.error(request, f"Invalid template: {template}") | ||
return render(request, "base/toast.html") | ||
|
||
if content is None: | ||
messages.error(request, f"Missing content for template: {template}") | ||
return render(request, "base/toast.html") | ||
|
||
acc_defaults = get_account_defaults(request.actor) | ||
|
||
setattr(acc_defaults, f"email_template_recurring_invoices_{template}", content) | ||
|
||
acc_defaults.save() | ||
|
||
messages.success(request, f"Email template '{template}' saved successfully") | ||
|
||
return render(request, "base/toast.html") |
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