# Path: jasper_erpnext_report/utils/file.py
# def get_extension(fname):
# 
# 	ext = fname.rsplit(".",1)
# 
# 	if len(ext) > 1:
# 		return ext[1].lower()
# 
# 	return ext[0]


import frappe
import frappe.utils
from frappe import _
from jasper_erpnext_report.utils.file import get_extension
from __future__ import unicode_literals
__author__ = 'luissaguas'

no_cache = True

def get_context(context):
	if frappe.local.session['sid'] == 'Guest':
		return {"message":_("Please login first."), "doc_title":_("Not Permitted")}

	jasper_report_path = frappe.form_dict.jasper_doc_path
	if not jasper_report_path:
		return {"message":_("Switch to Desk to see the list of reports."), "doc_title":_("Not Permitted")}

	filename = jasper_report_path.rsplit("/",1)[1]
	doc_title = jasper_report_path.split("/",1)[0]

# Path: jasper_erpnext_report/utils/file.py
# def get_extension(fname):
# 
# 	ext = fname.rsplit(".",1)
# 
# 	if len(ext) > 1:
# 		return ext[1].lower()
# 
# 	return ext[0]


# Path: jasper_erpnext_report/templates/pages/Jasper Reports.py
import frappe
import frappe.utils
from frappe import _
from jasper_erpnext_report.utils.file import get_extension

from __future__ import unicode_literals
__author__ = 'luissaguas'

no_cache = True

def get_context(context):
	if frappe.local.session['sid'] == 'Guest':
		return {"message":_("Please login first."), "doc_title":_("Not Permitted")}

	jasper_report_path = frappe.form_dict.jasper_doc_path
	if not jasper_report_path:
		return {"message":_("Switch to Desk to see the list of reports."), "doc_title":_("Not Permitted")}

	filename = jasper_report_path.rsplit("/",1)[1]
	doc_title = jasper_report_path.split("/",1)[0]

	ext = get_extension(filename)