2012-07-19 13:40:31 +05:30
|
|
|
from __future__ import unicode_literals
|
2012-03-21 12:29:56 +05:30
|
|
|
install_docs = [
|
2012-04-17 11:45:35 +05:30
|
|
|
{"doctype":"Role", "role_name":"Blogger", "name":"Blogger"},
|
|
|
|
{"doctype":"Role", "role_name":"Website Manager", "name":"Website Manager"},
|
|
|
|
]
|
2012-04-27 18:39:14 +05:30
|
|
|
|
|
|
|
import webnotes
|
|
|
|
|
2012-12-14 16:39:27 +05:30
|
|
|
max_tickets_per_hour = 200
|
|
|
|
|
2012-04-27 18:39:14 +05:30
|
|
|
@webnotes.whitelist(allow_guest=True)
|
|
|
|
def send_message():
|
|
|
|
from webnotes.model.doc import Document
|
|
|
|
|
|
|
|
d = Document('Support Ticket')
|
|
|
|
d.subject = webnotes.form_dict.get('subject', 'Website Query')
|
|
|
|
d.description = webnotes.form_dict.get('message')
|
|
|
|
d.raised_by = webnotes.form_dict.get('sender')
|
2012-12-24 19:50:15 +05:30
|
|
|
d.status = webnotes.form_dict.get("status") or "Open"
|
|
|
|
|
2012-04-27 18:39:14 +05:30
|
|
|
if not d.description:
|
2012-12-14 16:39:27 +05:30
|
|
|
webnotes.response["message"] = 'Please write something'
|
|
|
|
return
|
2012-04-27 18:39:14 +05:30
|
|
|
|
|
|
|
if not d.raised_by:
|
2012-12-14 16:39:27 +05:30
|
|
|
webnotes.response["message"] = 'Email Id Required'
|
|
|
|
return
|
2012-04-27 18:39:14 +05:30
|
|
|
|
2012-12-14 16:39:27 +05:30
|
|
|
# guest method, cap max writes per hour
|
|
|
|
if webnotes.conn.sql("""select count(*) from `tabSupport Ticket`
|
|
|
|
where TIMEDIFF(NOW(), modified) < '01:00:00'""")[0][0] > max_tickets_per_hour:
|
|
|
|
webnotes.response["message"] = "Sorry: we believe we have received an unreasonably high number of requests of this kind. Please try later"
|
|
|
|
return
|
2012-12-10 11:15:59 +05:30
|
|
|
|
2012-04-27 18:39:14 +05:30
|
|
|
d.save()
|
2012-12-14 16:39:27 +05:30
|
|
|
webnotes.response["message"] = 'Thank You'
|
2012-10-16 10:47:18 +05:30
|
|
|
|
|
|
|
def get_site_address():
|
|
|
|
from webnotes.utils import get_request_site_address
|
|
|
|
url = get_request_site_address()
|
|
|
|
|
|
|
|
if not url or url=='http://localhost':
|
|
|
|
new_url = webnotes.conn.get_value('Website Settings', 'Website Settings',
|
|
|
|
'subdomain')
|
|
|
|
if new_url:
|
|
|
|
url = "http://" + new_url
|
|
|
|
|
|
|
|
return url
|