Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 6 | from webnotes import _ |
| 7 | from webnotes.utils import today |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 8 | |
Anand Doshi | b0d996f | 2013-09-10 18:29:39 +0530 | [diff] [blame] | 9 | no_cache = True |
| 10 | |
Anand Doshi | 330dae9 | 2013-09-10 13:46:15 +0530 | [diff] [blame] | 11 | def 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 Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 24 | |
| 25 | @webnotes.whitelist() |
| 26 | def 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 Mehta | 39bb8e2 | 2013-12-11 15:32:14 +0530 | [diff] [blame] | 34 | from webnotes.core.doctype.communication.communication import make |
Anand Doshi | fb109ad | 2013-09-11 18:58:20 +0530 | [diff] [blame] | 35 | make(content=message, sender=bean.doc.raised_by, subject = bean.doc.subject, |
| 36 | doctype="Support Ticket", name=bean.doc.name, |
| 37 | date=today()) |