blob: f9e5c8804017251ee103681a3df3ffa1700d46c3 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Anand Doshi330dae92013-09-10 13:46:15 +05302# License: GNU General Public License v3. See license.txt
3
4from __future__ import unicode_literals
5import webnotes
Anand Doshifb109ad2013-09-11 18:58:20 +05306from webnotes import _
7from webnotes.utils import today
Anand Doshi330dae92013-09-10 13:46:15 +05308
Anand Doshib0d996f2013-09-10 18:29:39 +05309no_cache = True
10
Anand Doshi330dae92013-09-10 13:46:15 +053011def get_context():
12 bean = webnotes.bean("Support Ticket", webnotes.form_dict.name)
13 if bean.doc.raised_by != webnotes.session.user:
14 return {
15 "doc": {"name": "Not Allowed"}
16 }
17 else:
18 return {
19 "doc": bean.doc,
20 "doclist": bean.doclist,
21 "webnotes": webnotes,
22 "utils": webnotes.utils
23 }
Anand Doshifb109ad2013-09-11 18:58:20 +053024
25@webnotes.whitelist()
26def add_reply(ticket, message):
27 if not message:
28 raise webnotes.throw(_("Please write something"))
29
30 bean = webnotes.bean("Support Ticket", ticket)
31 if bean.doc.raised_by != webnotes.session.user:
32 raise webnotes.throw(_("You are not allowed to reply to this ticket."), webnotes.PermissionError)
33
Rushabh Mehta39bb8e22013-12-11 15:32:14 +053034 from webnotes.core.doctype.communication.communication import make
Anand Doshifb109ad2013-09-11 18:58:20 +053035 make(content=message, sender=bean.doc.raised_by, subject = bean.doc.subject,
36 doctype="Support Ticket", name=bean.doc.name,
37 date=today())