Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions helpdesk/api/agent_home/agent_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_dashboard(reset_layout: bool = False):
dashboard = frappe.db.exists("HD Field Layout", {"user": frappe.session.user})
Expand Down Expand Up @@ -78,6 +79,7 @@ def _resolve_window(period: str):


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_agent_tickets(period: str = "last month"):
current_from, current_to, previous_from, previous_to = _resolve_window(period)
Expand Down Expand Up @@ -139,18 +141,21 @@ def get_ticket_data(from_date, to_date):


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_avg_first_response_time(period: str = "last month"):
return get_avg_time_metric(period, "first_response_time", scope="agent")


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_avg_resolution_time(period: str = "last month"):
return get_avg_time_metric(period, "resolution_time", scope="agent")


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_recent_feedback(
period: str = "all_time",
Expand Down Expand Up @@ -275,6 +280,7 @@ def get_recent_feedback(


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_avg_time_metrics(
period: str = "6m", from_date: str = None, to_date: str = None
Expand Down Expand Up @@ -571,6 +577,7 @@ def _get_pending_response_tickets(limit=10):


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_pending_tickets(ticket_type: str = "upcoming_sla"):
if ticket_type == "upcoming_sla":
Expand Down Expand Up @@ -625,6 +632,7 @@ def get_pending_tickets(ticket_type: str = "upcoming_sla"):


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_recent_activity() -> list[dict]:
"""The current agent's latest action per ticket (replied, commented, updated,
Expand Down
2 changes: 2 additions & 0 deletions helpdesk/api/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def sanitize_query(query: str) -> str:


@frappe.whitelist()
@frappe.read_only()
def get_article_stats(article_name: str):
views = frappe.db.get_value("HD Article", article_name, "views")

Expand Down Expand Up @@ -69,6 +70,7 @@ def get_article_stats(article_name: str):


@frappe.whitelist()
@frappe.read_only()
def search(query: str) -> list:
query = sanitize_query(query)
ret, enough = search_with_enough_results([], query)
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/assignment_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


@frappe.whitelist()
@frappe.read_only()
def get_assignment_rules_list():
if not frappe.has_permission("Assignment Rule", "read"):
frappe.throw(
Expand Down
2 changes: 2 additions & 0 deletions helpdesk/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


@frappe.whitelist()
@frappe.read_only()
def get_user():
current_user = frappe.session.user
filters = {"name": current_user}
Expand Down Expand Up @@ -78,6 +79,7 @@ def get_user():


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_current_user_email_info():
user = frappe.session.user
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


@frappe.whitelist(allow_guest=True)
@frappe.read_only()
def get_config():
fields = [
"brand_name",
Expand Down
2 changes: 2 additions & 0 deletions helpdesk/api/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


@frappe.whitelist(methods=["GET"])
@frappe.read_only()
def search_contacts(
txt: str, additional_filters: str | list | None = None
) -> list[dict[Literal["full_name", "name", "email_id"], str]]:
Expand Down Expand Up @@ -159,6 +160,7 @@ def edit_contact(name: str, doc: dict):


@frappe.whitelist(methods=["GET"])
@frappe.read_only()
def get_contact_info(name: str) -> dict:
frappe.has_permission("Contact", "read", doc=name, throw=True)
contact = frappe.get_doc("Contact", name)
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_dashboard_data(
dashboard_type: str, filters: dict[str, any] = None
Expand Down
4 changes: 4 additions & 0 deletions helpdesk/api/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


@frappe.whitelist()
@frappe.read_only()
def get_list_data(
doctype: str,
# flake8: noqa
Expand Down Expand Up @@ -244,6 +245,7 @@ def get_options(fieldtype, options):


@frappe.whitelist()
@frappe.read_only()
@redis_cache()
def get_filterable_fields(
doctype: str,
Expand Down Expand Up @@ -393,6 +395,7 @@ def get_filterable_fields(


@frappe.whitelist()
@frappe.read_only()
def sort_options(doctype: str, show_customer_portal_fields: bool = False):
fields = frappe.get_meta(doctype).fields
fields = [field for field in fields if field.fieldtype not in no_value_fields]
Expand Down Expand Up @@ -422,6 +425,7 @@ def sort_options(doctype: str, show_customer_portal_fields: bool = False):


@frappe.whitelist()
@frappe.read_only()
def get_quick_filters(doctype: str, show_customer_portal_fields: bool = False):
meta = frappe.get_meta(doctype)
fields = [field for field in meta.fields if field.in_standard_filter]
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


@frappe.whitelist(allow_guest=True, methods=["GET"])
@frappe.read_only()
def get_translations():
language = None
if frappe.session.user != "Guest":
Expand Down
5 changes: 5 additions & 0 deletions helpdesk/api/knowledge_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


@frappe.whitelist(allow_guest=True)
@frappe.read_only()
def get_article(name: str):
article = frappe.get_doc("HD Article", name).as_dict()

Expand Down Expand Up @@ -87,6 +88,7 @@ def move_to_category(category: str, articles: list[str]):


@frappe.whitelist()
@frappe.read_only()
def get_categories():
categories = frappe.get_list(
"HD Article Category",
Expand All @@ -103,6 +105,7 @@ def get_categories():


@frappe.whitelist()
@frappe.read_only()
def get_category_articles(category: str):
articles = frappe.get_list(
"HD Article",
Expand Down Expand Up @@ -140,13 +143,15 @@ def merge_category(source: str, target: str):


@frappe.whitelist()
@frappe.read_only()
def get_general_category():
return frappe.db.get_value(
"HD Article Category", {"category_name": "General"}, "name"
)


@frappe.whitelist()
@frappe.read_only()
def get_category_title(category: str):
return frappe.db.get_value("HD Article Category", category, "category_name")

Expand Down
3 changes: 3 additions & 0 deletions helpdesk/api/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ def mark_persona_captured(brand_name: str | None = None) -> None:


@frappe.whitelist()
@frappe.read_only()
@agent_manager_only
def get_welcome_ticket() -> str | None:
"""Name of the seeded welcome ticket, if it still exists."""
return frappe.db.get_value("HD Ticket", {"subject": "Welcome to Helpdesk"}, "name")


@frappe.whitelist()
@frappe.read_only()
def get_first_ticket(ticket: str | None = None):
"""Get first ticket created except the default ticket"""
# If a cached ticket ID was passed, verify it still exists
Expand All @@ -49,6 +51,7 @@ def get_first_ticket(ticket: str | None = None):


@frappe.whitelist()
@frappe.read_only()
def get_general_category_id():
"""Get the id of the general category"""
category = frappe.get_all(
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/saved_replies.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_rendered_saved_reply(ticket_id: str, saved_reply_id: str | None = None):
if not saved_reply_id:
Expand Down
2 changes: 2 additions & 0 deletions helpdesk/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


@frappe.whitelist()
@frappe.read_only()
def search(
query: str, filters: str | None = None, limit: int = 20, title_only: bool = False
):
Expand Down Expand Up @@ -42,6 +43,7 @@ def search(


@frappe.whitelist()
@frappe.read_only()
def get_filter_options():
"""Get available filter options for search interface"""
from helpdesk.search_sqlite import HelpdeskSearch
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_users():
session_user = frappe.session.user
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/settings/email_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def get_reply_via_agent_data():


@frappe.whitelist(methods=["GET"])
@frappe.read_only()
def get_data(notification: str):
only_for_managers()

Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/settings/field_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


@frappe.whitelist()
@frappe.read_only()
def get_field_dependency(name: str):
"""
Returns the field dependency for the given name.
Expand Down
1 change: 1 addition & 0 deletions helpdesk/api/ticket_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_ticket_analytics(ticket: str) -> dict:
frappe.has_permission("HD Ticket", "read", ticket, throw=True)
Expand Down
5 changes: 5 additions & 0 deletions helpdesk/api/ticket_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def _fill_date_series(from_date_str, to_date_str, rows: list) -> list:


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_feedback_received(
scope: Scope,
Expand Down Expand Up @@ -91,6 +92,7 @@ def get_feedback_received(


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_sla_violations(
dt: str,
Expand Down Expand Up @@ -206,6 +208,7 @@ def _query(from_date, to_date, grouped=False):


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_avg_first_response_time(
dt: str,
Expand All @@ -216,6 +219,7 @@ def get_avg_first_response_time(


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_avg_resolution_time(
dt: str,
Expand All @@ -226,6 +230,7 @@ def get_avg_resolution_time(


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_ticket_stats(
dt: str,
Expand Down
2 changes: 2 additions & 0 deletions helpdesk/helpdesk/doctype/hd_customer/hd_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def get_user(self, contact_name, throw_error=True):
return None

@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_contacts(self):
contact_names = [contact.contact_name for contact in self.contacts]
Expand Down Expand Up @@ -332,6 +333,7 @@ def invite_contacts(self, to_invite: list[dict], role: str) -> dict:
return result

@frappe.whitelist()
@frappe.read_only()
def get_pending_invites(self):
if "Agent Manager" not in frappe.get_roles():
frappe.throw(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def clear_table(self):


@frappe.whitelist()
@frappe.read_only()
def get_events(start: str, end: str, filters: str | None = None):
"""Returns events for Gantt / Calendar view rendering.

Expand Down
1 change: 1 addition & 0 deletions helpdesk/helpdesk/doctype/hd_settings/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def get_default_email_content(type: str) -> str:


@frappe.whitelist()
@frappe.read_only()
def get_banner_msg():
"""Get current and default banner message for settings UI"""

Expand Down
1 change: 1 addition & 0 deletions helpdesk/helpdesk/doctype/hd_team/hd_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def unassign_condition(self, team_name: str) -> tuple[str, str]:


@frappe.whitelist()
@frappe.read_only()
@agent_only
def get_team_members(team: str):
return frappe.get_all("HD Team Member", filters={"parent": team}, pluck="user")
Loading
Loading