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
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
@ -7,20 +11,26 @@ from frappe.model.document import Document
|
||||||
|
|
||||||
class VoxtelesysSettings(Document):
|
class VoxtelesysSettings(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self._set_webhook_url_display()
|
self._set_webhook_url_displays()
|
||||||
|
|
||||||
def _set_webhook_url_display(self):
|
def _set_webhook_url_displays(self):
|
||||||
base = (self.voxml_base_url or "").rstrip("/")
|
base = (self.voxml_base_url or "").rstrip("/") or frappe.utils.get_url().rstrip("/")
|
||||||
if not base:
|
|
||||||
base = frappe.utils.get_url()
|
|
||||||
self.webhook_url_display = (
|
self.webhook_url_display = (
|
||||||
f"{base}/api/method/voxtelesys_integration.api.voxtelesys.handle_inbound_call"
|
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
|
@staticmethod
|
||||||
def is_enabled() -> bool:
|
def is_enabled() -> bool:
|
||||||
return bool(frappe.db.get_single_value("Voxtelesys Settings", "enabled"))
|
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
|
@staticmethod
|
||||||
def get_api_token() -> str:
|
def get_api_token() -> str:
|
||||||
token = frappe.db.get_single_value("Voxtelesys Settings", "api_token")
|
token = frappe.db.get_single_value("Voxtelesys Settings", "api_token")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue