v2.1: settings SMS fields + HD Ticket/Contact/Lead form JS: voxtelesys_settings.py
This commit is contained in:
parent
877eaa0ec1
commit
4d7e30a6a5
1 changed files with 17 additions and 7 deletions
|
|
@ -1,5 +1,9 @@
|
|||
"""
|
||||
Voxtelesys Settings - Single DocType controller.
|
||||
Voxtelesys Settings — Single DocType controller.
|
||||
|
||||
Static accessors are used throughout api/voxtelesys.py and api/sms.py to read
|
||||
config without re-querying the DB every call. They're cheap (single-row)
|
||||
but kept here so the call sites stay readable.
|
||||
"""
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
|
@ -7,20 +11,26 @@ from frappe.model.document import Document
|
|||
|
||||
class VoxtelesysSettings(Document):
|
||||
def validate(self):
|
||||
self._set_webhook_url_display()
|
||||
self._set_webhook_url_displays()
|
||||
|
||||
def _set_webhook_url_display(self):
|
||||
base = (self.voxml_base_url or "").rstrip("/")
|
||||
if not base:
|
||||
base = frappe.utils.get_url()
|
||||
def _set_webhook_url_displays(self):
|
||||
base = (self.voxml_base_url or "").rstrip("/") or frappe.utils.get_url().rstrip("/")
|
||||
self.webhook_url_display = (
|
||||
f"{base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call"
|
||||
)
|
||||
self.sms_webhook_url_display = (
|
||||
f"{base}/api/method/voxtelesys_integration.api.sms.handle_inbound_sms"
|
||||
)
|
||||
|
||||
# ---- static accessors (read once, no doc instantiation) ----
|
||||
@staticmethod
|
||||
def is_enabled() -> bool:
|
||||
return bool(frappe.db.get_single_value("Voxtelesys Settings", "enabled"))
|
||||
|
||||
@staticmethod
|
||||
def is_sms_enabled() -> bool:
|
||||
return bool(frappe.db.get_single_value("Voxtelesys Settings", "sms_enabled"))
|
||||
|
||||
@staticmethod
|
||||
def get_api_token() -> str:
|
||||
token = frappe.db.get_single_value("Voxtelesys Settings", "api_token")
|
||||
|
|
|
|||
Loading…
Reference in a new issue